VND Openxmlformats-Officedocument Wordprocessingml Document&rendition 1-9
VND Openxmlformats-Officedocument Wordprocessingml Document&rendition 1-9
<div class="content">
<h1>Multimedia Programs Developed Using FLASH</h1>
<h2>5. Motion Tweening Operation</h2>
<div id="animationArea">
<div id="tweenObject" class="tweenObject"></div>
</div>
<button onclick="startTween()">Start Motion Tweening</button>
</div>
<script>
function startTween() {
const tweenObject = document.getElementById('tweenObject');
const duration = 2000; // Duration in milliseconds
const startPos = 0; // Starting position (left)
const endPos = 550; // Ending position (right)
const startTime = performance.now();
function animate(currentTime) {
const elapsedTime = currentTime - startTime;
const progress = Math.min(elapsedTime / duration, 1); // Clamp
progress to 0-1
const currentPos = startPos + (endPos - startPos) * progress;
requestAnimationFrame(animate);
}
</script>
</body>
</html>
OUTPUT:
EXPERIMENT-6:
SOURCE CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>24 Spokes Wheel</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
canvas {
border: 1px solid #000;
}
</style>
</head>
<body>
<canvas id="wheelCanvas" width="550" height="500"></canvas>
<script>
const canvas = document.getElementById('wheelCanvas');
const ctx = canvas.getContext('2d');
const x = canvas.width / 2;
const y = canvas.height / 2;
const radius = 200;
const numSpokes = 24;
function drawWheel() {
// Clear the canvas
ctx.clearRect(0, 0, canvas.width, canvas.height);
drawWheel();
</script>
</body>
</html>
OUTPUT:
EXPERIMENT-7:
SOURCE CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Shape Tweening: Circle to Triangle</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
canvas {
border: 1px solid #000;
}
</style>
</head>
<body>
<canvas id="tweenCanvas" width="400" height="400"></canvas>
<script>
const canvas = document.getElementById('tweenCanvas');
const ctx = canvas.getContext('2d');
let frame = 0;
const totalFrames = 60; // Total frames for the animation
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height); // Clear the canvas
const t = frame / totalFrames; // Normalize frame to a value between 0
and 1
const x = canvas.width / 2;
const y = canvas.height / 2;
const size = 100; // Size of the shapes
ctx.beginPath();
if (t < 0.5) {
// Draw a circle for the first half of the animation
const radius = size * (1 - t * 2); // Decrease radius
ctx.arc(x, y, radius, 0, Math.PI * 2);
} else {
// Draw a triangle for the second half of the animation
const progress = t * 2 - 1; // Normalize for triangle
ctx.moveTo(x, y - size); // Top vertex
ctx.lineTo(x - size * progress, y + size); // Bottom left vertex
ctx.lineTo(x + size * progress, y + size); // Bottom right vertex
ctx.closePath();
}
ctx.fillStyle = 'green';
ctx.fill();
frame++;
if (frame <= totalFrames) {
requestAnimationFrame(draw); // Continue the animation
}
}
<script>
const ecard = document.getElementById('ecard');
EXPERIMENT-9:
SOURCE CODE:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Growing Moon Animation</title>
<style>
body {
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(to bottom, #003366, #66ccff); /* Blue sky
gradient */
overflow: hidden;
}
.moon {
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #fff;
position: relative;
animation: grow 3s infinite alternate;
}
.moon::before {
content: '';
position: absolute;
top: 0;
left: 25%;
width: 100%;
height: 100%;
background-color: #003366; /* Shadow for crescent effect */
border-radius: 50%;
}
@keyframes grow {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.2); } /* Maximum size */
}
.star {
position: absolute;
background-color: white;
border-radius: 50%;
opacity: 0.8;
}
</style>
</head>
<body>
<div class="moon"></div>
<script>
const numStars = 100;
const body = document.body;
// Create stars
for (let i = 0; i < numStars; i++) {
const star = document.createElement('div');
star.classList.add('star');
const size = Math.random() * 3 + 2; // Size between 2 and 5
star.style.width = `${size}px`;
star.style.height = `${size}px`;
star.style.top = `${Math.random() * 100}vh`;
star.style.left = `${Math.random() * 100}vw`;
body.appendChild(star);
}
</script>
</body>
</html>
OUTPUT: