技術課題
var A = 1.4;
var B = 2.5;
var C = 1.4;
var D = -2.3;
var time;
var colors = [];
function setup() {
createCanvas(windowWidth,
windowHeight);
background(238, 238, 238);
noStroke();
colors.push(color(160, 190, 270, 129));
colors.push(color(130, 198, 260, 200));
colors.push(color(250, 180, 240, 20));
colors.push(color(270, 145, 135, 50));
colors.push(color(245, 35, 87, 100));
colors.push(color(85, 35, 67, 8));
time = 0;
}
function draw() {
translate(windowWidth / 2, windowHeight / 2);
var x = random(-3, 3);
var y = random(-3, 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);
}