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
77
hanging-punctuation
takashimelon
0
34
Flutterで作るお絵かきアプリ
takashimelon
0
290
いいから黙ってアニメーションはCSSで書いておけ
takashimelon
0
93
Flutter x Socket.IOで行うリアルタイム通信
takashimelon
0
430
XDからFigmaに乗り換えた話
takashimelon
0
84
webaudioapi.pdf
takashimelon
0
39
IT × 音楽 ~Web Audio API~
takashimelon
0
76
HTML5.1について
takashimelon
0
220
Other Decks in Programming
See All in Programming
霧の中の代数的エフェクト
funnyycat
1
350
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
1.1k
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
210
どこまでゆるくて許されるのか
tk3fftk
0
480
symfony/aiとlaravel/boost
77web
0
120
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
170
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
3
4.3k
【やさしく解説 設計編 #1】「ドメイン駆動」と「実装駆動」ってなに? 〜設計の考え方を、たとえ話で学ぼう〜
panda728
PRO
1
110
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
160
使用 Meilisearch 建立新聞搜尋工具
johnroyer
0
140
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.4k
自作OSでスライド発表する
uyuki234
1
3.8k
Featured
See All Featured
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
340
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
420
Rails Girls Zürich Keynote
gr2m
96
14k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
210
From π to Pie charts
rasagy
0
230
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
370
The World Runs on Bad Software
bkeepers
PRO
72
12k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
320
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
360
Ruling the World: When Life Gets Gamed
codingconduct
0
280
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
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アニメーションみたいなこともできる - アニメーションはおもしろい
ご清聴ありがとうございました