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
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
80
hanging-punctuation
takashimelon
0
35
Flutterで作るお絵かきアプリ
takashimelon
0
290
いいから黙ってアニメーションはCSSで書いておけ
takashimelon
0
94
Flutter x Socket.IOで行うリアルタイム通信
takashimelon
0
430
XDからFigmaに乗り換えた話
takashimelon
0
84
webaudioapi.pdf
takashimelon
0
41
IT × 音楽 ~Web Audio API~
takashimelon
0
79
HTML5.1について
takashimelon
0
220
Other Decks in Programming
See All in Programming
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.7k
Oxlintはいいぞ(続)
yug1224
1
410
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
430
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
600
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
730
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
290
Cloudflare is Agents
chimame
0
180
源内ハンズオン概要編
hideg
0
210
AWS Transform Customによる Spring Boot 2.xから4.xへのVerUp
satoshi256kbyte
2
100
React本体のコードリーディング
high_g_engineer
1
150
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
710
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
110
Featured
See All Featured
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
GitHub's CSS Performance
jonrohan
1033
470k
How STYLIGHT went responsive
nonsquared
100
6.2k
Product Roadmaps are Hard
iamctodd
55
12k
BBQ
matthewcrist
89
10k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
500
The Cult of Friendly URLs
andyhume
79
7k
Designing Experiences People Love
moore
143
24k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
280
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6.1k
Unsuck your backbone
ammeep
672
58k
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アニメーションみたいなこともできる - アニメーションはおもしろい
ご清聴ありがとうございました