The content on this website, including videos and code examples, is for educational purposes only. All demonstrations and designs are fictional and created to illustrate coding techniques. Any resemblance to existing websites or brands is purely coincidental.
The creators and administrators of this website do not claim ownership or affiliation with any existing websites or companies. Users are encouraged to use the information responsibly for learning purposes. Liability for any misuse of the content provided is not accepted.
Below is the html code for this video.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Happy Ganesh Chaturthi</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p>Aum Gam Ganapataye Namah</p>
<div class="chakra chakra-biggest"></div>
<div class="chakra chakra-bigger"></div>
<div class="chakra chakra-big"></div>
<div class="img-lord-ganesh">
<img src="./lord ganpati.png" alt="front image">
<img src="./lord ganpati.png" alt="soft shadow image" class="shadow-soft">
</div>
<canvas></canvas>
<script src="index.js"></script>
</body>
</html>
Below is the css code for this video.
style.css
@import url('https://fonts.googleapis.com/css2?family=Aref+Ruqaa+Ink&display=swap');
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
width: 100%;
background-color: #ffff00;
background-image: linear-gradient(to right bottom, #f5f7f6bf, #5ca0f2bf);
overflow: hidden;
}
p {
position: absolute;
top: 1.25%;
transform: translateY(-1.25%);
width: 100%;
color: #ffef00;
text-align: center;
font-size: 3rem;
font-family: 'Aref Ruqaa Ink', serif;
text-shadow: -0.01em -0.01em 0.01em #ca2325;
animation: textAnim 2s ease-in-out 0.5s alternate infinite;
}
@keyframes textAnim {
to {
transform: translateY(-0.025em) translateX(0.05em);
text-shadow: 0 0.01em #ffef00, 0 0.02em #ffef00, 0 0.03em #ffef00, -0.01em 0.01em #ca2325, -0.02em 0.02em #ca2325,
-0.03em 0.03em #ca2325, -0.04em 0.04em #ca2325, -0.01em -0.01em 0.03em #ff0000, -0.02em -0.02em 0.03em #ff0000,
-0.03em -0.03em 0.03em #ff0000;
}
}
.chakra {
position: absolute;
top: 50%;
left: 50%;
background-image: url(./chakra.png);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
z-index: -1;
}
.chakra-biggest {
height: 75vh;
width: 75vh;
opacity: 0.25;
animation: chakraAnim 5s linear infinite;
}
.chakra-bigger {
height: 68.75vh;
width: 68.75vh;
opacity: 0.5;
animation: chakraAnim 7.5s linear reverse infinite;
}
.chakra-big {
height: 62.5vh;
width: 62.5vh;
opacity: 0.75;
animation: chakraAnim 10s linear infinite;
}
@keyframes chakraAnim {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
}
}
.img-lord-ganesh {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
height: 62.5vh;
width: 62.5vh;
}
.img-lord-ganesh img {
height: 100%;
width: 100%;
}
.img-lord-ganesh img.shadow-soft {
position: absolute;
left: 0;
filter: blur(10px);
z-index: -1;
}
canvas {
position: absolute;
z-index: -9;
}
Below is the javascript code for this video.
index.js
const canvas = document.querySelector("canvas");
canvas.height = window.innerHeight;
canvas.width = window.innerWidth;
const ctx = canvas.getContext("2d");
const totalFlowers = 108;
const flowerArray = [];
const flowerImage = new Image();
flowerImage.src = 'https://gallery.yopriceville.com/var/resizes/Free-Clipart-Pictures/Flowers-PNG/Hibiscus_Flower_PNG_Clipart.png?m=1581669497';
flowerImage.addEventListener("load", () => {
for (let i = 0; i < totalFlowers; i++) { flowerArray.push(new Flower()); }
render();
});
function render() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
flowerArray.forEach(flower => flower.animate());
window.requestAnimationFrame(render);
}
window.addEventListener("resize", () => {
canvas.height = window.innerHeight;
canvas.width = window.innerWidth;
});
class Flower {
constructor() {
this.x = Math.random() * canvas.width;
this.y = (Math.random() * canvas.height * 2) - canvas.height;
this.w = 25 + Math.random() * 15;
this.h = 20 + Math.random() * 10;
this.opacity = this.w / 40;
this.flip = Math.random();
this.xSpeed = 1.5 + Math.random() * 2;
this.ySpeed = 1 + Math.random();
this.flipSpeed = Math.random() * 0.03;
}
draw() {
if (this.y > canvas.height || this.x > canvas.width) {
this.x = -flowerImage.width;
this.y = (Math.random() * canvas.height * 2) - canvas.height;
this.xSpeed = 1.5 + Math.random() * 2;
this.ySpeed = 1 + Math.random();
this.flip = Math.random();
}
ctx.globalAlpha = this.opacity;
ctx.drawImage(flowerImage, this.x, this.y, this.w * (0.6 + (Math.abs(Math.cos(this.flip)) / 3)), this.h * (0.8 + (Math.abs(Math.sin(this.flip)) / 5)));
}
animate() {
this.x += this.xSpeed;
this.y += this.ySpeed;
this.flip += this.flipSpeed;
this.draw();
}
}
Thanks for visiting