ट्यूटोरियल: Morphing और अनुक्रमित एनिमेशन
Mesmerizing आकार परिवर्तन और choreographed बहु तत्व एनिमेशन बनाएँ।.
** समय:* 20 मिनट ** कठिनाई:* उन्नत
आप क्या बना सकते हैं
एक गतिशील अनुक्रम जहां आकार एक दूसरे में रूपांतरित होता है जबकि पाठ में समय के साथ प्रकट होता है।.
सुविधाओं को कवर
- Shape morphing - विभिन्न आकारों के बीच चिकनी संक्रमण
- *Staggered एनिमेशन - एकाधिक तत्वों के लिए अनुक्रमित समय
- ** रंग परिवर्तन* - एनिमेटेड ढाल रंग परिवर्तन
- *मास्क प्रकट करता है - सिनेमाई पोंछे और आईरिस प्रभाव
- *Choreographed अनुक्रम - सटीक रूप से समयबद्ध बहु-तत्व नृत्य
भाग 1: आकृति Morphing
चरण 1: स्रोत आकार बनाएं
- केंद्र में एक सर्कल बनाएं:
- त्रिज्या: 80
- रंग:
#3b82f6(नीला) - Position: (400, 300)
const circle = app.create('circle', {
x: 400, y: 300,
radius: 80,
color: '#3b82f6'
});
चरण 2: लक्ष्य आकार बनाएँ
- एक तारा बनाएँ (मॉर्फ़ लक्ष्य होगा):
- अंक: 5
- त्रिज्या: 100
- रंग:
#f59e0b(Amber) - Position: (400, 300)
const star = app.create('star', {
x: 400, y: 300,
points: 5,
radius1: 100,
radius2: 40,
color: '#f59e0b'
});
Step 3: Add Morph रिलेशन
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: चेन एकाधिक Morphs
एक आकृति अनुक्रम बनाएँ: सर्कल → स्टार → त्रिभुज → सर्कल
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
});
भाग 2: Staggered Text Reveal
चरण 5: पत्र कोलाज बनाएँ
const collage = app.letterCollage.create('TRANSFORM', {
style: 'gradient',
gradientPalette: 'cyberpunk',
gradientDirection: 'horizontal',
fontSize: 64,
x: 400, y: 500
});
Step 6: Staggered Animation लागू करें
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: मास्क रेवल
Step 7: Add Dramatic Reveal
एक आईरिस प्रभाव के साथ आकृति आकार का खुलासा करें:
// 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: पूर्ण choreography
पूर्ण एनिमेशन स्क्रिप्ट
// === 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 सेकंड | पूर्ण लूप चक्र |
| गुणवत्ता | उच्च | रंग संक्रमण संरक्षण |
प्रो टिप्स
** ओवरलैप टाइमिंग* - निर्बाध प्रवाह के लिए पिछले सिरों से पहले अगले एनीमेशन 0.1-0.2s शुरू करें।.
** जब रंगों के बीच संक्रमण होता है तो आकृतियां सबसे अच्छी लगती हैं।.
** प्रभाव के लिए केंद्र अनुक्रम* -
centerstagger पैटर्न पाठ के बीच पर ध्यान आकर्षित करता है।.
*मैच सामग्री को प्रकट करता है - परिपत्र आकार के लिए
irisका उपयोग करें, पाठ के लिएwipeLeft।.
विविधता
डेटा विजुअलाइजेशन Morph
// 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 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' }
]);
});
अगला कदम
- [Physics एनिमेशन] (/tutorials/physics-animation) - बाउंस और लोचदार प्रभाव
- Map Animations - भौगोलिक डेटा कहानी कहने
- मस्किंग सिस्टम - उन्नत खुलासा तकनीक