心の波
var xoff, yoff;
var time;
var colors = [];
function setup() {
createCanvas(windowWidth,
windowHeight);
background(97, 193, 190);
noFill();
colors.push(color(108, 155, 210, 150))
colors.push(color(0, 141, 203, 128));
colors.push(color(238, 135, 180, 128));
colors.push(color(239, 133, 140, 128));
colors.push(color(186, 121, 177, 128));
colors.push(color(255, 246, 127, 128));
xoff = 0.1;
yoff = 0.2;
time = 0;
}
function draw() {
var c = getColor(time);
stroke(c);
beginShape();
var xoff = 1;
for (var x = 0; x <= windowWidth; x += 5) {
var y = map(noise(xoff, yoff), 1, -1, 0, windowHeight);
curveVertex(x, y);
xoff += 0.03;
}
yoff += 0.002;
curveVertex(windowWidth,
windowHeight);
endShape();
time = time + 0.001;
if (time > 1.0) {
time = 0;
}
}
function getColor(t) {
var p = t * (colors.length -1);
var from = floor(p);
return lerpColor(colors[from], colors[from + 1], p - from);
}