Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
////////Desert Night - By Jessica Cornelius/////////

void setup() {
  //Creates canvas size at 400x400 pixels
  size(400,400);
  //Sets default background to blue
  background(121, 216, 234);
  //Created objects have no line weight
  noStroke();
}

void draw() {
  //Night to Day Change, Lower the mouse on the canvas = darker colours
  background(-mouseY/4+50, -mouseY/4+122, -mouseY/4+214);
  
  //Sun, Mouse location = suns location
  fill(255, 241, 85);
  ellipse(mouseX, mouseY, 40, 40);
  //Outer layers of sun, opacity added
  fill(255, 241, 85, 80);
  ellipse(mouseX, mouseY, 45, 45);
  fill(255, 241, 85, 50);
  ellipse(mouseX, mouseY, 50, 50);
  
  //Sand, Lower the mouse on the canvas = darker colours
  fill(-mouseY/5+228, -mouseY/5+178, -mouseY/5+105);
  rect(0, 240, 400, 160);
  
  //Pyramids, Lower the mouse on the canvas = darker colours
  fill(-mouseY/5+182, -mouseY/5+142, -mouseY/5+88);
  triangle(340, 40, 140, 240, 540, 240);
  fill(-mouseY/5+225, -mouseY/5+175, -mouseY/5+106);
  triangle(220, 100, 360, 240, 80, 240);
  
  //Pyramid Shadows, Lower the mouse on the canvas = the smaller the shadow gets & shadows get darker
  //Shadows disappear at night time
  fill(-mouseY+91, -mouseY+61, -mouseY+30, -mouseY+300);
  triangle(-mouseX+690, -mouseY/4+340, 140, 240, 540, 240);
  fill(-mouseY+91, -mouseY+61, -mouseY+30, -mouseY+300);
  triangle(-mouseX+450, -mouseY/6.64+300, 360, 240, 80, 240);
 
  //Stars, Lower the mouse on the canvas = makes stars visible
  fill(255, mouseY/5);
  ellipse(40, 30, 6, 6);
  fill(255, mouseY/2);
  ellipse(40, 30, 2, 2);
  
  fill(255, mouseY/5);
  ellipse(10, 110, 3, 3);
  fill(255, mouseY/1);
  ellipse(10, 110, 2, 2);
  
  fill(255, mouseY/2);
  ellipse(140, 20, 2, 2);
  
  fill(255, mouseY/5);
  ellipse(210, 30, 3, 3);
  fill(255, mouseY/1);
  ellipse(210, 30, 2, 2);
  
  fill(255, mouseY/5);
  ellipse(280, 70, 6, 6);
  fill(255, mouseY/2);
  ellipse(280, 70, 2, 2);
  
  fill(255, mouseY/5);
  ellipse(100, 100, 3, 3);
  fill(255, mouseY/1);
  ellipse(100, 100, 1, 1);
  
  fill(255, mouseY/5);
  ellipse(60, 160, 6, 6);
  fill(255, mouseY/2);
  ellipse(60, 160, 2, 2);
  
  fill(255, mouseY/5);
  ellipse(140, 110, 3, 3);
  fill(255, mouseY/1);
  ellipse(140, 110, 2, 2);
  
  fill(255, mouseY/5);
  ellipse(115, 75, 6, 6);
  fill(255, mouseY/2);
  ellipse(115, 75, 2, 2);
  
  fill(255, mouseY/5);
  ellipse(380, 40, 6, 6);
  fill(255, mouseY/2);
  ellipse(380, 40, 2, 2);
  
  fill(255, mouseY/2);
  ellipse(180, 45, 2, 2);
  
  fill(255, mouseY/2);
  ellipse(235, 20, 2, 2);
  
  fill(255, mouseY/2);
  ellipse(255, 60, 2, 2);
  
  fill(255, mouseY/5);
  ellipse(300, 30, 3, 3);
  fill(255, mouseY/1);
  ellipse(300, 30, 2, 2);
  
  //Firelogs Base Colour
  fill(121, 95, 61);
  ellipse(200, 323, 63, 21);
  
  //Firelog Seperations
  stroke(72, 54, 30);
  //Giving less stroke to logs further away
  strokeWeight(0.5);
  line(200, 318, 222, 315);
  line(200, 318, 178, 315);
  line(200, 318, 208, 313);
  line(200, 318, 192, 313);
  //Increasing stroke to mid logs
  strokeWeight(1);
  line(200, 318, 230, 321);
  line(200, 318, 170, 321);
  line(200, 318, 225, 324);
  line(200, 318, 175, 324);
  //Increasing stroke to closest logs
  strokeWeight(1.5);
  line(200, 318, 222, 332);
  line(200, 318, 178, 332);
  line(200, 318, 208, 335);
  line(200, 318, 192, 335);
  
  //Firelogs
  strokeWeight(0.5);
  fill(180, 143, 95);
  ellipse(167, 328, 7, 13);
  ellipse(233, 328, 7, 13);
  ellipse(173, 333, 12, 15);
  ellipse(227, 333, 12, 15);
  ellipse(185, 338, 16, 17);
  ellipse(215, 338, 16, 17);
  ellipse(200, 340, 18, 18);
  
  //Random Orange Flames, random flickering between top X coordinate within 16pixels
  noStroke();
  fill(255, 155, 54, 210);
  triangle(random(175,185), 260, 200, 310, 178, 310);
  triangle(222, 310, 200, 310, random(215,225), 275);
  triangle(random(197,213), 250, 215, 310, 185, 310);
  
  //Static Flame Orange
  fill(255, 155, 54, 235);
  ellipse(200, 310, 45, 45);
  
  //Random Yellow Flames, random flickering between top X coordinate within 10pixels
  fill(255, 212, 54, 160);
  triangle(random(203,207), 258, 206, 298, 195, 298);
  triangle(random(180,186), 280, 193, 295, 184, 310);
  triangle(random(216,222), 285, 210, 298, 216, 315);
  
  //Static Flame Yellow
  fill(255, 212, 54, 235);
  ellipse(200, 310, 33, 33);
  
  //Flame Glow, appears at night
  fill(255, 166, 0, mouseY/10);
  ellipse(200, 300, 150, 150);
  fill(mouseY+255, mouseY+166, mouseY+0, mouseY/30);
  ellipse(200, 300, 180, 180);
  fill(mouseY+255, mouseY+166, mouseY+0, mouseY/50);
  ellipse(200, 300, 200, 200);
  
  //Moon Position, fill enabling slight visibility in day
  fill(200, mouseY+50);
  ellipse(60, 60, 40, 40);
  fill(250, mouseY+50);
  ellipse(60, 60, 35, 35);
}