Project 2 – Variable Faces (Dog)

Click through for color and other variable changes

sketch

var rightearX = 360;
var rightearY = 240;
var leftearX = 120
var leftearY = 240
var pupilH = 29
var eyebrow = 211
var nose = 120
var tongue = 43
var r = 80
var g= 35
var b= 80
var red = 255
var green = 255
var blue = 255
var beardR = 213
var beardG = 227
var beardB = 244
 
function setup() {
    createCanvas(500, 500);
}
 
function draw() {
    background("white");
    noStroke();
//facebase
    fill(red,green,blue);
        rect(144,150,214,198,50);
//facehood-dark color
    fill(r,g,b);
        rect(144,150,214,162,50);
//faceeyes
    fill(red,green,blue);
        rect(176,192,66,111,33);
        rect(259,192,66,111,33);
//nose
    fill(red,green,blue);
        ellipse(249,337,nose,113);
//tongue
    fill("red");
        rect(229,311,41,tongue,20);
//beard
    fill(beardR,beardG,beardB);
        quad(195,341,216,363,263,316,242,294);
        quad(239,316,260,294,307,341,286,363);
//white eyes
    fill("white");
        ellipse(209,247,37,41);
        ellipse(293,247,37,41);
//darkest color
    fill(r,g,b);
    //ears
        triangle(299,139,383,156,rightearX,rightearY);
        triangle(200,139,116,151,leftearX,leftearY);
    //pupil
        ellipse(208,252,24,pupilH);
        ellipse(293,252,24,pupilH);
    //eyebrows
        rect(189,eyebrow,40,9,5);
        rect(274,eyebrow,40,9,5);
    //snout
        ellipse(250,304,60,34);
}
 
function mousePressed() {
    rightearX = random(350, 390);
    rightearY = random(240, 340);
    leftearX = random(110,150);
    leftearY = random(240,340);
    pupilH = random(20,38);
    eyebrow = random(200,224);
    nose = random(120,150);
    tongue = random(43,80);
    r = random (0,100);
    g = random(0,100);
    b = random (0,100);
    red = random (100,255);
    green = random (100,255);
    blue = random (100,255);
    beardR = random (200,255);
    beardG = random (200,255);
    beardB = random (200,255);
}

Leave a Reply