Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CustomPainterとAnimationControllerを使用したアニメーション作成
Search
takashi
September 18, 2024
Programming
0
100
CustomPainterとAnimationControllerを使用したアニメーション作成
GitHubリポジトリ:
https://github.com/takashi0602/flutter_sample_animation
takashi
September 18, 2024
Tweet
Share
More Decks by takashi
See All by takashi
Flutterで実装するCompound Pattern
takashimelon
0
63
hanging-punctuation
takashimelon
0
23
Flutterで作るお絵かきアプリ
takashimelon
0
220
いいから黙ってアニメーションはCSSで書いておけ
takashimelon
0
79
Flutter x Socket.IOで行うリアルタイム通信
takashimelon
0
370
XDからFigmaに乗り換えた話
takashimelon
0
70
webaudioapi.pdf
takashimelon
0
20
IT × 音楽 ~Web Audio API~
takashimelon
0
58
HTML5.1について
takashimelon
0
210
Other Decks in Programming
See All in Programming
時間軸から考えるTerraformを使う理由と留意点
fufuhu
16
4.8k
Reading Rails 1.0 Source Code
okuramasafumi
0
250
AIを活用し、今後に備えるための技術知識 / Basic Knowledge to Utilize AI
kishida
22
5.9k
@Environment(\.keyPath)那么好我不允许你们不知道! / atEnvironment keyPath is so good and you should know it!
lovee
0
120
私の後悔をAWS DMSで解決した話
hiramax
4
210
Updates on MLS on Ruby (and maybe more)
sylph01
1
180
Processing Gem ベースの、2D レトロゲームエンジンの開発
tokujiros
2
130
Ruby×iOSアプリ開発 ~共に歩んだエコシステムの物語~
temoki
0
340
2025 年のコーディングエージェントの現在地とエンジニアの仕事の変化について
azukiazusa1
24
12k
楽して成果を出すためのセルフリソース管理
clipnote
0
180
個人軟體時代
ethanhuang13
0
330
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
310
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1370
200k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
Making Projects Easy
brettharned
117
6.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3k
Docker and Python
trallard
46
3.6k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.6k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
810
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.6k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Transcript
CustomPainterと AnimationControllerを使用した アニメーション作成 たかし
目次 - 自己紹介 - GitHubリポジトリ - 完成デモ - CustomPainterとは -
AnimationControllerとは - 実装 - 改めてデモ - おわりに
自己紹介
自己紹介 - 名前: たかし - 年齢: 26 - 職種: フロントエンドエンジニア兼Flutterエンジニア
- 趣味: 旅行・推し活
GitHubリポジトリ
https://github.com/takashi0602/flutter_sample_animation
完成デモ
https://github.com/takashi0602/flutter_sample_animation /blob/main/video/star-path-animation.mp4
CustomPainterとは
CustomPainterとは - パスを描画するためのクラス - Canvas / Path / Paintを使用して、CustomPaint上に描画する -
主要なメソッド - paint - 描画処理の実装を記述する - shouldRepaint - 再描画が必要かどうかを記述する
AnimationControllerとは
AnimationControllerとは - アニメーションを制御するためのクラス - 時間の経過に基づいて、 valueプロパティがlowerBoundからupperBoundまでの値を取り、アニメー ションの進行度を示す - lowerBoundとupperBoundのデフォルト値は0と1 -
主なプロパティとメソッド - vsync - 使用するTickerを設定 - Tickerとは毎フレームごとにコールバックを発生させるメカニズムで、アニメーションの 更新を提供する - forward / reverse / repeat - アニメーションを前方向 / 逆方向 / 繰り返し再生
実装
星の実装
星の実装 - 2つの五角形を求めることで各頂点をlintToメソッドで繋ぎ合わせている
AnimationControllerの実装
AnimationControllerの実装 - SingleTickerProviderStateMixinを使用し、vsyncを設定 - durationを5秒に設定 - repeatメソッドを使用し、アニメーションを繰り返し再生
CustomPainter の実装
CustomPainterの実装 - path.computeMetricsメソッドを使用し、パスの詳細な情報を含むデータ(メトリク ス)を取得 - moveToの数に応じてメトリクスを配列で受け取る(今回は 1つ) - アニメーションの進捗度に応じたパスの長さを求め、その長さ分のパスを抽出 -
Paintクラスを使用し、パスのスタイルを定義 - canvas.drawPathメソッドを使用し、パスを描画
buildメソッド の実装
buildメソッドの実装 - _createStarPathメソッドを使用して、星のパスを取得 - AnimatedBuilderにAnimationControllerを設定 - CustomPaintにStarPainterとSizeを設定
改めてデモ
https://github.com/takashi0602/flutter_sample_animation /blob/main/video/star-path-animation.mp4
おわりに
おわりに - CustomPainterとAnimationControllerを使用することで、アニメーションの幅が広 がる - SVG画像をPathに変換すれば、SVGアニメーションみたいなこともできる - アニメーションはおもしろい
ご清聴ありがとうございました