SketchBook

JOLLY

var points = [];
var posX, posY;
var speedX;
var yoff;

var colors = [];
var time;

function setup() {
createCanvas(windowWidth,
windowHeight);
angleMode(DEGREES);
background(234, 234, 234);

 time =0;

posX = 0;
posY = windowHeight / 2;
speedX = 0.5;
yoff = 0.5;

colors.push(color(108, 155, 210,220));
colors.push(color(108, 155, 210,128));
colors.push(color(108, 155, 210,128));
colors.push(color(84, 195, 241,241));
colors.push(color(84, 195, 241,241));
 }

function draw() {
points = [];
var n = 50;
 var theta = 10000/ n;
var radius = windowHeight / 2;
var xoff = 0.0;
for (var i = 0; i < n; i = i + 1) {
var amp = noise(xoff, yoff);
points[i] = {
x: amp * radius * cos(i * theta),
y: amp * radius * sin(i * theta)
};
xoff = xoff + 0.2;
}
 yoff = yoff + 20;

 posX = posX + speedX;100
 posY = height / 20 * cos(360 * posX / width) + height / 3;

for (var i = 0; i < n; i = i + 1) {
points[i].x += posX;
points[i].y += posY;
}

stroke(getColor(time));
 fill(255, 255, 255, 2);

beginShape();
for (var i = 0; i < points.length; i = i + 1) {
curveVertex(points[i].x, points[i].y);
}
curveVertex(points[0].x, points[0].y);
 curveVertex(points[3].x, points[3].y);
curveVertex(points[2].x, points[2].y);
endShape();

speedX
}

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