I wanted to do a little animation/landscape of a worm’s dream 🙂 Flashy colors and big flowers!
sketch
var backgroundX = 600;
var trip = [];
var noiseParam = 0;
var noiseStep = 0.02;
var x1 = 250;
function preload() {
colorBackground = loadImage("https://i.imgur.com/XE9vWWB.png")
worm = loadImage("https://i.imgur.com/CYR27Ru.png");
redFlower = loadImage("https://i.imgur.com/R5vVLaL.png");
yellowFlower = loadImage("https://i.imgur.com/ogHwP78.png");
blueFlower = loadImage("https://i.imgur.com/faPKcYb.png");
backgroundHouse = loadImage("https://i.imgur.com/DgMNstF.png");
backgroundTower = loadImage("https://i.imgur.com/AuMqECF.png");
}
function setup() {
createCanvas(450, 300);
for (var i = 0; i<width/5 +1; i++) {
var n = noise(noiseParam);
var value = map(n,0,1,0,height+50);
trip.push(value);
noiseParam+=noiseStep;
}
}
function draw() {
// backdrop
image(colorBackground,width/2,height/2);
dream();
imageMode(CENTER);
image(blueFlower, x1, 105, 250, 250);
image(redFlower, x1 - 170, 137, 67, 126);
image(yellowFlower, x1 + 130, 105.5, 210, 210);
image(worm, 94, 190.5, 188, 163);
backgroundX -= 2;
x1 -= 2;
// resetting foreground and background elements
if (backgroundX <= -125) {
backgroundX = 900;
}
if (x1 <= -160) {
x1 = 825
}
}
function dream() {
trip.shift();
var n = noise(noiseParam);
var value = map(n,0,1,0,height+50);
trip.push(value);
noiseParam += noiseStep;
beginShape();
vertex(0,height);
for(var i =0; i <= width/5; i++) {
fill(random(150,200),103,random(100,200));
strokeWeight(4);
vertex((i*5),trip[i]);
}
vertex(width,height);
endShape();
}