Skip to content

Instantly share code, notes, and snippets.

@brittanylynnjustice
Created January 23, 2015 23:22
Show Gist options
  • Save brittanylynnjustice/2956fa48462d01b20054 to your computer and use it in GitHub Desktop.
Save brittanylynnjustice/2956fa48462d01b20054 to your computer and use it in GitHub Desktop.
generative face
<head>
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.3.16/p5.js"></script>
<script language="javascript" type="text/javascript" src="http://ekeneijeoma.github.io/ijeoma.js/build/ijeoma.js"></script>
<script language="javascript" type="text/javascript" src="http://ekeneijeoma.github.io/p5.ijeoma.js/build/p5.ijeoma.js"></script>
</head>
<body>
</body>
function setup() {
createCanvas(800,600)
brow1y = random(220,240);
brow2y = random(220,240);
eye1c = color(random(255),245,155);
}
function draw(){
background(0,0,0);
smooth();
hair();
facebase();
bangs();
earrings();
whiteeyes();
mouth();
nose();
neck();
cheekblush();
eyegloss();
breakinbangs();
eyebrows();
iris();
}
function keyPressed() {
//brow1y = random(220,240);
//brow2y = random(220,240);
//eye1c = color(random(255),245,155);
tweenColor = createTween('eye1c',color(random(255),245,155),40)
.add('brow1y',random(220,240),100)
.add('brow2y',random(220,240),100)
.play();
}
function hair() {
/*hair*/
fill(0,210,210);
noStroke();
ellipse(415,300,450,540);
}
function facebase() {
/*face base*/
fill(255,229,204);
ellipse(415,300,315,430);
ellipse(250,300,40,100);
ellipse(580,300,40,100);
}
function bangs(){
/*bangs*/
fill(0,210,210);
ellipse(415,160,270,200);
}
function earrings() {
/*earrings*/
fill(255,128,0);
ellipse(250,340,10,10);
ellipse(580,340,10,10);
}
function whiteeyes() {
/*white eyes*/
fill(255);
ellipse(340,300,100,100);
ellipse(490,300,100,100);
}
function iris() {
/*iris*/
fill(eye1c);
ellipse(340,300,80,80);
ellipse(490,300,80,80);}
/*iris*/
function mouth() {
/*mouth*/
fill(255,204,204);
ellipse(420,440,20,20);
stroke(0);
fill(0);
}
function nose() {
/*nose*/
line(405, 395, 405, 405);
line(430, 395, 430, 405);
}
function neck() {
/*neck*/
noStroke();
fill(255,229,204);
rect(365, 480, 100, 90);
}
function cheekblush() {
/*cheek blush*/
fill(255,204,204);
ellipse(500,370,50,10);
ellipse(335,370,50,10);
}
function eyegloss() {
/*eye gloss*/
fill(255);
ellipse(320,280,10,10);
ellipse(510,280,10,10);
}
function eyebrows() {
/*eyebrows*/
fill(61,43,43);
rect(290,brow1y,80,10);
rect(460,brow2y,80,10);
}
function breakinbangs() {
/*break in bangs*/
fill(255,229,204);
triangle(390, 275, 418, 220, 446, 275);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment