Crystal-Xue-Project-02

sketch-105.js

//Crystal Xue
//15104-section B
//luyaox@andrew.cmu.edu
//Project_02

var nosePointX = 380;
var nosePointY = 340;
var chinPointX = 372;
var chinPointY = 442;
var jawPointX = 240;
var jawPointY = 430;
var earPointX = 180;
var earPointY = 310;
var lighteningR1 = 255;
var lighteningG1 = 0;
var lighteningB1 = 0;
var lighteningR2 = 0;
var lighteningG2 = 0;
var lighteningB2 = 255;
var backgroundR = 113;
var backgroundG = 114;
var backgroundB = 208;
var count = 0;

function setup() {
    createCanvas(480, 640);
}

function draw() {
	background(backgroundR, backgroundG, backgroundB);

    //hair
    fill(255);
    noStroke();
    ellipse(230,320,220,250);
    quad(120, 320, 190, 500, 300, 500, 310, 300);
    triangle(200, 500, 160, 500, 190, 470);

    //face
    stroke(255);
    strokeWeight(3);
    fill(20);
    beginShape();

    //forehead
    curveVertex(220, 335);       
    curveVertex(220, 330);       
    curveVertex(220, 300);      
    curveVertex(220, 270);        
    curveVertex(220, 245);       
	curveVertex(250, 240);
	curveVertex(300, 235);

    //browbone
	curveVertex(335, 262);

	//nose
	curveVertex(347, 278);
	curveVertex(348, 305);
	curveVertex(nosePointX, nosePointY);
	curveVertex(nosePointX - 15, nosePointY + 21);

    //mouth
	curveVertex(365, 373);
	curveVertex(372, 381);
    curveVertex(368, 391);
    curveVertex(372, 400);

    //chin
    curveVertex(368, 422);
    curveVertex(chinPointX, chinPointY);   
    curveVertex(chinPointX - 7, chinPointY + 16);
    curveVertex(345, 462);
    curveVertex(305, 458);

    //jaw
    curveVertex(jawPointX, jawPointY);       
    curveVertex(220, 370);

    //ear
    curveVertex(205, 375);
    curveVertex(earPointX, earPointY + 45);   
    curveVertex(170, 325);
    curveVertex(earPointX, earPointY);     
    curveVertex(199, 315); 
    curveVertex(earPointX + 35, earPointY + 25);            
    endShape(CLOSE);

    //lightening bolt
    stroke(lighteningR2, lighteningG2, lighteningB2);
    strokeWeight(5)
    line(302, 235, 286, 384);
    line(289, 448, 318, 318);
    push();
    noStroke();
    fill(lighteningR1, lighteningG1, lighteningB1);
    triangle(304, 235, 288, 384, 343, 270);
    quad(323, 308, 291, 448, 352, 310, 346, 273);
    pop();
}

function mousePressed() {
    nosePointX = random(375, 385);
    nosePointY = random(335, 345);
    chinPointX = random(368, 376);
    chinPointY = random(433, 450);
    jawPointX = random(235, 245);
    jawPointY = random(425, 450);
    earPointX = random(175, 185);
    earPointy = random(300, 320);
    backgroundR = random(100, 200);
    backgroundG = random(100, 200);
    backgroundB = random(100, 200);

    count+=1;
    if (count%3==0){
        lighteningR1 = 255;
        lighteningG1 = 0;
        lighteningB1 = 0;  
        lighteningR2 = 0;
        lighteningG2 = 0;
        lighteningB2 = 255;
    }
    
    if (count%3==1){
    	lighteningR1 = 217;
    	lighteningG1 = 190;
    	lighteningB1 = 77;
        lighteningR2 = 104;
        lighteningG2 = 52;
        lighteningB2 = 30;    	
    }

    if (count%3==2){
    	lighteningR1 = 146;
    	lighteningG1 = 206;
    	lighteningB1 = 234;
        lighteningR2 = 214;
        lighteningG2 = 149;
        lighteningB2 = 183;     	
    }
}

I am inspired by David Bowie figure and pop art color palette. I also approached this project with a slightly different way. Experimenting with the side profile of David Bowie was a lot of fun.

Leave a Reply