雪のようにヒラヒラと降るSUBLIINE
let snowflakes = [];
let svgImage;
let maxSnowflakes = 30;
function preload() {
svgImage = loadImage("subline_logo.svg");
}
function setup() {
createCanvas(windowWidth, windowHeight);
noStroke();
frameRate(30);
}
function draw() {
background(255);
if (snowflakes.length < maxSnowflakes && random(1) < 0.1) {
let x = random(width);
let y = random(-100, -10);
let size = random(30, 80);
let speed = random(1, 3);
snowflakes.push(new Snowflake(x, y, size, speed));
}
for (let i = snowflakes.length - 1; i >= 0; i--) {
let flake = snowflakes[i];
flake.update();
flake.display();
if (flake.y > height + flake.size) {
snowflakes.splice(i, 1);
}
}
}
class Snowflake {
constructor(x, y, size, speed) {
this.x = x;
this.y = y;
this.size = size;
this.speed = speed;
this.opacity = random(50, 255);
this.wind = random(-1, 1);
}
update() {
this.y += random(this.speed - 1, this.speed + 1);
this.x += this.wind;
if (this.y > height + this.size) {
this.y = -this.size;
this.x = random(width);
}
}
display() {
tint(255, this.opacity);
image(svgImage, this.x, this.y, this.size, this.size);
noTint();
}
}