Makepad アニメーションスキル は何をしますか?
バージョン: makepad-widgets (dev ブランチ) | 最終更新: 2026-01-19
あなたは Makepad アニメーションの専門家です。以下のようにユーザーを支援してください:
- コードの作成: 以下のパターンに従ってアニメーションコードを生成
- 質問への回答: 状態、トランジション、タイムラインを解説
使用すべきタイミング
- Makepad でアニメーション、トランジション、ホバー状態、アニメーターのタイムラインを構築またはデバッグする必要がある場合。
- タスクが
animator、状態変更、イージング、キーフレーム、または視覚的なインタラクションフィードバックに関連している場合。 - 一般的な Rust UI ガイダンスではなく、Makepad 固有のアニメーションパターンが必要な場合。
ドキュメント
詳細なドキュメントについては、ローカルファイルを参照してください:
./references/animation-system.md- 完全なアニメーションリファレンス
高度なパターン
本番環境で使用可能なアニメーションパターンについては、_base/ ディレクトリを参照:
| パターン | 説明 |
|---|---|
| 06-animator-basics | アニメーターの基礎 |
| 07-easing-functions | イージングとタイミング |
| 08-keyframe-animation | 複雑なキーフレーム |
重要: ドキュメント完全性チェック
質問に答える前に、Claude は以下を実行する必要があります:
- 上記の関連リファレンスファイルを読む
- ファイルの読み取りに失敗した場合、またはファイルが空の場合:
- ユーザーに通知: "ローカルドキュメントが不完全です。
/sync-crate-skills makepad --forceを実行してドキュメントを更新することをお勧めします。" - それでも SKILL.md のパターンと組み込み知識に基づいて回答する
- ユーザーに通知: "ローカルドキュメントが不完全です。
- リファレンスファイルが存在する場合、その内容を回答に組み込む
主要パターン
1. 基本のホバーアニメーション
<Button> {
text: "Hover Me"
animator: {
hover = {
default: off
off = {
from: { all: Forward { duration: 0.15 } }
apply: {
draw_bg: { color: #333333 }
}
}
on = {
from: { all: Forward { duration: 0.15 } }
apply: {
draw_bg: { color: #555555 }
}
}
}
}
}
2. 複数状態アニメーション
<View> {
animator: {
hover = {
default: off
off = {
from: { all: Forward { duration: 0.2 } }
apply: { draw_bg: { color: #222222 } }
}
on = {
from: { all: Forward { duration: 0.2 } }
apply: { draw_bg: { color: #444444 } }
}
}
pressed = {
default: off
off = {
from: { all: Forward { duration: 0.1 } }
apply: { draw_bg: { scale: 1.0 } }
}
on = {
from: { all: Forward { duration: 0.1 } }
apply: { draw_bg: { scale: 0.95 } }
}
}
}
}
3. フォーカス状態アニメーション
<TextInput> {
animator: {
focus = {
default: off
off = {
from: { all: Forward { duration: 0.2 } }
apply: {
draw_bg: {
border_color: #444444
border_size: 1.0
}
}
}
on = {
from: { all: Forward { duration: 0.2 } }
apply: {
draw_bg: {
border_color: #0066CC
border_size: 2.0
}
}
}
}
}
}
4. 無効状態
<Button> {
animator: {
disabled = {
default: off
off = {
from: { all: Snap }
apply: {
draw_bg: { color: #0066CC }
draw_text: { color: #FFFFFF }
}
}
on = {
from: { all: Snap }
apply: {
draw_bg: { color: #333333 }
draw_text: { color: #666666 }
}
}
}
}
}
アニメーター構造
| プロパティ | 説明 |
|---|---|
animator | ルートのアニメーションコンテナ |
{state} = | 状態定義 (hover、pressed、focus、disabled) |
default: | 初期状態値 |
{value} = | 状態値の定義 (on、off、custom) |
from: | トランジションのタイムライン |
apply: | アニメーション対象のプロパティ |
タイムラインタイプ (Play 列挙型)
| タイプ | 説明 |
|---|---|
Forward { duration: f64 } | 線形順方向アニメーション |
Snap | 即時変更、トランジションなし |
Reverse { duration: f64, end: f64 } | 逆方向アニメーション |
Loop { duration: f64, end: f64 } | ループアニメーション |
BounceLoop { duration: f64, end: f64 } | バウンスループアニメーション |
イージング関数 (Ease 列挙型)
// 基本
Linear
// 2次
InQuad, OutQuad, InOutQuad
// 3次
InCubic, OutCubic, InOutCubic
// 4次
InQuart, OutQuart, InOutQuart
// 5次
InQuint, OutQuint, InOutQuint
// 正弦波
InSine, OutSine, InOutSine
// 指数
InExp, OutExp, InOutExp
// 円形
InCirc, OutCirc, InOutCirc
// 弾性
InElastic, OutElastic, InOutElastic
// バック
InBack, OutBack, InOutBack
// バウンス
InBounce, OutBounce, InOutBounce
// カスタム
ExpDecay { d1: f64, d2: f64 }
Bezier { cp0: f64, cp1: f64, cp2: f64, cp3: f64 }
Pow { begin: f64, end: f64 }
イージングの使用例
from: {
all: Ease { duration: 0.3, ease: InOutQuad }
}
一般的な状態
| 状態 | 値 | トリガー |
|---|---|---|
hover | on、off | マウス ホバー入/出 |
pressed / down | on、off | マウス 押下/解放 |
focus | on、off | フォーカス 取得/喪失 |
disabled | on、off | ウィジェット 有効/無効 |
selected | on、off | 選択状態の変更 |
アニメーション可能なプロパティ
ほとんどの draw_* シェーダーユニフォームをアニメーション化できます:
- 色:
color、border_color、shadow_color - サイズ:
border_size、border_radius、shadow_radius - 変形:
scale、rotation、offset - 不透明度:
opacity
コード作成時の注意点
- 初期状態には必ず
default:を設定する - スムーズなトランジションには
Forwardを使用する - 即時状態変更(無効など)には
Snapを使用する - レスポンシブな感覚を保つため、継続時間は短く(0.1〜0.3秒)設定する
draw_bg、draw_textなどのシェーダーユニフォームをアニメーション化する
Rust API (AnimatorImpl トレイト)
pub trait AnimatorImpl {
// 状態にアニメーション
fn animator_play(&mut self, cx: &mut Cx, state: &[LiveId; 2]);
// 状態にカット(アニメーションなし)
fn animator_cut(&mut self, cx: &mut Cx, state: &[LiveId; 2]);
// 現在の状態を確認
fn animator_in_state(&self, cx: &Cx, state: &[LiveId; 2]) -> bool;
}
// 使用例
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
match event.hits(cx, self.area()) {
Hit::FingerHoverIn(_) => {
self.animator_play(cx, id!(hover.on));
}
Hit::FingerHoverOut(_) => {
self.animator_play(cx, id!(hover.off));
}
Hit::FingerDown(_) => {
self.animator_play(cx, id!(pressed.on));
}
Hit::FingerUp(_) => {
self.animator_play(cx, id!(pressed.off));
}
_ => {}
}
}
質問に答える際の注意点
- 状態は独立しており、複数の状態を同時にアクティブにできる
- 状態がその値に達したときに、アニメーションがプロパティを適用する
fromは「どのように」アニメーションするかを定義し、applyは「何を」アニメーションするかを定義する- Makepad は古い値と新しい値の間を自動的に補間する
- Rust でアニメーション状態を参照するには
id!(state.value)マクロを使用する
制限事項
- このスキルは、タスクが上記の範囲と明確に一致する場合にのみ使用してください。
- 出力を、環境固有の検証、テスト、または専門家によるレビューの代わりとして扱わないでください。
- 必要な入力、権限、安全境界、または成功基準が欠けている場合は、立ち止まって明確化を求めてください。