Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/* 
This program is isnpired by my love of shiny objects

Title: Bling

 By Shannon Umerez -->991514126
       
       >this program is a display of a diamond using a mix of different triangles
       >the x and y positions of the mouse affect the patterns of the backround creating 
       different lighting in contrast to the diamnd
       >with a mouse click you can freeze the background
         - a light source will apprear parallel to the mouse position on the x axis
           revealing the sparkle of light shining off the diamond
       >engage with the mesmerizing illusion of visually appealling objects
       
       */
       
      
void setup(){
//size of window
  size(400,400);
}

void draw(){
  frameRate(60);
//set the background colour to white
  background(255);
 
         //BACKGROUND//
         
//background shading circles that change colour with mouse movement
  fill(0);
  noStroke();
  rect(0,0,400,400,mouseX);
  fill(66,73,73,mouseX); //1
  ellipse(200,200,500,500);
  fill(81,90,90,mouseX);//2
  ellipse(200,200,475,475);
  fill(97,106,107,mouseX);//3
  ellipse(200,200,450,450);
  fill(112,123,124,mouseX);//4
  ellipse(200,200,425,425);
  fill(127,140,141,mouseX);//5
  ellipse(200,200,400,400);
   fill(153,163,164,mouseX);//6
  ellipse(200,200,375,375);
  fill(178,186,187,mouseX);//7
  ellipse(200,200,350,350);
  fill(204,209,209,mouseX);//8
  ellipse(200,200,325,325);
  fill(229,232,244,mouseX);//9
  ellipse(200,200,300,300);
  fill(255);//10
  ellipse(200,200,mouseY,mouseY);
  fill(255);
  ellipse(200,200,275,275);

      //DIMOND BASE//
//set triangle colour and stroke
  fill(153,255,255,255);
  stroke(255);
  strokeWeight(1);

//top triangles of diamond 
  triangle(60,140,80,140,120,80); //1
  triangle(80,140,120,135,120,80); //2
  triangle(120,80,120,135,160,80); //3
  triangle(160,80,120,135,180,135); //5
  triangle(160,80,180,135,200,80); //7
  triangle(200,80,180,135,220,135); //8
  triangle(200,80,220,135,240,80); //9
  triangle(240,80,220,135,280,135); //10
  triangle(280,80,240,80,280,135); //13
  triangle(280,135,280,80,320,140); //14
  triangle(320,140,340,140,280,80); //15

//bottom triangles
  triangle(60,140,80,140,165,290);   //16
  triangle(80,140,140,135,140,240);  //17
  triangle(140,238,140,135,180,280); //18
  triangle(140,240,165,290,180,280); //19
  triangle(180,280,140,135,200,135); //20
  triangle(180,280,200,135,220,280); //21
  triangle(200,135,220,280,260,135); //22
  triangle(220,280,260,135,260,240); //23
  triangle(260,135,260,240,320,140); //24
  triangle(320,140,340,140,235,290); //25
  triangle(220,280,235,290,262,240); //26
  triangle(165,290,180,280,200,340); //27
  triangle(180,280,220,280,200,340); //28
  triangle(220,280,235,290,200,340); //29
 
    //DEPTH triangles //
//blue
//top
  strokeWeight(0);
  fill(77,204,255,90);
  triangle(200,80,190,135,210,135);
  triangle(60,140,80,140,120,80);//1
  triangle(80,140,95,136,120,80); //2
  triangle(305,137,280,80,320,140); //14
  triangle(320,140,340,140,280,80); //15
  triangle(120,135,120,80,130,120); //16
  triangle(280,135,280,80,270,120);//17
  triangle(120,135,140,133,160,80);//18
  triangle(240,80,260,135,280,135);//19
  triangle(160,80,180,135,182,125);//20
  triangle(220,135,217,125,240,80);//21

//bottom part of diamond
  triangle(320,140,310,138,260,240);
  triangle(315,140,340,140,335,145);
  triangle(330,140,340,140,290,210);
  triangle(260,135,250,135,220,280);
  triangle(220,280,200,135,196,160);
  triangle(180,280,200,135,204,160);
  triangle(180,280,140,135,150,135);
  triangle(80,140,90,139,140,240);
  triangle(60,140,70,140,165,290);
  triangle(60,140,80,140,65,145);
  triangle(260,240,220,280,230,287);
  triangle(140,240,173,285,180,280);
  triangle(200,340,180,280,190,280);
  triangle(200,340,210,280,220,280);
  triangle(167,290,175,283,200,340);
  triangle(224,285,235,290,200,340);
}


void mousePressed(){
//when the mouse is pressed the diamond changes to colours of light for one second
//also changes background colour for reference 
  frameRate(1);

//yellow colour glare in Diamond
  fill(255,255,0,mouseX/400.0*175);
  triangle(180,135,178,125,200,80);
  triangle(220,135,225,120,200,80);
  triangle(258,142,260,135,205,135);
  triangle(200,135,202,142,235,135);
  triangle(143,145,140,135,170,135);
  triangle(170,135,199,142,200,135);
  triangle(265,120,270,80,280,80);
  triangle(280,110,280,100,305,137);
  triangle(126,120,120,80,130,80);
  triangle(93,138,120,100,120,110);

//bottom of diamond 
  triangle(70,145,75,140,165,290);
  triangle(325,140,330,145,240,280);
  triangle(150,250,150,240,175,260);
  triangle(223,260,250,250,250,240);
  triangle(220,280,215,240,240,180);
  triangle(180,280,185,240,160,180);

//red colour in Diamond
  fill(239, 83, 80,mouseX/400.0*175);
  triangle(230,80,240,80,217,125);
  triangle(160,80,170,80,180,120);
  triangle(280,80,280,100,305,136);
  triangle(90,138,120,80,120,100);
//bottom of diamond
  triangle(250,250,220,280,225,260);
  triangle(150,250,175,260,180,280);
  triangle(280,200,295,137,310,140);
  triangle(120,200,90, 140, 105,137);


//green in diamond
  fill(0, 172, 193,mouseY/400.0*175);
  triangle(140,135,145,125,180,135);
  triangle(220,135,255,125,260,135);
//bottom of diamond
  triangle(250,250,260,240,260,135);
  triangle(140,240,140,135,150,250);
  triangle(213,240,218,260,200,280);
  triangle(200,280,182,260,188,240);


        //DRAW LIGHT//
  fill(255,255,30);
  ellipse(40+mouseX,40+mouseY/40,30,30);
  fill(255,255,0,100);
  ellipse(40+mouseX,40+mouseY/40,50,50);
  fill(174,214,241,60);
  ellipse(200+mouseX,200+mouseY,20,20);
  
  // SPARKLES//
  fill(266);
  strokeWeight(2);
//1
  line(120,75,120,85);
  line(115,80,125,80);
  line(115,75,125,85);
//2
  line(160,170,160,190);
  line(170,170,150,190);
  line(150,180,170,180);
//3
  line(247,129,252,147);
  line(236,131,260,142);
  line(255,130,245,145);
}