SketchBook

止まってた心電図

var xoff, yoff;

var time;

var colors = [];

function setup() {
createCanvas(windowWidth,
windowHeight);
background(84, 195, 241,20);

noFill();

colors.push(color(57, 168, 105, 50))
 colors.push(color(243,225,0, 150));
colors.push(color(255, 246, 127, 220));
colors.push(color(255, 241, 0, 128));
colors.push(color(255, 241, 127, 200));
colors.push(color(215, 0, 15, 100));

xoff = 0.0;
yoff = 0.0;

time = 0;
}createCanvas(windowWidth,
windowHeight);
background(234, 234, 234);

function draw() {

var c = getColor(time);
stroke(c);

beginShape();
 var xoff = 200;
for (var x = 0; x <= windowWidth; x += 50) {
var y = map(noise(xoff, yoff), 0, 5, 0, windowHeight);
curveVertex(x, y);
xoff += 0.03;
}
yoff += 100;
curveVertex(windowWidth,
windowHeight);
endShape();

time = time + 0.001;

if (time > 1.0) {
time = 0;
} noStroke();
fill(frameCount, 128 + frameCount, 128, 5);
triangle(150, 80, frameCount);
}

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