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
20
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で作るお絵かきアプリ
takashimelon
0
140
いいから黙ってアニメーションはCSSで書いておけ
takashimelon
0
54
Flutter x Socket.IOで行うリアルタイム通信
takashimelon
0
210
XDからFigmaに乗り換えた話
takashimelon
0
68
webaudioapi.pdf
takashimelon
0
19
IT × 音楽 ~Web Audio API~
takashimelon
0
53
HTML5.1について
takashimelon
0
200
Other Decks in Programming
See All in Programming
VS Code extension: ドラッグ&ドロップでファイルを並び替える
ttrace
0
160
M5Stackボードの選び方
tanakamasayuki
0
200
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
6
240
CSC509 Lecture 03
javiergs
PRO
0
130
Flutterアプリを生成AIで生成する勘所
rizumita
0
250
pytest プラグインを開発して DRY に自動テストを書こう
inuatsu
2
250
Cancel Next.js Page Navigation: Full Throttle
ypresto
1
130
実践Dash - 手を抜きながら本気で作るデータApplicationの基本と応用 / Dash for Python and Baseball
shinyorke
2
230
Интеграционное тестирование: как приручить хаос
mariyasaygina
0
500
Pydantic x Database API:turu-pyの開発
yassun7010
1
510
◯◯エンジニアになった理由
gessy0129
PRO
0
610
Rails 8 Frontend: 10 commandments & 7 deadly sins in 2025
yshmarov
1
600
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
25
650
Into the Great Unknown - MozCon
thekraken
30
1.4k
We Have a Design System, Now What?
morganepeng
49
7.1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
29
1.7k
Mobile First: as difficult as doing things right
swwweet
222
8.8k
How to train your dragon (web standard)
notwaldorf
87
5.6k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
26
4k
Scaling GitHub
holman
458
140k
How to Ace a Technical Interview
jacobian
275
23k
Faster Mobile Websites
deanohume
304
30k
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アニメーションみたいなこともできる - アニメーションはおもしろい
ご清聴ありがとうございました