xxxxxxxxxx
103
var a; //offset
let colours = [
"#F7CE5B",
"#F7B05B",
"#ECC30B",
"#ffd166",
"#87CEEB",
"#00CCFF",
"#38285C",
]; //colour palette for swirls
let swirls = []; //arrays for swirl instances
function setup() {
createCanvas(600, 400);
noStroke();
background("#000435");
for (a = 100; a <= 600; a += 100) {
let skySwirl = new drawSwirl(a, 60.0, 3.5, 0.3, colours);
swirls.push(skySwirl);
}
}
function draw() {
for (let drawSwirl of swirls) {
drawSwirl.draw();
}
//moon
stroke("#ffffc5");
strokeWeight(5);
fill("#ffce1b");
circle(450, 100, 100);
strokeWeight(10);
stroke("#e1ad01");
noFill();
circle(450, 100, 50); //to create layers in moon colours
//the cypress tree in gogh's original painting
beginShape();
fill("#001e09");
stroke("#ffffc5");
strokeWeight(1);
vertex(80, 400);
vertex(50, 450);
vertex(70, 305);
vertex(80, 260);
vertex(65, 220);
vertex(80, 165);
vertex(90, 200);
vertex(100, 170);
vertex(90, 130);
vertex(105, 110);
vertex(106, 80);
vertex(115, 45);
vertex(120, 120);
vertex(130, 140);
vertex(125, 170);
vertex(130, 200);
vertex(140, 210);
vertex(150, 180);
vertex(155, 280);
vertex(160, 240);
vertex(155, 140);
vertex(160, 300);
vertex(170, 260);
vertex(170, 120);
vertex(160, 320);
vertex(180, 230);
vertex(190, 310);
vertex(200, 280);
vertex(215, 395);
vertex(222, 320);
vertex(225, 335);
vertex(230, 360);
vertex(250, 180);
vertex(270, 400);
endShape();
}
//using class for the swirls in the sky
class drawSwirl {
constructor(a, angle, scalar, speed, colours) {
this.a = a;
this.angle = angle;
this.scalar = scalar;
this.speed = speed;
this.colours = colours;
}
draw() {
var x = this.a + cos(this.angle) * this.scalar;
var y = this.a + sin(this.angle) * this.scalar;
fill(random(this.colours));
stroke("#ffffc5");
strokeWeight(0.5);
ellipse(x, y, 5, 5);
this.angle += this.speed;
this.scalar += this.speed;
}
}