xxxxxxxxxx
function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
}
function draw() {
blendMode(BLEND);
background(0, 50);
drawSnow(1);
drawTree();
drawSnow(2);
}
function drawTree() {
push();
translate(width / 2 + (mouseX - width / 2) * -0.1, height * 0.05 + (mouseY - height / 2) * 0.1);
fill(0, 150, 0);
for(var i=0; i<4; i++)
{
translate(0, height * 0.1);
scale(1.3);
var wh = height * 0.15;
triangle(0, 0, -wh, wh, wh, wh);
}
pop();
}
function drawSnow(s) {
randomSeed(s);
fill(200);
for(var i=0; i<100; i++) {
var r = random(1, 2) * height * 0.005 * s;
var z = r * 0.1;
var xt = (frameCount * -0.2 + sin(frameCount * random(0.04, 0.06))) * z;
var yt = frameCount * z * 0.5;
var x = modulo(random(width) - mouseX * (z - 1) * 0.1 + xt, width);
var y = modulo(random(height) - mouseY * (z - 1) * -0.1 + yt, height);
ellipse(x, y, r, r);
}
}
function modulo(a, b) {
return a - floor(a / b) * b;
}