/* Scalable Smiley Face Processing Sketch by Michael Goldwasser */ // customizable parameters float facePct = 0.7; // face diameter 70% of canvas float eyePct = 0.2; // eye width is 20% of face width float eyeGapPct = 0.5; // gap between eyes equal 50% of single eye width color faceColor = color(255,255,0); // yellow color irisColor = color(56,183,240); // light blue color mouthColor = color(243,23,56); String msg = "Have a nice day!"; // let's get started size(800, 800); background(255); // general face fill(faceColor); float faceWidth = facePct * width; ellipse(0.5*width, 0.5*height, faceWidth, faceWidth); // eyes float eyeY = 0.5 * height - 0.15 * faceWidth; // height of center of eye float eyeWidth = width*facePct*eyePct; float eyeGap = eyeWidth * eyeGapPct; float leftX = 0.5*(width - eyeGap - eyeWidth); float rightX = 0.5*(width + eyeGap + eyeWidth); fill(255); ellipse(leftX, eyeY, eyeWidth, eyeWidth); ellipse(rightX, eyeY, eyeWidth, eyeWidth); noStroke(); fill(irisColor); ellipse(leftX, eyeY, 0.6*eyeWidth, 0.6*eyeWidth); ellipse(rightX, eyeY, 0.6*eyeWidth, 0.6*eyeWidth); fill(0); ellipse(leftX, eyeY, 0.35*eyeWidth, 0.35*eyeWidth); ellipse(rightX, eyeY, 0.35*eyeWidth, 0.35*eyeWidth); // mouth noFill(); stroke(mouthColor); strokeWeight(0.05*faceWidth); arc(0.5*width, 0.5*width, 0.6*faceWidth, 0.6*faceWidth, 0.25*PI, 0.75*PI); // add a friendly message textSize(12); float temp = textWidth(msg); // this is width if at 12pt font textSize(12*width*facePct/temp); textAlign(CENTER, TOP); fill(0); text(msg, 0.5*width, 0.5*width + 0.5*faceWidth);