xxxxxxxxxx
57
// global angle variable starting at 60 radians
let angle = 60;
function setup() {
createCanvas(600, 300);
// once only - different image each time played
noLoop()
noStroke()
}
function draw() {
// off white background
background(250, 241, 222);
// low random value to add to angle, x position and rotation
r = random(0.1, -0.1)
// larger random value to add to offset for sine angle
ra = random(5, 12)
// rotate by small random value
rotate(r)
// set offset to sine angle
let offsetA = ra+50;
// repeat 5 times
for (i=0; i<5; i++){
// random value between 1 and 5 to alter x position
rx = random(1, 5)
// create dots across full width of canvas
for (x = 0; x < width; x++) {
// angle for sine is angle value
// plus slight random plus offset
a = angle + r + offsetA;
// x position will be increment with randoms applied
xa = x * rx + r
// y position is the sine value of variable a
// mapped between 50 and 150
y = map(sin(a), -1, 1, 50, height/2);
// random transparency on sandy colour
let rt = random(80, 100)
fill(240, 182, 81, rt)
// reset the a variable as a counter
for(a=0;a<10;a+=3){
// draw tiny etherial pinpoints
// varying slightly each time
ellipse(xa+5*a,y+5*a,a/2-2,a/2-2)
}
// increment offset to sine angle
offsetA += 0.05;
}
// increment angle value
angle +=0.2;
}
}