Kevin Thies – Variable Face

sketch

//Kevin Thies
//Section C
//kthies@andrew.cmu.edu
//Project-02

// Core Variables
var headHeight = 200; // head height and width
var headWidth = 200;
var noseHeight = headHeight * 2.5; // relates proportion of head to  nose
var noseAngle = -4;

var skinR = 221; // color values for skin and background
var skinG = 203;
var skinB = 161;

var backR = 25; // background color offset from skin color values
var backG = 25; // additionally used to offset eye color
var backB = 25; // so the colors all harmonize

var eyeOffset = 50; // setback from head width
var eyeWidth = headWidth/2 - eyeOffset; // eye position
var eyeHeight = eyeWidth * headHeight / headWidth; // use head proportions for eyes
var eyeTop = 3;
var eyeBottom = 3.5;
var pupilRatio = .8; // ratio of eye white to black
var irisRatio = 1.4; // ratio of eye black to color


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

function draw() {

    // Background that
    background(skinR + backR, skinG + backG, skinB + backB);

    // Head Shape
        // Nose, sometimes it looks more like a nose and that's ok
        noStroke();
        fill(skinR, skinG, skinB);
        arc(width/2, height/3, headWidth, noseHeight, noseAngle, 0, CHORD);

        // Hide the top half of nose generated
        fill(skinR + backR, skinG + backG, skinB + backB);
        rect(0,0, width, height/3);

        // Head's main ellipse
        fill(skinR, skinG, skinB);
        ellipse(width/2, height/3, headWidth, headHeight);

    // Nose

    // Eyes
        // Pupil
        fill(0);
        arc(width/2 - headWidth/2 + eyeOffset, height/3, eyeWidth,
            eyeHeight, eyeTop, eyeBottom, PIE);
        // Iris
        fill(skinR - backR, skinG - backG, skinB - backB);
        arc(width/2 - headWidth/2 + eyeOffset, height/3, eyeWidth * pupilRatio * irisRatio,
            eyeHeight * pupilRatio * irisRatio, eyeTop, eyeBottom, PIE);
        // White
        fill(255);
        arc(width/2 - headWidth/2 + eyeOffset, height/3, eyeWidth * pupilRatio,
            eyeHeight * pupilRatio, eyeTop, eyeBottom, PIE);


}

function mousePressed() {

    //Reshuffle the head dimensions
    headWidth = random(120, 200);
    headHeight = random(100, 160);
    noseHeight = headHeight * random(2, 3);
    noseAngle = -random(3.66, 4); //radian angle of  arc

    //Change eye color and Shape
    eyeOffset = random(45, 60);
    eyeTop = random(2.61, 3.14); // 5/6 Pi to Pi
    eyeBottom = random(3.14, 3.66); //Pi to 7/6 pi
    pupilRatio = random(.75, .5);
    irisRatio = random(1.2, 1.3);

    // Constrain face color to less saturated, darker values
    skinR = random(140, 225);
    skinG = random(143, 225);
    skinB = random(140, 184);

    // Reshuffle background color offset
    backR = random(-50, 25);
    backG = random(-50, 25);
    backB = random(-50, 25);
}

There was a lot of math involved in this one. If I could go back in time, I think bezier curves would’ve been a better fit than arcs simply based on the parameters they use. At the same time, since I used arcs, the end product morphed into what it is now instead of more ‘realistic’ shapes.

Julie Choi-Project-02-Variable-Face

juliechoi_project_02

// declare character variables
var faceWidth = 130;
var faceHeight = 150;
var eyeSize = 25;
var pupilSize = 10;
var mouthSize = 25;
var tongueSize = 20;
var bodySize = 160;
var legSize = 20;
var blushSize = 20;

// declare other object variable
var discoSize = 85;

// declare color variables
var r = 0;
var g = 0;
var b = 0; 
var skinColor1 = 249; 
var skinColor2 = 205;
var skinColor3 = 161;
var colorA = 0;
var colorB = 0;
var colorC = 0;


function setup() {
    createCanvas(640,480);
 }
function draw() {
	// draw background
    background(r, g, b);

    // draw face + body + legs
    noStroke();
    fill(skinColor1, skinColor2, skinColor3);
    ellipse(width / 2, height / 2, faceWidth, faceHeight);
    fill(249, 205, 161);
    noStroke();
    fill(skinColor1, skinColor2, skinColor3);
    ellipse(width / 2, height / 2 + 100, bodySize, bodySize);
    fill(249, 205, 161);
    noStroke();
    fill(skinColor1, skinColor2, skinColor3);
    ellipse(width / 1.8, height / 1.15, legSize / 1.9, legSize + 30);
    noStroke();
    ellipse(width / 2.2, height / 1.15, legSize / 1.9, legSize + 30);

    // declare eye variables
    var eyeLeft = width / 2 - faceWidth * 0.25;
    var eyeRight = width / 2 + faceWidth * 0.25;
    var pupilLeft = width / 2 - faceWidth * 0.25;
    var pupilRight = width / 2 + faceWidth * 0.25;

    // draw eyes + pupil
    fill(255);
    ellipse(eyeRight, height / 2.25, eyeSize, eyeSize);
    ellipse(eyeLeft, height / 2.25, eyeSize, eyeSize);

    fill(0);
    ellipse(pupilRight, height / 2.2, pupilSize, pupilSize);
    ellipse(pupilLeft, height / 2.2, pupilSize,pupilSize);

    // draw nose with curveVertex
    strokeWeight(1);
    stroke(255);
    noFill(0);
    beginShape();
    curveVertex(width / 1.95, height / 2.3);
    curveVertex(width / 1.95, height / 2.3);
    curveVertex(width / 1.94, height/ 2.1);
    curveVertex(width / 1.9, height/ 2);
    curveVertex(width / 2, height / 2);
    curveVertex(width / 2, height / 2);
    endShape();

    // draw hair strand with curveVertex
    strokeWeight(3);
    stroke('brown');
    noFill(0); //320, 240
    beginShape();
    curveVertex(323, 170);
    curveVertex(323, 170);
    curveVertex(320, 166);
    curveVertex(325, 159);
    curveVertex(323, 153);
    curveVertex(326, 148);
    curveVertex(322, 142);
    curveVertex(324, 135);
    curveVertex(324, 135);
    endShape();

    // draw mouth
    colorA = 243;
    colorB = 159;
    colorC = 76;

    noStroke();
    fill(colorA, colorB, colorB);
    ellipse(width / 2, height / 2 + 20, mouthSize + 5, mouthSize / 2 + 5);

    fill(colorA, colorC, colorC);
    //strokeWeight(5);
	//fillStroke(243, 159, 159);
    ellipse(width / 2, height / 2 + 20, mouthSize + 2, mouthSize / 1.9);

	// draw tongue
    noStroke();
    fill(colorA, colorC, colorC);
    ellipse(width / 2, height / 2 + 25, tongueSize / 1.8, tongueSize + 3);

    // draw blush
    fill('pink');
    strokeWeight(1);
    stroke(255, 255, 255, 50);
    ellipse(width / 2.4, height / 2 + 10, blushSize * 2, blushSize);

    strokeWeight(1);
    stroke(255, 255, 255, 50);
    ellipse(width / 1.7, height / 2 + 10, blushSize * 2, blushSize);

    //draw disco ball shape
    noStroke();
    fill(150);
    rect(315, 0, 15, 25);
    quad(315, 25, 330, 25, 335, 35, 310, 35);
    ellipse(width / 1.99, height / 6.5, discoSize, discoSize);

    fill(0);
    ellipse(307, 52, 15, 15);
    ellipse(327, 72, 15, 15);

    fill(0);
    ellipse(345, 60, 15, 15);
    ellipse(319, 100, 15, 15);

    fill(0);
    ellipse(298, 78, 15, 15);
    ellipse(343, 88, 15, 15);

    fill(243, 36, 202); //pink
    ellipse(305, 50, 15, 15);
    ellipse(325, 70, 15, 15);

    fill(24, 138, 255); //blue
    ellipse(347, 60, 15, 15);
    ellipse(321, 100, 15, 15);

    fill(255, 255, 24); //yellow
    ellipse(300, 80, 15, 15);
    ellipse(345, 90, 15, 15);
}

function mousePressed() {
    faceWidth = random(150, 250);
    faceHeight = random(150, 200);
    eyeSize = random(10, 40);
    pupilSize = random(5, 10);
	mouthSize = random(20, 28);
	tongueSize = random(15, 18);
	bodySize = random(160,200);
	blushSize = random(15,20)
    colorA = random(0, 255);
    colorB = random(0, 255);
    colorC = random(0, 255);
    skinColor1 = random(0, 255);
    skinColor2 = random(0, 255);
    skinColor3 = random(0, 255);
    r = random(0, 255);
    g = random(0, 255);
    b = random(0, 255);
}


For this project, I personally had so much fun using all the new materials from this week. I ended up creating a character in a rave with randomized expression and color. I was able to figure out that when I randomize the color under the draw function, the background changes extremely quickly since the draw function is in a loop. Although applying that part looks more like a rave, I didn’t apply it to my code for this post because it might hurt some people’s eyes. Instead, if you are curious, download this: real_rave  to see how it looks. I hope you enjoy!

Sean McGadden Looking Outward- 02

Generative Art

Looking Outward – 02

Jean-Pierre Hébert

This artist has been making some really interesting computational and generative art for the past 50 years. Jean-Pierre began as one of the pioneers of experimental computer generated art in the 1970’s. Much of his work is very abstracted relying heavily on color and line to create complex tactile canvases that imply depth and texture extremely well.  His work is quite responsible because he does not abandon the notion of physical production. As a result Jean-Pierre does create computationally designed works but he executes these works with specific physical medium installed into special printers. The piece below is made with sepia ink on paper and pen plotter drawing. It is  called “quantic notions” made in 1989:

Jean-Pierre  describes his method for creating such works as a physically limitless, horizon less, infinite space for transcending traditional drawing techniques and space itself. He uses the assets of coding and programming to layer information that goes deeper than the visual. He is able to create pieces of incredible detail and scale without the strain of another traditional physical endeavor. I am very interested by this idea of computation and iteration. Jean-Pierre Hebert is able to create many variations on one piece of work before he is satisfies and this is easily done simply by multiple prints and changes in code. I can also see the connections in his style to modern day print-making. Using a physical input of etches or carves from a block, a print-maker is able to make many passes and address changes in the block. In this way, the computer code is Jean-Pierre’s printing block. His ideas are very modern and it seems he is beyond his time in generative art. Another older piece I quite liked was Vent Noir 2 (1989) below:

His pieces are evocative and memorable. They make the viewer question what it is they are seeing.  Jean-Pierre Hebert has also continued creating fascinating work well into the 2010’s. Another newer piece of his called “In Visible Cities Baucis” (2010) is pigment and metal type on paper, a digital drawing on niyodo paper. Below:

I think ultimately his work is limited by the programs he can use to code with and the data he has available. In his more current work he has resorted to larger more public pieces with much collaboration. His initial work is more creatively valuable becasue he was a trail blazer of generative art. In the new age of technology programmatic capabilities seem to evade him. He remains an influential personality.

September 7, 2018

Rebecca Kim – Project 02 – Variable Face

rebecca-variableface

/*
Rebecca Kim
Section C
rykim@andrew.cmu.edu
Project-O2
*/


//define variables
var eyeSize = 20;
var faceWidth = 250;
var faceHeight = 200;
var colorX = 200;
var petalY1 = 50;
var petalY2 = 30;
var wordNumber = 0;
var colorR = 255;
var colorG = 120;
var colorB = 120;
var y1 = 285;
var y2 = 295;
var smileY=320;

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

function draw() {
	//face
	strokeWeight(5);
	background(colorX,180,180);
    ellipse(width/2, height/1.9, faceWidth, faceHeight);
    noFill(0);
    stroke(255,255,colorB);
    strokeWeight(.5);
    ellipse(width/2.1, height/1.95, faceWidth, faceHeight);

	//eyes
	strokeWeight(0);
	var eyeLX = width / 2 - faceWidth * 0.25
	var eyeRX = width / 2 + faceWidth * 0.25
	fill(colorR, colorG, colorB);
	ellipse(eyeLX, height / 2, eyeSize, eyeSize);
	ellipse(eyeRX, height / 2, eyeSize, eyeSize);

	//blush
	strokeWeight(5);
	stroke(colorR,colorG,colorB);
	line(385,y1,390,y2);
	line(395,y1,400,y2);
	line(405,y1,410,y2);

	//facial expression
	noFill();
	stroke(0);
	strokeWeight(2);
	beginShape();
	curveVertex(width/2-faceWidth*.15,smileY);
	curveVertex(width/2+faceWidth*.025,310);
	curveVertex(width/2-faceWidth*.025,310);
	curveVertex(width/2+faceWidth*.15,smileY);
	endShape();


	//larger flower
	translate(200, 300);
	strokeWeight(0);
	stroke(colorR,120,120);
	for (var i = 0; i < 10; i ++) {
	ellipse(0, 10, 10, petalY1);
	rotate(PI/5);
	}

	//smaller flower
	translate(240, -40);
	strokeWeight(0);
	fill(colorX,120,120);
	for (var i = 0; i < 10; i ++) {
	ellipse(1, 5, 7, petalY2);
	rotate(PI/3);
	}


	//text
	var word = int(wordNumber);
	if (word == 1) {
		strokeWeight(.1);
		textSize(12);
		fill(160);
		text("???", 50, 50);
	} else if (word == 2){
		noStroke();
		textSize(20);
		fill(200,160,160);
		text(":-(", 50, 50);
	} else if (word == 3){
		strokeWeight(1);
		textSize(15);
		fill(255);
		text(":-/", 50, 50);
	}

 }

 function mousePressed() {
 	faceWidth = random(200, 300);
 	faceHeight = random(150, 300);
 	eyeSize = random(10,25);
 	colorX = random(180,255);
 	colorR = random(240,255);
 	colorG = random(100,150);
 	colorB = random(80,140);
 	petalY1 = random(50,80);
 	petalY2 = random(25,40);
 	word = random(0,4);
 	wordNumber = random(0,4);
 	y1 = random(275,285);
 	y2 = random(285,295);
 	smileY = random(280,350);
 }

Navigating the world of arcs and curves was new and a bit challenging, but nonetheless rewarding once I successfully embedded it into my code!

Sharon Yang Looking Outwards – 02

Algorithmic artwork that I find highly inspirational and intriguing are of  Herbert W. Franke, named ‘Lightforms’ (Lichtformen) and ‘Ultra Light'(Ultralicht). Franke is a German scientist and artist of the 1950s. His contributions to digital art is admirable as he pioneered the very first form of generative/algorithmic art. His first work in the mid 1950s was created through using an oscilloscope and a camera to generate patterns in groups of continuous lines. (Source: dada.compart-bremen.de/item/agent/188) The artwork ‘Lichtformen’ consists of a multitude of mathematically generated curves without any interruptions or kinks. The gradient has been created through mechanically generating vibrations.

The following image is the Dracula series created in 1970/71. It has been generated by computer graphics based on “Dragon curves”, which is a form of mathematical fractals. (Source: digitalartmuseum.org/franke/1953-1978a.html)

The creativity of the artist to pioneering incorporating scientific and mathematical algorithms into arts is very inspiring and his artworks continue to inspire many scientists and artists in the field.

Hannah Cai—Project 2—Variable Faces

/* Hannah Cai
hycai@andrew.cmu.edu
Section C
Project-02-Variable-Face
*/

function setup() {
    createCanvas(640,480);
    background(250);
    rectMode(CENTER);
    ellipseMode(CENTER);
    angleMode(DEGREES);

    // color variables
    bodyR = 251;
    bodyG = 176;
    bodyB = 64;
    finR = 190;
    finG = 30;
    finB = 45;
    scaleR = 255;
    scaleG = 215;
    scaleB = 86;

    size = 1;
    shear = 0;
    gillWeight = (5); 
    showWhiskers = (1);
    whiskerAngle = (0);
    whiskerLength = (33);
    finStyle = 0;
    scaleStyle = 0;
    scaleDot = 0;
    scaleDotSize = 0;
    specimenNumber = 8108;
}

function draw() {
    background(250);
    // label
    textFont('Courier New');
    textStyle(ITALIC);
    textAlign(CENTER);
    textSize(20);
    noStroke();
    fill(0);
    text('Arowana',320,357); //species name
    textSize(14);
    text('Osteoglossidae',320,375); //scientific name
    textSize(10);
    textFont('Courier');
    text('specimen #'+specimenNumber,320,395); //"specimen # x"

    translate(320,240); 
    scale(size);
    shearX(shear);
    translate(-320,-240);

    // tail fins
    fill(finR,finG,finB);
    noStroke();
        // tail
        translate(455,213);
        rotate(-45);
        rect(0,0,112,112,0,40,100,40);
        rotate(45);
        translate(-455,-213);
        // top fin
        ellipse(390,151,71,47);
        // bottom fins
        if (finStyle <= 0.5) { //fin style 1: two short bottom fins
        shearX(35);
        rect(180,270,117,48,0,200,30,200);
        shearX(-35);
        rect(267,274,54,41,0,50,5,50);
        } else { //fin style 2: one long bottom fin
        shearX(35);
        rect(150,270,180,48,0,200,30,200);
        shearX(-35);
        noFill();
        stroke(finR,finG,finB);
        strokeWeight(1);
        arc(266,270,150,70,150,260);
        }

    // whiskers
    if (showWhiskers >= 0.5) { 
    noStroke();
    fill(bodyR,bodyG,bodyB);
    translate(137,151);
    rotate(-whiskerAngle);
    ellipse(-1,-17,4,whiskerLength);
    rotate(whiskerAngle);
    translate(-137,-151);
    }

    // body
    noStroke();
    fill(bodyR,bodyG,bodyB);
    arc(245,150,219,218,0,180); //head
    rect(322,204.5,170,109,0,100,100,0); //tail

    // scales
    strokeWeight(1);
    if (scaleStyle >= 0.5) { //scale style 1: outlines
        noStroke();
        fill(scaleR,scaleG,scaleB);
    } else { //scale style 2: half-circles
        noFill();
        strokeWeight(1);
        stroke(scaleR,scaleG,scaleB);
    }
    arc(223,168,34,34,-90,90); //row 1
    arc(223,204,34,34,-90,90);
    arc(223,240,34,34,-90,90);
    arc(240,185,34,34,-90,90); //row 2
    arc(240,221,34,34,-90,90);
    arc(257,168,34,34,-90,90); //row 3
    arc(257,204,34,34,-90,90);
    arc(257,240,34,34,-90,90);
    arc(274,185,34,34,-90,90); //row 4
    arc(274,221,34,34,-90,90);
    arc(291,168,34,34,-90,90); //row 5
    arc(291,204,34,34,-90,90);
    arc(291,240,34,34,-90,90);
    arc(308,185,34,34,-90,90); //row 6
    arc(308,221,34,34,-90,90);
    arc(325,168,34,34,-90,90); //row 7
    arc(325,204,34,34,-90,90);
    arc(325,240,34,34,-90,90);
    arc(342,185,34,34,-90,90); //row 9
    arc(342,221,34,34,-90,90);
    arc(359,168,34,34,-90,90); //row 10
    arc(359,204,34,34,-90,90);
    arc(359,240,34,34,-90,90);
    arc(376,185,34,34,-90,90); //row 11
    arc(376,221,34,34,-90,90);
    arc(393,204,27,34,-90,90); //row 12

    //scale details
    if (scaleDot >= 0.5) {
    noStroke();
    fill(scaledotR,scaledotG,scaledotB)
    arc(223,168,scaleDotSize,scaleDotSize,-90,90); //row 1
    arc(223,204,scaleDotSize,scaleDotSize,-90,90);
    arc(223,240,scaleDotSize,scaleDotSize,-90,90);
    arc(240,185,scaleDotSize,scaleDotSize,-90,90); //row 2
    arc(240,221,scaleDotSize,scaleDotSize,-90,90);
    arc(257,168,scaleDotSize,scaleDotSize,-90,90); //row 3
    arc(257,204,scaleDotSize,scaleDotSize,-90,90);
    arc(257,240,scaleDotSize,scaleDotSize,-90,90);
    arc(274,185,scaleDotSize,scaleDotSize,-90,90); //row 4
    arc(274,221,scaleDotSize,scaleDotSize,-90,90);
    arc(291,168,scaleDotSize,scaleDotSize,-90,90); //row 5
    arc(291,204,scaleDotSize,scaleDotSize,-90,90);
    arc(291,240,scaleDotSize,scaleDotSize,-90,90);
    arc(308,185,scaleDotSize,scaleDotSize,-90,90); //row 6
    arc(308,221,scaleDotSize,scaleDotSize,-90,90);
    arc(325,168,scaleDotSize,scaleDotSize,-90,90); //row 7
    arc(325,204,scaleDotSize,scaleDotSize,-90,90);
    arc(325,240,scaleDotSize,scaleDotSize,-90,90);
    arc(342,185,scaleDotSize,scaleDotSize,-90,90); //row 9
    arc(342,221,scaleDotSize,scaleDotSize,-90,90);
    arc(359,168,scaleDotSize,scaleDotSize,-90,90); //row 10
    arc(359,204,scaleDotSize,scaleDotSize,-90,90);
    arc(359,240,scaleDotSize,scaleDotSize,-90,90);
    arc(376,185,scaleDotSize,scaleDotSize,-90,90); //row 11
    arc(376,221,scaleDotSize,scaleDotSize,-90,90);
    arc(393,204,scaleDotSize,scaleDotSize,-90,90); //row 12
    }

    // eyes
    noStroke();
    fill(255);
    ellipse(172,165,25,25); //whites
    fill(0);
    ellipse(172,165,21,21); //pupil

    // gills
    noFill();
    stroke(finR,finG,finB);
    strokeWeight(gillWeight);
    arc(179,192,69,69,-40,105);

    // mouth
    strokeWeight(1);
    arc(94,204,138,138,-50,-15);

    // gill fin
    strokeWeight(gillWeight);
    fill(finR,finG,finB);
    ellipse(240,228,67,20);
}


function mousePressed() {
    size = random(.5,1.2);
    shear = random(0,15); //horizontal stretch
    showWhiskers = random(0,1);
    finStyle = random(0,1);
    scaleStyle = random(0,1);
    scaleDot = random(0,1);
    scaleDotSize = random(0,30);
    // color variables
    bodyR = random(100,250);
    bodyG = random(100,250);
    bodyB = random(100,250);
    finR = bodyR - random(50,150);
    finG = bodyG - random(50,150);
    finB = bodyB - random(50,150);
    scaleR = bodyR + random(50,100);
    scaleG = bodyG + random(50,100);
    scaleB = bodyB + random(50,100);
    scaledotR = scaleR - random(30,50)
    scaledotG = scaleG - random(30,50)
    scaledotB = scaleB - random(30,50)

    gillWeight = random(1,5);
    whiskerAngle = random(0,90);
    whiskerLength = random(30,50);
    specimenNumber = random(0,9999);
    specimenNumber = round(specimenNumber); //rounds specimen# to whole number
}

real arowana look like this:

a closer look at the whiskers

initial sketches with ideas for variations

/////

some variations from the final code 

I wanted to take a more scientific approach to the idea of generated variations, so I decided to focus my project on variations of an animal species. I chose the arowana because it’s one of my favorite animals, and because I wanted to try and capture its distinctive shape. Overall, I had a lot of fun with this project!

Kevin Riordan Looking Outwards-02-Section C

This video is called Fractal Meditation, and was made by William Rood using algorithms in I think 2017, based on when it was published. The creator used 3d Mandelbrot sets to create the fractals, and the only thing I know about the algorithm is that it uses spherical coordinates. I suppose the movement and generation is related to the music that plays, as the colors and what appears seem to be somewhat influenced by the sound. I admire how long the video is, and how unique every single part actually is. Nothing ever actually repeats, even though everything changes so gradually. I think usually when something is this long, parts repeat especially when the sound is so constant, because this video is meant to be meditative. However, because of whatever algorithm is used, everything is so complex and unique that I do not think it would repeat even if the video was an hour long, which I admire alot.

Austin Treu – Looking Outwards-02

https://keiwan.itch.io/evolution

I found this evolution simulator by Keiwan on itch.io a while back. I find it fascinating how the algorithms are complicated enough to figure out how they can utilize almost any organization of muscles, bones and joints that they are given to evolve into a ‘creature’ more suitable for the given task. Algorithms such as these, that can take something so abstract and make it functional really highlight the fact that we may even be living in an ever-changing simulation ourselves. There is no way to say that there isn’t something that ‘developed’ our universe and let it run on its own. Many facets of our universe function very similarly to this evolution sim, although the ‘real’ things are much more complex than this. The algorithms involved in the sim are able to pick out the best uses for the creatures’ configurations and infuse those capabilities into the next generation from what I can tell. Over time, the creatures are able to develop more specified functions which continue to improve at the given task as long as the program is running, which sounds relatively similar to how we find ourselves evolving physically, technologically, and otherwise here on Earth.

Austin Treu – Project-02

atreu-proj02

//Austin Treu
//Section C
//atreu@andrew.cmu.edu
//Project-02

var eyeSize, irisSize, faceW, faceH, 
    backR = 75, backG = 220, backB = 200,
    faceR = 255, faceG = 255, faceB = 255,
    eyeR = 0, eyeG = 255, eyeB = 255,
    mouthW, mouthH, mouthX, mouthY,
    earW, earH, earShape = 0;
 
function setup() {
    createCanvas(480, 640);
    eyeSize = width/10, irisSize = eyeSize - 10;
    faceW = width/2, faceH = height/2;
    mouthX = width/2, mouthY = height/2 + eyeSize;
    mouthW = width/6, mouthH = height/8;
    earW = width/20, earH = height/10;
}
 
function draw() {
    background(backR,backG,backB);

    //draw face
    fill(faceR, faceG, faceB);
    ellipse(width / 2, height / 2, faceW,  faceH);

    //calculate and draw eyes
    var eyeLX = width/2 - faceW * 0.25;
    var eyeRX = width/2 + faceW * 0.25;
    fill(255);
    ellipse(eyeLX, height/2, eyeSize, eyeSize);
    ellipse(eyeRX, height/2, eyeSize, eyeSize);
    fill(eyeR, eyeG, eyeB);
    ellipse(eyeLX, height/2, irisSize, irisSize);
    ellipse(eyeRX, height/2, irisSize, irisSize);

    //draw mouth
    fill(255);
    arc(mouthX, mouthY, mouthW, mouthH, 0, PI, CHORD);

    //draw ears
    fill(faceR, faceG, faceB);
    if(earShape == 0){
        //circle ears
        ellipse(width/2-faceW/2-faceW/30, height/2, earW, earH);
        ellipse(width/2+faceW/2+faceW/30, height/2, earW, earH);
    }
    else if(earShape == 1){
        //triangle ears
        triangle(width/2-faceW/2, height/2-faceW/10, 
            width/2-faceW/2, height/2+faceW/10, 
            width/2-faceW/2-earW, height/2+earH);
        triangle(width/2+faceW/2, height/2-faceW/10, 
            width/2+faceW/2, height/2+faceW/10, 
            width/2+faceW/2+earW, height/2+earH);
    }
    else if(earShape == 2){
        //line ears
        line(width/2-faceW/2, height/2, 
            width/2-faceW/2-earW, height/2-earH);
        line(width/2+faceW/2, height/2, 
            width/2+faceW/2+earW, height/2-earH);
    }
    else{
        //do nothing - no ears
    }
}
 
function mousePressed() {
    //randomize face size
    faceW = random(width/4, width/2+width/4);
    faceH = random(height/4, height-height/8);

    //randomize eye sizes
    eyeSize = random(10, 30);
    irisSize = eyeSize - 10;

    //randomize background color
    backR = random(0, 255);
    backG = random(0, 255);
    backB = random(0, 255);

    //base face color off swapped back values
    faceR = backG;
    faceG = backB;
    faceB = backR;

    //base eye color off swapped back values
    eyeR = backB;
    eyeG = backR;
    eyeB = backG;

    //randomize mouth size 
    mouthW = faceW - random(20,100);
    mouthH = faceH/2 - random(0,30);

    //randomize ear size and shape
    earShape = int(random(0,4));
    earW = random(width/20, width/10);
    earH = random(height/20, height/5);
}

I decided to take an approach to this project looking at the faces as being more alien or robot than human, as it ultimately allowed me to add more interesting adjustments when it came to color and shapes. It provided me with some good practice in debugging the small things (e.g. semicolon in the wrong place… oops!).

Sharon Yang Project 02 Variable Face

Project2_Variable_face

/*Sharon Yang
Section C
junginny
Project-02-B
*/

//variables for the cooridinates and the size of the facial features, 
//the face and the eyes; 
var eyeWidth = 68;
var eyeHeight = 52;
var faceWidth = 360;
var faceHeight = 320;
var faceX = 232
var faceY = 320

//variables for colors, for the hair and eyebrows 
var fillR = 50;
var fillG = 41;
var fillB = 46;
function setup() {
    createCanvas(480, 640);
}
 
function draw() {
    background(254,230,240);

    //hair behind the face, the color variables used for the hair color
    //to be randomized 
    fill(fillR,fillG,fillB);
    rect(50,254,360,354);

   //face
    noStroke();
    fill(253,227,204);
    ellipse(faceX, faceY, faceWidth, faceHeight);

    //eyes, setting variables for the X coordinates of the left and
    //the right eyes using the width of the canvas and the face for
    //the eye positions to suit the face shape as it changes
    var LeftEyeX = width*0.48-faceWidth*0.2;
    var RightEyeX = width*0.48+faceWidth*0.2;
    fill(0);
    ellipse(LeftEyeX, faceHeight, eyeWidth, eyeHeight);
    ellipse(RightEyeX, faceHeight, eyeWidth, eyeHeight);

    //pupils, setting variables for the X coordinates of the left and
    //the right pupils using the left and right X coordinate variables
    //to remain at an appropriate position within the eyes as the size
    //the size and the shape of the eyes change
    var LeftPupilX = LeftEyeX*1.14;
    var RightPupilX = RightEyeX*1.07;
    fill(255);
    ellipse(LeftPupilX, faceHeight, 12, 12);
    ellipse(RightPupilX, faceHeight, 12, 12);

    //hair and bangs, the Y coordinates have been determined by the
    //face height as it varies 
    noStroke();
    fill(fillR,fillG,fillB);
    arc(86,faceHeight*0.9,140,200,HALF_PI,PI+HALF_PI);
    arc(32,faceHeight*1.2,140,200,PI+HALF_PI,HALF_PI);
    arc(84,faceHeight*1.65,140,200,HALF_PI,PI+HALF_PI);
    arc(382,faceHeight*0.87,140,200,PI+HALF_PI,HALF_PI);
    arc(440,faceHeight*1.24,140,200,HALF_PI,PI+HALF_PI);
    arc(382,faceHeight*1.65,140,200,PI+HALF_PI,HALF_PI);
    arc(236,faceHeight*0.7,408,280,PI,PI+PI,OPEN);
    arc(40,faceHeight*0.59,190,200,0,QUARTER_PI);
    arc(90,faceHeight*0.59,190,200,0,QUARTER_PI);
    arc(130,faceHeight*0.59,190,200,0,QUARTER_PI);
    arc(170,faceHeight*0.59,190,200,0,QUARTER_PI);
    arc(220,faceHeight*0.59,190,200,0,QUARTER_PI);
    arc(280,faceHeight*0.59,190,200,0,QUARTER_PI);
    arc(320,faceHeight*0.59,190,200,0,QUARTER_PI);

    //nose, the X and Y coordinates as well as the size determined 
    //by the face size as it varies
    noStroke();
    stroke(223,197,168);
    strokeWeight(4);
    line(faceWidth*0.67,faceHeight*1.07,faceWidth*0.70,faceHeight*1.14);
    line(faceWidth*0.70,faceHeight*1.14,faceHeight*0.72,faceHeight*1.16);

    //brows, setting variables for the height of the brows - the distance
    //from the eyes
    var browHeight = 274

    noFill();
    //the color variables used to randomize the colors of the brows
    stroke(fillR, fillG, fillB);
    strokeWeight(9);
    beginShape();
    //the position of the brows determined by the position and the size of the 
    //eyes
    curveVertex(LeftEyeX-eyeWidth/2-4, browHeight+12);
    curveVertex(LeftEyeX-eyeWidth/2-4, browHeight+12);
    curveVertex(LeftEyeX-15, browHeight);
    curveVertex(LeftEyeX+15, browHeight);
    curveVertex(LeftEyeX+eyeWidth/2+4, browHeight+12);
    curveVertex(LeftEyeX+eyeWidth/2+4, browHeight+12);
    endShape();

    noFill();
    stroke(fillR, fillG, fillB);
    strokeWeight(9);
    beginShape();
    curveVertex(RightEyeX-eyeWidth/2-4, browHeight+12);
    curveVertex(RightEyeX-eyeWidth/2-4, browHeight+12);
    curveVertex(RightEyeX-15, browHeight);
    curveVertex(RightEyeX+15, browHeight);
    curveVertex(RightEyeX+eyeWidth/2+4, browHeight+12);
    curveVertex(RightEyeX+eyeWidth/2+4, browHeight+12);
    endShape();
    
    //mouth, setting variables for the berzier point function
    //determining the position of the mouth in relative to the face
    //size, the edges of the mouth are assigned values for it to
    //be randomized and change in their positions
    noFill();
    stroke(237,34,93);
    strokeWeight(7);
    var x1 = 170,
    x2 = faceWidth*0.6,
    x3 = faceWidth*0.7,
    x4 = 300;
    var y1 = 410,
    y2 = faceHeight*1.35,
    y3 = faceHeight*1.37,
    y4 = 410;
    bezier(x1, y1, x2, y2, x3, y3, x4, y4);

    //ears, setting variable for the Y coordinate of the ears for
    //for the position of the earrings, the position of the ears 
    //determined by the face size
    var earY = faceHeight+20
    fill(253,227,204);
    noStroke();
    arc(faceX - faceWidth/3,earY,100,100,HALF_PI,PI+HALF_PI);
    arc(faceX + faceWidth/3,earY,100,100,PI+HALF_PI,HALF_PI);

    //earrings, the position determined by the position of the ears
    //which varies as the face size changes 
    fill(255);
    ellipse(faceX - faceWidth/3-20,earY+30,14,14);
    ellipse(faceX + faceWidth/3+20,earY+30,14,14);

    //neck
    noStroke();
    fill(253,227,204);
    rect(176,460,120,100);
    fill(253,227,204);
    ellipse(295,591,127,100);

    //shoulders
    fill(5,57,111);
    rect(46,520,400,200,80);

    //v-neck on the shirt
    fill(253,227,204);
    noStroke();
    triangle(230,600,176,520,296,520);
    stroke(255);
    strokeWeight(13);
    line(176,520,230,600);
    line(230,600,296,520);
}

//when the user presses the mouse
//the values of the variables are randomized and reassigned
//varying the size of the face and the eyes, and the positions
//of the brows, and the colors of the hair and the brows
function mousePressed() {
    faceWidth = random(340, 380);
    faceHeight = random(300,340);
    eyeWidth = random(60,80);
    eyeHeight = random(24,66);
    browArc = random(5, 50);
    browHeight = random(246,340);
    browHeight = constrain(browHeight,faceHeight*0.9+20,faceHeight+eyeHeight/2+10);
    x1 = random(100,180);
    y1 = random(380,600);
    x4 = random(270,340);
    y4 = random(380,600);
    fillR = random(20,80);
    fillG = random(10,70);
    fillB = random(16,76);
}

Creating an animation was fun yet quite complex requiring to use many variables and equations instead of the usual coordinates. It really helped me understand setting the variables as well as the random functions. I also had to learn other functions including the curve vertex and the berzier point as using ellipses and arcs limited creating certain motions.