سنو فال کا ایفکٹ کیسے لگائیں تمام بلاگر پر ؟
یہ بہت آسان طریقہ ہے آپ نے مندرجہ ذیل ایچ ٹی ایم ایل کوڈ کافی کرنا ہے اور اپنے بلاگر کے ویجٹ میں پیسٹ کرنا ہے جب بھی آپ بلاگ اوپن کروگے تو سارے بلاگ پر سنو فال ہوگی جو کہ پڑھنے والے کو آپکا بلاگ بہت ہی مزیدار لگے گا اور دیر تک رکےگا جس سے آپکی پوسٹ وائرل ہونے کا بہت چانس ہوسکتا ہے۔
<!-- Snowfall and Accumulation Effect --><canvas id="snowCanvas" style="position:fixed; top:0; left:0; pointer-events:none; z-index:9999;"></canvas>
<script>
(function() {
const canvas = document.getElementById('snowCanvas');
const ctx = canvas.getContext('2d');
let width, height, flakes = [];
let groundSnow = []; // Barf jama karne ke liye array
function init() {
width = window.innerWidth;
height = window.innerHeight;
canvas.width = width;
canvas.height = height;
groundSnow = new Array(Math.ceil(width / 5)).fill(0);
}
window.onresize = init;
init();
function createFlake() {
return {
x: Math.random() * width,
y: -10,
size: Math.random() * 3 + 2,
speed: Math.random() * 1 + 0.5,
velX: Math.random() * 1 - 0.5
};
}
for (let i = 0; i < 150; i++) {
flakes.push(createFlake());
}
function draw() {
ctx.clearRect(0, 0, width, height);
ctx.fillStyle = "white";
ctx.beginPath();
flakes.forEach((f, i) => {
f.y += f.speed;
f.x += f.velX;
// Niche barf jama hone ka logic
let groundIdx = Math.floor(f.x / 5);
if (f.y >= height - groundSnow[groundIdx]) {
if (groundSnow[groundIdx] < 50) { // Max 50px tak jama hogi
groundSnow[groundIdx] += 0.5;
}
flakes[i] = createFlake();
}
ctx.moveTo(f.x, f.y);
ctx.arc(f.x, f.y, f.size, 0, Math.PI * 2);
});
// Jama hui barf ko draw karna
for (let i = 0; i < groundSnow.length; i++) {
ctx.rect(i * 5, height - groundSnow[i], 5, groundSnow[i]);
}
ctx.fill();
requestAnimationFrame(draw);
}
draw();
})();
</script>
