SketchBook

ふぁすとぶれいん

var A = 1.8;
var B = 2.1;
var C = 1.8;
var D = -2.9;

var time;
var colors = [];

function setup() {
createCanvas(windowWidth,
windowHeight);
background(0, 0, 0);
noStroke();

colors.push(color(50, 180, 250, 128));
colors.push(color(100, 250, 250, 120));
colors.push(color(225, 360, 225, 110));
colors.push(color(455, 160, 135, 10));
colors.push(color(200, 250, 70, 10));
colors.push(color(35, 25, 515, 315));
colors.push(color(265, 765, 893, 315));

time = 0;
}

function draw() {
translate(windowWidth / 2, windowHeight / 2);

var x = random(-3, 10);
var y = random(-7, 3);

for (var i = 0; i < 2000; i++) {
var xx = sin(A * y) - cos(B * x);
var yy = sin(C * x) - cos(D * y);
var c = getColor(time);
fill(c);
ellipse(xx * width * 0.25, yy * height * 0.25, 1);
x = xx;
y = yy;
}

time = time + 0.01;

if (time > 1.0) {
time = 0.0;
C += 0.1;
}
}

function getColor(t) {
var p = t * (colors.length - 1);
var from = floor(p);
return lerpColor(colors[from], colors[from + 1], p - from);
}