Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/*Destiny Ghost shell
description As the mouse moves around the screen the ghost eye will look at the mouse cursor locaton following it piviting in the eye socket. setting is placed in the night sky hence the stars in the background.
twinkling stars
By: Trevon Harris
Sept 19 2016
*/
void setup()
{
  size(400,400);
  rectMode(CORNERS);
  ellipseMode(CORNERS);
  frameRate(30);// 30 frames per secound
}
void draw()
{
  ellipseMode(CORNERS);
  background(0,24,72);//dark blue/black to simulate the sky
  
  stroke(0);
  //middle grey bar
  fill(50,50,50);
  rect(80,195,320,205);
 
  //Box behund ghost giving off diagnal lines as well as filling in around the eye socket
  fill(100,100,100);
  rect(130,130,270,270);
  
  //grey ring/ eye socket
  fill(100,100,100);
  ellipse(160,160,240,240);
   
  //dark blue filling of eye
  fill(40,0,100); 
  ellipse(170,170,230,230);
  
  //inside triangles
  //top right top left
  //noStroke();
  fill(255,130,0);
  triangle(240,160,200,120,200,140);
  triangle(200,120,200,140,160,160);
  
  //left top left bottum
  triangle(160,160,140,195,120,195);
  triangle(160,240,140,205,120,205);
  
  //bottum left bottum right
  triangle(160,240,200,260,200,280);
  triangle(200,260,200,280,240,240);
  
  //right bottum right top
  triangle(240,240,260,205,280,205);
  triangle(260,195,280,195,240,160);
  
  //outter shell
  stroke(0);
  fill(0);
  
  //top right
  quad(340,180,315,165,280,195,320,195);
  quad(315,165,270,130,240,160,280,195);
  quad(270,130,240,80,200,120,240,160);
  quad(240,80,220,50,200,70,200,120);
  
  //top left
  quad(200,70,180,50,160,80,200,120);
  quad(200,120,160,80,130,130,160,160);
  quad(160,160,130,130,85,165,120,195);
  quad(120,195,85,165,60,180,80,195);
   
   //bottum left
  quad(120,205,80,205,60,220,85,235);
  quad(160,240,120,205,85,235,130,270);
  quad(200,280,160,240,130,270,160,320);
  quad(200,330,200,280,160,320,180,350);
  
  //bottum right
  quad(240,320,200,280,200,330,220,350);
  quad(270,270,240,240,200,280,240,320);
  quad(315,235,280,205,240,240,270,270);
  quad(340,220,320,205,280,205,315,235);
  
  stroke(255,130,0);
  //top and bottum orange triangle
  fill(255,130,0);//orange filling
  triangle(220,50,180,50,200,70);
  triangle(220,350,200,330,180,350);
 
  //left top and bottum orange triangles
  triangle(80,195,60,180,60,195);
  triangle(80,205,60,205,60,220);
  

  //right top and bottum triangles 
  triangle(340,195,340,180,320,195);
  triangle(340,220,340,205,320,205);
  
  /*as the mouse moves around the screen the green colored eye follows the mouse piviting around the eye socket*/
  stroke(0,255,0);// will fill the 1 pixel gap inbetteen the shapes
  fill(0,255,0);//green filling for eye
  
  ellipse((mouseX-width/2)*.02+195,(mouseY-height/2)*.02+195,(mouseX-width/2)*.02+205,(mouseY-height/2)*.02+205);//middle of the eye
  //right side of eye
  quad((mouseX-width/2)*.02+198,(mouseY-height/2)*.02+177,(mouseX-width/2)*.02+198,(mouseY-height/2)*.02+190,(mouseX-width/2)*.02+190,(mouseY-height/2)*.02+200,(mouseX-width/2)*.02+180,(mouseY-height/2)*.02+195);// eye top left
  quad((mouseX-width/2)*.02+198,(mouseY-height/2)*.02+223,(mouseX-width/2)*.02+198,(mouseY-height/2)*.02+210,(mouseX-width/2)*.02+190,(mouseY-height/2)*.02+200,(mouseX-width/2)*.02+180,(mouseY-height/2)*.02+205);// eye bottim left
  triangle((mouseX-width/2)*.02+190,(mouseY-height/2)*.02+200,(mouseX-width/2)*.02+180,(mouseY-height/2)*.02+195,(mouseX-width/2)*.02+180,(mouseY-height/2)*.02+205);
  //left side of eye
  quad((mouseX-width/2)*.02+202,(mouseY-height/2)*.02+177,(mouseX-width/2)*.02+202,(mouseY-height/2)*.02+190,(mouseX-width/2)*.02+210,(mouseY-height/2)*.02+200,(mouseX-width/2)*.02+220,(mouseY-height/2)*.02+195);// eye top right
  quad((mouseX-width/2)*.02+202,(mouseY-height/2)*.02+223,(mouseX-width/2)*.02+202,(mouseY-height/2)*.02+210,(mouseX-width/2)*.02+210,(mouseY-height/2)*.02+200,(mouseX-width/2)*.02+220,(mouseY-height/2)*.02+205);// eye top left
  triangle((mouseX-width/2)*.02+210,(mouseY-height/2)*.02+200,(mouseX-width/2)*.02+220,(mouseY-height/2)*.02+195,(mouseX-width/2)*.02+220,(mouseY-height/2)*.02+205);

  // pulsing/ glowing eye 
  noStroke();
  fill(0,255,0,60);
  ellipse(cos(frameCount * .08) * 5+(mouseX-width/2)*.03+140,cos(frameCount * .08) * 5+(mouseY-height/2)*.03+140,cos(frameCount * .08) * 5+(mouseX-width/2)*.03+260,cos(frameCount * .08) * 5+(mouseY-height/2)*.03+260);

  ellipse(cos(frameCount * .08) * 5+(mouseX-width/2)*.03+160,cos(frameCount * .08) * 5+(mouseY-height/2)*.03+160,cos(frameCount * .08) * 5+(mouseX-width/2)*.03+240,cos(frameCount * .08) * 5+(mouseY-height/2)*.03+240);

  // stars twinkeling using sin/framecounte opening and closing flat circles produces twinkling effect
  fill(255);
  ellipseMode(CENTER);
  ellipse(320,140,sin(frameCount*25)*5,10);
  ellipse(320,140,10,sin(frameCount*25)*5);
 
  ellipse(100,60,sin(frameCount*25)*5,10);
  ellipse(100,60,10,sin(frameCount*25)*5);
 
  ellipse(40,380,sin(frameCount*25)*5,10);
  ellipse(40,380,10,sin(frameCount*25)*5);
 
  ellipse(360,20,sin(frameCount*25)*5,10);
  ellipse(360,20,10,sin(frameCount*25)*5);
 
  ellipse(380,240,sin(frameCount*25)*5,10);
  ellipse(380,240,10,sin(frameCount*25)*5);
 
  ellipse(300,300,sin(frameCount*25)*5,10);
  ellipse(300,300,10,sin(frameCount*25)*5);
 
  ellipse(120,380,sin(frameCount*25)*5,10);
  ellipse(120,380,10,sin(frameCount*25)*5);
 
  ellipse(60,160,sin(frameCount*25)*5,10);
  ellipse(60,160,10,sin(frameCount*25)*5);
 
  ellipse(340,360,sin(frameCount*25)*5,10);
  ellipse(340,360,10,sin(frameCount*25)*5);
 
  ellipse(100,280,sin(frameCount*25)*5,10);
  ellipse(100,280,10,sin(frameCount*25)*5);
 
  ellipse(270,60,sin(frameCount*25)*5,10);
  ellipse(270,60,10,sin(frameCount*25)*5);
 
 //detail lines
  stroke(255,130,0);
  fill(255,130,0);
  line(240,160,270,130);
  line(160,160,130,130);
  line(160,240,130,270);
  line(240,240,270,270);
  line(223,55,200,80);
  line(200,80,178,55);
  line(178,343,200,320);
  line(200,320,223,343);
  
}