動的、手続き的、表現に基づくアニメーションを作成するための高度なアニメーションシステムで、単純なキーフレームを超えたものです。
アニメーションシステムは、従来のキーフレームを超えた複数の種類をサポートしています。
これらの高度なアニメーションは、要素の animations 配列プロパティで定義されます。
ノードアニメーション (animations 配列):
キーフレーム (keyframes 配列):
複数のアニメーションメソッドが同じプロパティを対象とする場合:
| プロパティ | タイプ | 必須 | 例 | 値の範囲 | 説明 |
|---|---|---|---|---|---|
| type | string | true | - | expression | procedural | sequence | path | アニメーションのタイプ。 |
| enabled | boolean | false | - | - | アニメーションがアクティブかどうか。 |
| target | string | true | - | - | アニメーションするプロパティパス(例: "x", "rotation", "scaleX")。 |
| startTime | number | false | - | - | 要素の開始に対するアニメーションの開始時間(秒単位)。 |
| duration | number | false | - | - | アニメーションの持続時間(秒単位)。ループアニメーションの場合、これはループ期間です。 |
| loop | boolean | false | - | - | アニメーションがループするかどうか。 |
| blendMode | string | false | - | replace | add | multiply | このアニメーションが他のアニメーションとどのように組み合わさるか: 置き換え(上書き)、加算(合計)、乗算(スケール)。 |
| blendWeight | number | false | - | - | このアニメーションの強さ/影響(0-1)。複数のアニメーションのブレンドに使用されます。 |
表現は、アニメーションコンテキスト変数にアクセスしながらフレームごとに評価されるJavaScriptコードです。
{
time: number; // 現在の絶対時間(秒)
localTime: number; // 要素開始に対する時間
duration: number; // 要素の持続時間
progress: number; // 正規化された進行状況(0-1)
index: number; // グループ内の要素インデックス
total: number; // グループ内の総要素数
fps: number; // 秒間フレーム数
width: number; // キャンバス幅
height: number; // キャンバス高さ
value: any; // 現在のプロパティ値
}Math関数を使用したバウンスアニメーション:
{
"id": "element-1",
"type": "Image",
"start": 0,
"duration": 5,
"animations": [
{
"type": "expression",
"target": "y",
"enabled": true,
"expression": "100 + Math.abs(Math.sin(localTime * 3)) * 200",
"startTime": 0,
"duration": 5,
"loop": true
}
]
}
複数の効果を組み合わせる:
{
"animations": [
{
"type": "expression",
"target": "rotation",
"expression": "(localTime * 2 * Math.PI / duration) + Math.sin(localTime * 4) * 0.1",
"loop": true
},
{
"type": "expression",
"target": "scaleX",
"expression": "1 + Math.sin(localTime * 5) * 0.2",
"loop": true
}
]
}
設定可能なパラメータを持つ組み込みのアニメーションパターン。
{
"animations": [
{
"type": "procedural",
"proceduralType": "wiggle",
"target": "rotation",
"enabled": true,
"frequency": 2,
"amplitude": 0.1,
"loop": true
}
]
}
特定の間隔で値を変えるステップベースのアニメーション。
| プロパティ | タイプ | 必須 | 例 | 値の範囲 | 説明 |
|---|---|---|---|---|---|
| values | array | true | - | - | ステップを通過する値の配列。 |
| stepDuration | number | true | - | - | 各ステップの持続時間(秒単位)。 |
| loop | boolean | false | - | - | シーケンスをループするかどうか。 |
異なるサイズでテキストをサイクルする:
{
"animations": [
{
"type": "sequence",
"target": "fontSize",
"enabled": true,
"values": [24, 32, 40, 32, 24],
"stepDuration": 0.5,
"loop": true
}
]
}
ベジェ曲線パスに沿って要素をアニメーションさせる。
| プロパティ | タイプ | 必須 | 例 | 値の範囲 | 説明 |
|---|---|---|---|---|---|
| path | string | array | true | - | - | SVGパスデータ(d属性)またはパスポイントの配列。 |
| autoRotate | boolean | false | - | - | パスの接線に従って要素を自動的に回転させるかどうか。 |
| duration | number | true | - | - | 全パスを完了するのにかかる時間。 |
円運動:
{
"animations": [
{
"type": "path",
"target": "position",
"enabled": true,
"path": "M 100,100 a 200,200 0 1,1 0,1 Z",
"autoRotate": true,
"duration": 4,
"loop": true
}
]
}
target プロパティは、ドット表記を使用してネストされたプロパティを指定します:
"x", "y", "rotation""scale.x", "position.y""colors[0]", "points[2].x"{
"target": "x" // 要素のx位置
"target": "scaleX" // 水平スケール
"target": "alpha" // 不透明度
"target": "fill.color" // 塗りつぶし色(塗りつぶしがオブジェクトの場合)
"target": "points[0].x" // 最初の点のx座標
}複数のアニメーションが同じプロパティを対象とする場合の組み合わせ方法を制御します:
{
"blendMode": "replace",
"blendWeight": 1.0
}プロパティ値を完全に置き換えます。
{
"blendMode": "add",
"blendWeight": 0.5
}既存の値に加算します(重み付け)。オフセットの蓄積に便利です。
{
"blendMode": "multiply",
"blendWeight": 1.0
}既存の値を乗算します。スケーリング効果に便利です。
異なるアニメーションタイプを組み合わせる:
{
"id": "animated-element",
"type": "Shape",
"animations": [
{
"type": "expression",
"target": "x",
"expression": "width / 2 + Math.sin(localTime * 2) * 300",
"blendMode": "replace",
"loop": true
},
{
"type": "procedural",
"proceduralType": "wiggle",
"target": "rotation",
"frequency": 3,
"amplitude": 0.2,
"blendMode": "add",
"blendWeight": 0.5
},
{
"type": "sequence",
"target": "alpha",
"values": [1, 0.8, 1],
"stepDuration": 0.3,
"loop": true,
"blendMode": "multiply"
}
],
"keyframes": [
{
"id": "kf-1",
"time": 0,
"stateObj": { "scaleX": 1 }
},
{
"id": "kf-2",
"time": 2,
"stateObj": { "scaleX": 1.5 }
}
]
}
この例では:
startTime および duration は要素の start 時間に対して相対的ですlocalTime は要素が始まるときに0から始まりますduration 境界を尊重しますenabled: truetarget プロパティが存在するstartTime が要素の持続時間内にある{
"type": "expression",
"target": "x",
"expression": "value + (targetX - value) * 0.1"
}{
"type": "expression",
"target": "scaleY",
"expression": "1 + Math.exp(-localTime * 3) * Math.cos(localTime * 8) * 0.5"
}{
"type": "procedural",
"proceduralType": "wiggle",
"target": "x",
"frequency": 10,
"amplitude": 5
}{
"type": "expression",
"target": "alpha",
"expression": "Math.max(0, Math.min(1, (localTime - index * 0.1) * 2))"
}