Selamlar kar yağdırma kodları işinizi görebilir

<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Kar Yağdırma Efekti</title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background: #000;
        }
        canvas {
            display: block;
        }
    </style>
</head>
<body>
    <canvas id="snowCanvas"></canvas>
    <script src="snow.js"></script>
</body>
</html>
;


const canvas = document.getElementById('snowCanvas');
const ctx = canvas.getContext('2d');

canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

const numFlakes = 100;
const flakes = [];

function createFlake() {
    return {
        x: Math.random() * canvas.width,
        y: Math.random() * canvas.height,
        radius: Math.random() * 4 + 1,
        speed: Math.random() * 1 + 0.5
    };
}

for (let i = 0; i < numFlakes; i++) {
    flakes.push(createFlake());
}

function drawFlakes() {
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    ctx.fillStyle = 'white';
    ctx.beginPath();
    flakes.forEach(flake => {
        ctx.moveTo(flake.x, flake.y);
        ctx.arc(flake.x, flake.y, flake.radius, 0, Math.PI * 2);
    });
    ctx.fill();
}

function updateFlakes() {
    flakes.forEach(flake => {
        flake.y += flake.speed;
        if (flake.y > canvas.height) {
            flake.y = 0;
        }
    });
}

function animate() {
    drawFlakes();
    updateFlakes();
    requestAnimationFrame(animate);
}

animate();
PYTHON KODU:

import pygame
import random

# Başlat
pygame.init()

# Ekran boyutu
width, height = 800, 600
screen = pygame.display.set_mode((width, height))

# Kar parçacıkları oluştur
num_flakes = 100
flakes = []

for _ in range(num_flakes):
    x = random.randint(0, width)
    y = random.randint(0, height)
    speed = random.randint(1, 3)
    flakes.append([x, y, speed])

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
    
    screen.fill((0, 0, 0))
    
    for flake in flakes:
        flake[1] += flake[2]
        if flake[1] > height:
            flake[1] = random.randint(-20, -1)
        pygame.draw.circle(screen, (255, 255, 255), (flake[0], flake[1]), 3)
    
    pygame.display.flip()
    pygame.time.delay(10)

pygame.quit()
JAVA KODU:

int numFlakes = 100;
float[][] flakes = new float[numFlakes][3];

void setup() {
  size(800, 600);
  for (int i = 0; i < numFlakes; i++) {
    flakes[i][0] = random(width);
    flakes[i][1] = random(height);
    flakes[i][2] = random(1, 3);
  }
}

void draw() {
  background(0);
  for (int i = 0; i < numFlakes; i++) {
    flakes[i][1] += flakes[i][2];
    if (flakes[i][1] > height) {
      flakes[i][1] = random(-20, -1);
    }
    ellipse(flakes[i][0], flakes[i][1], 5, 5);
  }
}
C# KODU:

using System;
using System.Drawing;
using System.Windows.Forms;

public class SnowForm : Form
{
    private Timer timer;
    private Random rand;
    private int numFlakes = 100;
    private PointF[] flakes;
    private float[] speeds;

    public SnowForm()
    {
        this.Width = 800;
        this.Height = 600;
        this.DoubleBuffered = true;
        
        rand = new Random();
        flakes = new PointF[numFlakes];
        speeds = new float[numFlakes];
        
        for (int i = 0; i < numFlakes; i++)
        {
            flakes[i] = new PointF(rand.Next(Width), rand.Next(Height));
            speeds[i] = (float)(rand.NextDouble() * 3 + 1);
        }
        
        timer = new Timer();
        timer.Interval = 20;
        timer.Tick += new EventHandler(OnTick);
        timer.Start();
    }

    private void OnTick(object sender, EventArgs e)
    {
        for (int i = 0; i < numFlakes; i++)
        {
            flakes[i].Y += speeds[i];
            if (flakes[i].Y > Height)
            {
                flakes[i].Y = -10;
                flakes[i].X = rand.Next(Width);
            }
        }
        this.Invalidate();
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        Graphics g = e.Graphics;
        g.Clear(Color.Black);
        
        foreach (var flake in flakes)
        {
            g.FillEllipse(Brushes.White, flake.X, flake.Y, 5, 5);
        }
    }
    
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new SnowForm());
    }
}