Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
夏 × Jetpack Compose
Search
ねも
July 24, 2023
99
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
夏 × Jetpack Compose
要はComposeのCanvasでのお絵描きです
ねも
July 24, 2023
More Decks by ねも
See All by ねも
Compose Multiplatform for iOS開発でぶつかった壁
kohei_inoue
0
1.9k
ノンプログラマのための ~アルゴリズムパズル プログラマのための数学パズル入門~
kohei_inoue
0
94
ノンデザイナーズ・デザインブックを読んだので名刺作ってみた
kohei_inoue
0
100
Compose Multiplatform for iOSで音声再生しようぜ!!
kohei_inoue
0
380
Compose for iOS for ZOZOTOWN
kohei_inoue
0
1.9k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
699
190k
My Coaching Mixtape
mlcsv
0
320
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
690
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Designing Powerful Visuals for Engaging Learning
tmiket
1
570
Automating Front-end Workflow
addyosmani
1369
210k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Utilizing Notion as your number one productivity tool
mfonobong
4
590
Documentation Writing (for coders)
carmenintech
77
5.5k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
500
Six Lessons from altMBA
skipperchong
29
4.5k
Transcript
夏 × Jetpack Compose Twitter (X): https://twitter.com/nemo_855 GitHub: https://github.com/nemo-855 Qiita:
https://qiita.com/nemo-855 Android エンジニア 井上 晃平 / ねも
突然ですがみなさん、 夏といえば?
花火 🎇
まずはこちらをご覧ください
None
裏テーマ Compose の Canvas お絵描き
🍉 目次 ✓ 花びらを作る ✓ 表示割合を指定できるようになる ✓ まるく並べる
🌼 花びらを作る① private fun DrawScope.drawFlowerPetal( size: Size, color: Color, angle:
Float = 0f, ) { rotate(degrees = angle) { // Pathで花びらを描画 } }
🌼 花びらを作る② val path = Path().apply { moveTo(0f, 0f) quadraticBezierTo(
size.width * 5 / 6, size.height * 1 / 6, size.width, size.height, ) moveTo(size.width, size.height) quadraticBezierTo( size.width * 1 / 6, size.height * 5 / 6, 0f, 0f, ) } O size.width size.height 現在地が始点 赤 → 制御点 青 → 終点
🍧 表示割合を指定できるようにする① private fun DrawScope.drawFlowerPetal( size: Size, color: Color, angle:
Float = 0f, displayRatio: Float = 1.0f, ) { rotate(degrees = angle) { // Pathで花びらを描画 // clipPathで指定領域だけ表示させる } } O size.width 2 * size.width 2 * size.height size.height
🍧 表示割合を指定できるようにする② clipPath(path = path) { val triangleWidth = 2
* size.width * displayRatio val triangleHeight = 2 * size.height * displayRatio val trianglePath = Path().apply { moveTo(triangleWidth, 0f) lineTo(0f, triangleHeight) lineTo(0f, 0f) close() } drawPath( path = trianglePath, color = color, style = Fill ) } } O size.width 2 * size.width 2 * size.height size.height
🛟 まるく並べる① @Composable private fun FlowerPetalsRing( modifier: Modifier = Modifier,
flowerPetalRectSize: Size, numberOfFlowerPetal: Int, flowerPetalColor: Color, percent: Float = 1.0f, ) { // 描画処理 }
🛟 まるく並べる② BoxWithConstraints( modifier = modifier.fillMaxWidth().aspectRatio(1f) ) { val pieceLength
= with(LocalDensity.current) constraints.maxWidth.toDp() }.value val padding = (sqrt(2f) - 1) / 2 * pieceLength Canvas( modifier = Modifier.fillMaxSize().padding(padding.dp) ) { for (i in 0 until numberOfFlowerPetal) { val angle = (360 / numberOfFlowerPetal * i).toFloat() drawFlowerPetal( size = flowerPetalRectSize, color = flowerPetalColor, angle = angle, displayRatio = percent, ) } } }
あとはこれを重ねて Sliderで調整できるようにすると、、、
None
サンプルコード → https://github.com/nemo-855/Fireworks 🏖終わり