xxxxxxxxxx
119
var BASE;
var s;
function setup() {
BASE = 30;// random(38,58);
createCanvas(BASE*10, BASE*10);
strokeCap(SQUARE);
}
function draw() {
//BASE += random(-.1,.1);
background(200);
noStroke();
translate(width/2,height/2);
fill(255);
ellipse(0,0,BASE*8,BASE*8);
fill(0);
push();
var f1 = map(mouseX,0,width, -5,5).toFixed(3);;
var f2 = map(mouseY,0,height, -5,5).toFixed(3);
var s;
//var s = "bigEye("+f1+","+f2+");";
s = "bigEye(1.835,-1.239);";
eval(s);
s = "nose(-1.867,0.824)";
eval(s);
//s = "smallEye("+f1+","+f2+")";
s = "smallEye(-2.037,-0.947)";
eval(s);
s = "mouth()";
eval(s);
s = "crack("+f1+","+(f2)+");"
eval(s);
}
function mousePressed(){
noLoop();
}
function crack(a,b){
strokeWeight(BASE/5);
stroke(0);
noFill();
push();
// print (a+":"+b);
translate(BASE*.137,BASE*.44);
beginShape();
push();
vertex(BASE*-3.392,BASE*-4.471);
vertex(BASE*-1.704,BASE*-3.673);
vertex(BASE*-1.367,BASE*-3.895);
vertex(BASE*-1.316,BASE*-3.14);
vertex(BASE*-0.497,BASE*-3.36);
vertex(BASE*0.084,BASE*-2.65);
//vertex(BASE*-0.894,BASE*-2.657);
vertex(BASE*-0.497,BASE*-3.36);
vertex(BASE*0.143,BASE*-3.791);
s = "vertex(BASE*"+a+",BASE*"+b+");";
// eval(s);
// print(s);
endShape();
pop();
noLoop();
saveCanvas("skull.png");
}
function mouth(){
strokeWeight(BASE/2.8);
stroke(0);
line(-BASE*4,BASE*2,BASE*4,BASE*2);
line(0,BASE*1.35,0,BASE*2.65);
line(-BASE,BASE*1.45,-BASE,BASE*2.55);
line(-2*BASE,BASE*1.4,-2*BASE,BASE*2.55);
line(BASE,BASE*1.45,BASE,BASE*2.65);
line(2*BASE,BASE*1.45,2*BASE,BASE*2.55);
}
function nose(a,b){
push();
push();
rotate(a);
ellipse(0,BASE/4,BASE*2,BASE);
pop();
push();
rotate(-a);
ellipse(0,+BASE/4,BASE*2,BASE);
pop();
}
function bigEye(f1,f2){
var g = 2.5;
push();
translate(f1* BASE,f2*BASE);
rotate(0.1);
ellipse(0,0,BASE*g,BASE*g*1.3);
pop();
}
function smallEye(f1,f2){
var g = 2.2;
push();
translate(f1* BASE,f2*BASE);
rotate(0.1);
ellipse(0,0,BASE*g*1.1,BASE*g);
pop();
}