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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
takashi
September 18, 2024
Programming
120
0
Share
CustomPainterとAnimationControllerを使用したアニメーション作成
GitHubリポジトリ:
https://github.com/takashi0602/flutter_sample_animation
takashi
September 18, 2024
More Decks by takashi
See All by takashi
Flutterで実装するCompound Pattern
takashimelon
0
75
hanging-punctuation
takashimelon
0
30
Flutterで作るお絵かきアプリ
takashimelon
0
260
いいから黙ってアニメーションはCSSで書いておけ
takashimelon
0
90
Flutter x Socket.IOで行うリアルタイム通信
takashimelon
0
410
XDからFigmaに乗り換えた話
takashimelon
0
78
webaudioapi.pdf
takashimelon
0
32
IT × 音楽 ~Web Audio API~
takashimelon
0
67
HTML5.1について
takashimelon
0
220
Other Decks in Programming
See All in Programming
AIとRubyの静的型付け
ukin0k0
0
190
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
390
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
300
ビジネスモデルから紐解く、AI+型駆動開発
hirokiomote
2
3.3k
横断組織出身のQAEがインプロセスQAEでつまずいたこと・活かせたこと
ty89
0
430
Oxlintのカスタムルールの現況
syumai
5
750
サークル参加から学ぶ、小さな事業の回し方
yuzneri
0
240
AI時代になぜ書くのか
mutsumix
0
470
iOS26時代の新規アプリ開発
yuukiw00w
0
210
Swiftのレキシカルスコープ管理
kntkymt
0
200
AlarmKitで明後日起きれるアラームアプリを作る
trickart
0
160
TypeSpec で繋ぐ複数プロダクトの型安全
maroon8021
1
260
Featured
See All Featured
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
330
Speed Design
sergeychernyshev
33
1.7k
Why Our Code Smells
bkeepers
PRO
340
58k
Typedesign – Prime Four
hannesfritz
42
3k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
210
Building AI with AI
inesmontani
PRO
1
1k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
The Cult of Friendly URLs
andyhume
79
6.9k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
The browser strikes back
jonoalderson
0
1.1k
Between Models and Reality
mayunak
4
310
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アニメーションみたいなこともできる - アニメーションはおもしろい
ご清聴ありがとうございました