Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/*
**Candlelight**
Created by Shayla Ly
Mouse movement causes the candle's flame to grow and shrink. 
Stars also dim as the mouse moves.
Clicking and holding as well as mouse movement causes a pentagram to appear and glow.
Everything dims but the flame and the pentagram.
Blood appears beneath the candle.
*/

void setup(){
  // Canvas Size
  size(400,400);
  noStroke();
  rectMode(CORNER);

}

void draw(){
  
frameRate(60);
background(#0D0D0C);

// Sky
fill(26,15,48);
rect(0,0,400,150);

// Background Stars
fill(255,237,215,30);
rect(40,40,4,4);
rect(120,70,4,4);
rect(150,30,3,3);
rect(240,70,4,4);
rect(360,120,3,3);
rect(340,20,4,4);
rect(50,50,2,2);
rect(30,20,2,2);
rect(25,96,2,2);
rect(125,60,2,2);
rect(110,75,1,1);
rect(255,60,2,2);
rect(235,45,1,1);
rect(330,10,2,2);
rect(335,35,1,1);

// Stars
fill(255,237,215,(mouseX/5)-sin(frameCount*0.02));
rect(40,40,4,4);
rect(120,70,4,4);
rect(150,30,3,3);
rect(240,70,4,4);
rect(360,120,3,3);
rect(340,20,4,4);

rect(50,50,2,2);
rect(30,20,2,2);
rect(25,96,2,2);
rect(125,60,2,2);
rect(110,75,1,1);
rect(255,60,2,2);
rect(235,45,1,1);
rect(330,10,2,2);
rect(335,35,1,1);

// Wall
fill(#2B2019);
rect(0,150,400,400);

// Window
fill(#3D2A2B);
rect(0,130,400,60);
rect(180,0,40,150);

noStroke();

// Table
fill(#523E2F);
rect(0,260,400,400);

// Blood
if (mousePressed==true) {
fill(92,0,0);
ellipse(200,330,280,70);
ellipse(60,340,100,30);
ellipse(350,310,100,30);

fill(76,0,0,(mouseX/1.5)-sin(frameCount*0.02));
ellipse(60,340,60,10);
ellipse(350,310,60,10);
ellipse(200,330,200,50);
}

// Candle
noStroke();
fill(#FFFFFF);
rect(115,140,170,170);

fill(#F0E9DD);
ellipse(200,140,170,20);

fill(#FFFFFF);
ellipse(200,310,170,50);
ellipse(120,320,60,40);
ellipse(90,330,30,25);
ellipse(280,320,70,40);

// Overlay
if (mousePressed==true) {
  fill(0,0,0,100);
  rect(0,0,400,400);
 
  stroke(255,0,0,100);
  strokeWeight(8-(mouseX/150+mouseY/150));
  fill(0,0,0,0);
  ellipse(200,240,110,110);
  line(220,185,145,265);
  line(145,265,260,240);
  line(260,240,160,200);
  line(160,200,220,295);
  line(220,295,220,185);
  
  stroke(255,0,0,100);
  strokeWeight(12-(mouseX/150+mouseY/150));
  fill(0,0,0,0);
  ellipse(200,240,110,110);
  line(220,185,145,265);
  line(145,265,260,240);
  line(260,240,160,200);
  line(160,200,220,295);
  line(220,295,220,185);
 
  stroke(145,0,0);
  strokeWeight(4-(mouseX/150+mouseY/150));
  fill(0,0,0,0);
  ellipse(200,240,110,110);
  line(220,185,145,265);
  line(145,265,260,240);
  line(260,240,160,200);
  line(160,200,220,295);
  line(220,295,220,185);
 
  stroke(145,0,0);
  strokeWeight(4);
  fill(0,0,0,0);
  ellipse(200,240,110,110);
  line(220,185,145,265);
  line(145,265,260,240);
  line(260,240,160,200);
  line(160,200,220,295);
  line(220,295,220,185);
} else {

}

// Lighting
noStroke();
fill(232,158,66,120);
ellipse(200,100,50-mouseX/100,90-mouseY/90);
fill(232,158,66,80);
ellipse(200,100,70-mouseX/90,110-mouseY/80);
fill(232,158,66,60);
ellipse(200,100,100-mouseX/90,140-mouseY/80);

//Fire
noStroke();
fill(232,117,65,200);
ellipse(200,110,25-mouseX/90,60-mouseY/80);
fill(232,219,127,150);
ellipse(200,110,10-mouseX/90,45-mouseY/80);

}