|
///PS1 SELF PORTRAIT CARLGORDON 300308407 |
|
var a = 0; //variable to be controlled |
|
var b = 0; //variable to be controlled |
|
var c = 0; //variable to be controlled |
|
var c2 = 0; //variable to be controlled |
|
var d = 0; //variable to be controlled |
|
var e = 0; //variable to be controlled |
|
var f = 0; //variable to be controlled |
|
var g = 0; //variable to be controlled |
|
var h = 0; //variable to be controlled |
|
var i = 0; //variable to be controlled |
|
|
|
var demo =0; |
|
var random1 =0; |
|
var random2 =0; |
|
var random3 =0; |
|
var random4 =0; |
|
var random5 =0; |
|
var random6 =0; |
|
var random7 =0; |
|
var random8 =0; |
|
var random9 =0; |
|
var random10 =0; |
|
|
|
|
|
function setup () { |
|
|
|
|
|
createCanvas(960, 520); |
|
background(255); |
|
|
|
} |
|
|
|
function draw(){ |
|
background(255); |
|
for($i=0; $i<=width; $i+=width/5){ |
|
stroke(200); |
|
strokeWeight(1); |
|
line($i,10,$i,height-10); |
|
|
|
} |
|
for($iy=height/3; $iy<=height; $iy+=height/3){ |
|
line(10,$iy,width-10,$iy); |
|
} |
|
//text |
|
/* |
|
fill(0); |
|
text(mouseX,100,100, mouseX); |
|
text(mouseY,100,130, mouseY); |
|
text(demo,100,180, mouseY); |
|
text(random1,100,200, mouseY); |
|
*/ |
|
|
|
|
|
//AVATARS |
|
//top row |
|
drawFace(0-width/5,-height/3+10,random2,random5,random9,random10,random4); |
|
drawFace(0-(width/5*2),-height/3+10,random9,random1,random10,random9,random2); |
|
drawFace(0,-height/3+10,random3,random3,random7,random4,random5); |
|
drawFace(0+width/5,-height/3+10,random6,random3,random1,random3,random6); |
|
drawFace(0+(width/5*2),-height/3+10,random7,random5,random3,random2,random10); |
|
//middle row |
|
drawFace(0-width/5,10,random2,random2,random8,random6,random5); |
|
drawFace(0-(width/5*2),10,random6,random9,random3,random2,random9); |
|
drawFace(0,10,random7,random7,random3,random9,random3); |
|
drawFace(0+width/5,10,random3,random10,random1,random6,random5); |
|
drawFace(0+(width/5*2),10,random6,random3,random3,random2,random9); |
|
//bottom row |
|
drawFace(0-width/5,height/3+20,random7,random9,random5,random3,random6); |
|
drawFace(0-(width/5*2),height/3+20,random1,random4,random6,random2,random10); |
|
drawFace(0,height/3+20,random3,random7,random3,random4,random5); |
|
drawFace(0+width/5,height/3+20,random2,random10,random1,random7,random6); |
|
drawFace(0+(width/5*2),height/3+20,random9,random7,random3,random10,random1); |
|
//END AVATARS |
|
|
|
} |
|
|
|
//////DRAW FACE |
|
function drawFace (x1,y1,Skin,Hair,rand,rand2,rand3) { |
|
$CanvasPosX=x1; |
|
$CanvasPosY=y1; |
|
|
|
if(mouseY<=200){ |
|
mouseY=200; |
|
} |
|
if(mouseX>=570){ |
|
mouseX=570; |
|
} |
|
//shirt color variables |
|
|
|
|
|
/////////DRAW FACE FUNCTION |
|
|
|
if (mouseIsPressed) { |
|
fill(255); |
|
random1=focusedRandom(0,1,2); |
|
random2=focusedRandom(0,1,5); |
|
random3=focusedRandom(0,1,3); |
|
random4=focusedRandom(0,1,0); |
|
random5=focusedRandom(0,1,8); |
|
random6=focusedRandom(0,1,3); |
|
random7=focusedRandom(0,1,2); |
|
random8=focusedRandom(0,1,2); |
|
random9=focusedRandom(0,1,4); |
|
random10=focusedRandom(0,1,7); |
|
} |
|
else { |
|
} |
|
|
|
|
|
// |
|
|
|
//DECLARE SOME GLOBALS |
|
$skincolor="rgb(214,195,168)"; |
|
$skincolor2="rgb(200,180,144)"; |
|
$shirtcolor="rgb(220,220,220)"; |
|
// |
|
/////////////////////// |
|
from2 = color(214,195,168, 1 * 255); |
|
to2 = color(80, 66, 54, 1 * 255); |
|
// |
|
fromDark = color(194,175,148, 1 * 255); |
|
toDark = color(70, 56, 44, 1 * 255); |
|
// |
|
newSkin = lerpColor(from2, to2, Skin); |
|
newSkin2 = lerpColor(fromDark, toDark, Skin); |
|
// |
|
blonde = color(246,237,162, 1 * 255); |
|
black = color(47, 41, 32, 1 * 255); |
|
newHair = lerpColor(blonde, black, Hair); |
|
//BODY |
|
stroke(100); |
|
strokeWeight(2); |
|
|
|
|
|
/////////////////// |
|
//HEAD + FACE |
|
strokeWeight(10); |
|
stroke(newSkin2); |
|
fill(newSkin); |
|
/////////////////// |
|
//position in square |
|
//translate(x1,y1); |
|
//HEAD |
|
$headwidth=130+lerp(-20,25,rand3); |
|
$headheight=140+lerp(0,12,rand2); |
|
ellipse(width/2+x1,height/2-mouseY/100+y1,$headwidth,$headheight-mouseY/80); |
|
|
|
|
|
|
|
// TOP OF HEAD HAIR |
|
beginShape(); |
|
fill(newHair); |
|
noStroke(); |
|
vertex(431+x1, 180+y1); |
|
vertex(430+x1, 200+y1); |
|
vertex(525+x1, 200+y1); |
|
vertex(525+x1, 190)+y1; |
|
vertex(525+x1, 170-lerp(-0,20,h/100)+y1); |
|
vertex(width/2+x1, 150+lerp(-0,20,rand)+y1); |
|
vertex(460+x1, 170-lerp(-0,20,rand)+y1); |
|
endShape(); |
|
strokeWeight(8); |
|
stroke(newHair); |
|
|
|
// |
|
line(530+lerp(0,20,rand3)+x1,228+y1, 520+x1,190+y1); |
|
line(425-lerp(0,20,rand3)+x1,228+y1, 440+x1,190+y1); |
|
//ellipse(mouseX, mouseY, 80, 80); |
|
|
|
//EARS |
|
|
|
fill(newSkin); |
|
$earPosY=lerp(0,20,rand)+y1; |
|
$earposXL=width/2.3+x1; |
|
$earposXR=width/1.77+x1; |
|
$earwidth=25+lerp(-5,10,rand); |
|
$earheight=35+lerp(-2,5,rand); |
|
noStroke(); |
|
strokeWeight(6); |
|
//left |
|
ellipse($earposXL-lerp(0,15,rand3),height/2.3+$earPosY,$earwidth,$earheight); |
|
//right |
|
ellipse($earposXR+lerp(0,15,rand3),height/2.3+$earPosY,$earwidth,$earheight); |
|
//EYE COLOR |
|
|
|
from = color(10, 255, 0, 0.5 * 255); |
|
to = color(0, 0, 255, 0.5 * 255); |
|
c1 = lerpColor(from, to, rand3); |
|
|
|
//EYES |
|
$lposXL=width/2.1+x1; |
|
$lposXR=width/1.9+x1; |
|
//EYEPOS |
|
$eyePosY=lerp(0,35,rand)+y1; |
|
$eyeposX=lerp(-10,10,rand3); |
|
$eyewidth=lerp(20,35,rand2); |
|
$eyeheight=lerp(6,27,rand2)+(mouseY/80); |
|
stroke(newSkin2); |
|
fill(255); |
|
//EYEBALLS |
|
ellipse($lposXL+($eyeposX),height/2.4+$eyePosY,$eyewidth,$eyeheight); |
|
//r |
|
ellipse($lposXR-($eyeposX),height/2.4+$eyePosY,$eyewidth,$eyeheight); |
|
|
|
fill(c1); |
|
noStroke(); |
|
// |
|
$iriswidth=lerp(5,20,rand2); |
|
$irisheight=lerp(5,20,rand2); |
|
//left |
|
ellipse($lposXL+($eyeposX)+mouseX/100,height/2.4+$eyePosY,$iriswidth,$irisheight); |
|
//right |
|
ellipse($lposXR-($eyeposX)-mouseX/100,height/2.4+$eyePosY,$iriswidth,$irisheight); |
|
//pupils |
|
fill(60); |
|
noStroke(); |
|
//left pupil |
|
|
|
|
|
$lposY=height/2.4; |
|
$pupilwidth=lerp(5,12,rand2); |
|
$pupilheight=lerp(5,12,rand2); |
|
$glarecolor = color(255, 255, 255, 0.8 * 255); |
|
//left pupil |
|
ellipse($lposXL+($eyeposX)+mouseX/100,$lposY-mouseY/80+$eyePosY,$pupilwidth,$pupilheight); |
|
//right pupil |
|
ellipse($lposXR-($eyeposX)-mouseX/100,height/2.4-mouseY/80+$eyePosY,$pupilwidth,$pupilheight); |
|
//glare |
|
fill($glarecolor); |
|
noStroke(); |
|
//glare |
|
strokeWeight(lerp(4,10,rand3)); |
|
/////////////////// |
|
//BROWS |
|
$browPosY=lerp(0,20,rand)+y1; |
|
stroke(newHair) |
|
//l |
|
line(444+x1,202+mouseY/80+$browPosY,470+x1,208-mouseY/80+$browPosY); |
|
//r |
|
line(488+x1,208-mouseY/80+$browPosY,514+x1,200+mouseY/80+$browPosY); |
|
//line(500,190-mouseY/80,571,185+mouseY/80); |
|
stroke(215,214,179); |
|
strokeWeight(4); |
|
stroke(215,214,179); |
|
/////////////////// |
|
//MOUTH |
|
$mouthPosY=lerp(0,20,rand)+y1; |
|
$mouthwidth=45; |
|
$mouthheight=20; |
|
stroke(newSkin2); |
|
fill(100,0,0); |
|
ellipse(width/2+x1,height/1.8-mouseY/80+$mouthPosY,$mouthwidth,$mouthheight); |
|
//MOUTH DETAIL |
|
//teeth |
|
strokeWeight(3); |
|
stroke(255); |
|
line(460+x1,280+mouseY/110+$mouthPosY,500+x1,280+mouseY/110+$mouthPosY); |
|
// |
|
stroke(100,0,0); |
|
strokeWeight(lerp(3,6,rand3)); |
|
//top |
|
line(460+x1,280+mouseY/80+$mouthPosY,width/2-4+x1,280-mouseY/100+$mouthPosY); |
|
line(500+x1,280+mouseY/80+$mouthPosY,width/2+4+x1,280-mouseY/100+$mouthPosY); |
|
//l |
|
line(460+x1,280+mouseY/80+$mouthPosY,width/2+x1,296-mouseY/100+$mouthPosY); |
|
//r |
|
line(500+x1,280+mouseY/80+$mouthPosY,width/2+x1,296-mouseY/100+$mouthPosY); |
|
|
|
|
|
/////// |
|
//+RANDOMIZE FEATURE |
|
rmin_L= -20; |
|
rmax_L=0; |
|
//R |
|
rmin_R= 0; |
|
rmax_R=20; |
|
|
|
/////////////////// |
|
|
|
//NOSE |
|
//nose position on face |
|
// |
|
noStroke(); |
|
//nose bridge |
|
fill(newSkin2); |
|
beginShape(); |
|
//bridge bottom |
|
vertex(width/2+10+x1,height/2+y1+14+lerp(0,20,rand)); |
|
vertex(width/2-10+x1,height/2+y1+14+lerp(0,20,rand)); |
|
//bridge top |
|
vertex(width/2-5+x1,height/2.7+y1+50+lerp(0,20,rand)); |
|
vertex(width/2+5+x1, height/2.7+y1+50+lerp(0,20,rand)); |
|
endShape(); |
|
ellipse(width/2+x1,height/2.50+y1+30+lerp(0,20,rand),lerp(10,30,rand),lerp(55,70,rand)); |
|
//nose tip |
|
//nostrils |
|
$noswidth=16+lerp(0,10,rand); |
|
$nosheight=12-mouseY/80; |
|
//LEFT |
|
ellipse(width/2.02+x1,height/2.2+y1+30+lerp(0,20,rand),$noswidth,$nosheight); |
|
//RIGHT |
|
ellipse(width/1.98+x1,height/2.2+y1+30+lerp(0,20,rand),$noswidth,$nosheight); |
|
//NOSE DETAIL |
|
fill(0); |
|
/* SHOW ME THE RANDOM VALUES GENERATED |
|
text(random1,20,10); |
|
text(random2,20,20); |
|
text(random3,20,30); |
|
text(random4,20,40); |
|
text(random5,20,50); |
|
text(random6,20,60); |
|
text(random7,20,70); |
|
text(random8,20,80); |
|
text(random9,20,90); |
|
*/ |
|
noStroke(); |
|
} |
|
function myFunction() { |
|
document.getElementById("demo").innerHTML = Math.random(); |
|
demo=Math.random(); |
|
|
|
|
|
} |
|
function keyTyped() { |
|
if (key == '!') { |
|
saveBlocksImages(); |
|
} |
|
} |