教程: 曲解和顺序动画
创建中化形状变换和编舞多元素动画.
时间: 20分钟 困难: 高级
你会创造什么
一个动态序列,其中形状会相互变形,而文本则会以错开的时间揭示.
覆盖的特性
- 形状形态 — 不同形状之间的平稳过渡
- 交错动画 — 多个元素的顺序时间
- 颜色过渡 — 动画梯度颜色变化
- 风险揭示——电影擦拭和虹膜效应
- ** 精准的多元素舞蹈
第1部分:形状粉碎
步骤1: 创建源形状
- 中心创建圆 :
- 半径: 80
- 颜色:
#3b82f6(蓝色) - Position: (400, 300)
const circle = app.create('circle', {
x: 400, y: 300,
radius: 80,
color: '#3b82f6'
});
步骤2: 创建目标形状
- 创建恒星( 将成为形态目标) :
- 要点:5
- 半径: 100
- 颜色:
#f59e0b(琥珀) - Position: (400, 300)
const star = app.create('star', {
x: 400, y: 300,
points: 5,
radius1: 100,
radius2: 40,
color: '#f59e0b'
});
第3步: 增加摩尔法关系
morphs_to关系创建平滑形状过渡:
app.addRelation(circle.data.id, star.data.id, 'morphs_to', {
duration: 1.5,
easing: 'easeInOut',
morphColor: true, // Also transition colors
morphSize: true // Also transition size
});
步骤4:链式多面体
创建形态序列:圆 星 三角 圆
const shapes = [];
// Circle
shapes.push(app.create('circle', {
x: 400, y: 300, radius: 80, color: '#3b82f6'
}));
// Star
shapes.push(app.create('star', {
x: 400, y: 300, points: 5, radius1: 100, radius2: 40,
color: '#f59e0b', opacity: 0
}));
// Triangle
shapes.push(app.create('triangle', {
x: 400, y: 300, radius: 90,
color: '#10b981', opacity: 0
}));
// Hexagon (back to geometric)
shapes.push(app.create('polygon', {
x: 400, y: 300, sides: 6, radius: 85,
color: '#8b5cf6', opacity: 0
}));
// Chain morphs with delays
for (let i = 0; i < shapes.length - 1; i++) {
app.addRelation(shapes[i].data.id, shapes[i + 1].data.id, 'morphs_to', {
duration: 1.2,
delay: i * 1.5, // Stagger start times
easing: 'easeInOut',
morphColor: true
});
}
// Loop back to first shape
app.addRelation(shapes[shapes.length - 1].data.id, shapes[0].data.id, 'morphs_to', {
duration: 1.2,
delay: (shapes.length - 1) * 1.5,
easing: 'easeInOut',
morphColor: true
});
第二部分:错开的文字启示录
步骤 5: 创建信件拼接
const collage = app.letterCollage.create('TRANSFORM', {
style: 'gradient',
gradientPalette: 'cyberpunk',
gradientDirection: 'horizontal',
fontSize: 64,
x: 400, y: 500
});
步骤6:应用错位动画
app.letterCollage.applyStaggeredAnimation(collage.collageId, {
effect: 'fadeSlideUp',
staggerDelay: 0.06, // 60ms between letters
duration: 0.5,
sequence: 'center', // Start from center, expand outward
easing: 'easeOut'
});
序列图案
| 图案 | 效果 |
|---|---|
linear |
从左到右 |
reverse |
右对左 |
center |
向外中转 |
random |
随机顺序 |
wave |
正波计时 |
fibonacci |
自然节奏 |
第3部分:面具启示录
步骤7:增加戏剧启示录
揭示具有虹膜效应的形态形状:
// Apply animated mask to the shape container
app.applyAnimatedMask(shapes[0], 'iris', {
startTime: 0,
duration: 0.8,
easing: 'easeOut'
});
步骤8:擦拭文字启示录
// Reveal text with horizontal wipe
app.applyAnimatedMask(collage.group, 'wipeLeft', {
startTime: 0.5, // Start after shape reveals
duration: 0.6,
easing: 'easeInOut'
});
可用遮罩预设
| 预设 | 效果 |
|---|---|
iris |
圆从中心展开 |
wipeLeft |
从左侧水平显示 |
wipeUp |
从底部垂直显示 |
star |
恒星形状扩展 |
heart |
心脏形状扩张 |
curtainHorizontal |
从中间打开 |
diagonalWipe |
愤怒的揭露 |
第4部分: 完整的配音
完整动画脚本
// === SETUP ===
app.setCanvasSize({ width: 800, height: 600 });
app.setBackgroundColor('#0f172a');
// === MORPHING SHAPES ===
const shapeColors = ['#3b82f6', '#f59e0b', '#10b981', '#8b5cf6'];
const shapeTypes = ['circle', 'star', 'triangle', 'polygon'];
const mainShape = app.create('circle', {
x: 400, y: 250,
radius: 80,
color: shapeColors[0]
});
// Keyframe the shape through color transitions
app.addAnimation(mainShape.data.id, [
{ time: 0, properties: { fillColor: '#3b82f6', scale: 1 } },
{ time: 1.5, properties: { fillColor: '#f59e0b', scale: 1.2 }, easing: 'easeInOut' },
{ time: 3, properties: { fillColor: '#10b981', scale: 0.9 }, easing: 'easeInOut' },
{ time: 4.5, properties: { fillColor: '#8b5cf6', scale: 1.1 }, easing: 'easeInOut' },
{ time: 6, properties: { fillColor: '#3b82f6', scale: 1 }, easing: 'easeInOut' }
]);
// Add rotation for visual interest
app.addAnimation(mainShape.data.id, [
{ time: 0, properties: { rotation: 0 } },
{ time: 6, properties: { rotation: 360 }, easing: 'linear' }
]);
// === IRIS REVEAL FOR SHAPE ===
app.applyAnimatedMask(mainShape, 'iris', {
startTime: 0,
duration: 0.6,
easing: 'easeOut'
});
// === STAGGERED TEXT ===
const title = app.letterCollage.create('TRANSFORM', {
style: 'tile',
palette: 'neon',
fontSize: 56,
x: 400, y: 480
});
app.letterCollage.applyStaggeredAnimation(title.collageId, {
effect: 'popIn',
staggerDelay: 0.05,
duration: 0.4,
sequence: 'center',
easing: 'elastic'
});
// === ORBITING ACCENTS ===
const orbitColors = ['#f472b6', '#34d399', '#fbbf24'];
orbitColors.forEach((color, i) => {
const dot = app.create('circle', {
x: 400, y: 250,
radius: 6,
color: color
});
app.addRelation(dot.data.id, mainShape.data.id, 'orbits', {
radius: 120 + i * 25,
speed: 0.4 - i * 0.1,
phase: i * (Math.PI * 2 / 3)
});
// Fade in the orbiting dots
app.addAnimation(dot.data.id, [
{ time: 0.8 + i * 0.2, properties: { opacity: 0, scale: 0 } },
{ time: 1.2 + i * 0.2, properties: { opacity: 1, scale: 1 }, easing: 'elastic' }
]);
});
// === CAMERA MOVEMENT ===
app.addRelation('camera', null, 'camera_animates', {
duration: 6,
loop: true,
keyframes: [
{ time: 0, zoom: 1, center: [400, 300] },
{ time: 1.5, zoom: 1.15, center: [400, 280], easing: 'easeOut' },
{ time: 3, zoom: 1.05, center: [400, 320], easing: 'easeInOut' },
{ time: 4.5, zoom: 1.1, center: [400, 300], easing: 'easeInOut' },
{ time: 6, zoom: 1, center: [400, 300], easing: 'easeOut' }
]
});
// === PLAY ===
app.playKeyframeTimeline(6, true);
导出设置
最佳效果的形态动画:
| 设置 | 数值 | 原因 |
|---|---|---|
| 格式 | WebM 密码 | 梯度的最佳质量 |
| 帧率 | 60 fps | 较平滑的形态 |
| 会期 | 6秒钟 | 全循环周期 |
| 质量 | 高级 | 保存颜色转换 |
Pro 提示
重叠计时 — 在前端前开始下一部动画0.1-0.2s进行无缝流.
使用互补颜色 - 当颜色之间转换时,形状形态看起来最好,这些颜色一起工作.
撞击中心顺序 -
center交错模式提请人们注意文本的中间.
与内容相匹配 - 循环形状使用
iris,文本使用wipeLeft.
变化
数据可视化
// Bar chart to pie chart transition
const bars = createBarChart(data);
const pie = createPieChart(data);
app.addRelation(bars.data.id, pie.data.id, 'morphs_to', {
duration: 2,
easing: 'easeInOut'
});
Logo 动画序列
// Logo parts appear in sequence
const logoParts = [shape1, shape2, shape3, text];
logoParts.forEach((part, i) => {
app.addAnimation(part.data.id, [
{ time: i * 0.3, properties: { opacity: 0, scale: 0.5 } },
{ time: i * 0.3 + 0.4, properties: { opacity: 1, scale: 1 }, easing: 'elastic' }
]);
});
下一步
- 物理动画——弹跳和弹性效应
- 地图动画——地理数据故事介绍
- Masking System——高级揭示技术