//a Processing program to draw a hedgehog - written for Cameron S. //by Zoƫ J. Wood August 2011 //Each time the mouse is clicked the hedgehog gets smaller //The hedgehog is drawn using the parametric equation for a circle (with alternating radius values) float scale_factor; void setup() { size(500, 500); background(255,255,255); smooth(); scale_factor = 3.5; } void draw_hedgehog() { float rad, cx, cy, center_x, center_y; float in_rad; center_x = center_y = cx = cy =0; rad = 40; in_rad = 20; strokeWeight(1.4); stroke(0, 0, 0); //draw the head/body of the hedgehog fill(227, 211, 185); beginShape(); vertex(cx, cy); vertex(cx+(.7*rad), cy+(rad/1.3)); vertex(cx-(1.4*rad), cy+(rad/1.4)); vertex(cx-(1.3*rad), cy+(rad/1.8)); endShape(CLOSE); //draw the feet fill(83, 59, 21); beginShape(); vertex(cx+13-(rad/1.2), cy+(rad/1.3)); vertex(cx+13-(rad/1), cy+(rad/1.1)); vertex(cx+13-(rad/1.5), cy+(rad/1.1)); vertex(cx+13-(rad/1.4), cy+(rad/1.3)); endShape(CLOSE); beginShape(); vertex(cx+40-(rad/1.2), cy+(rad/1.3)); vertex(cx+40-(rad/1), cy+(rad/1.1)); vertex(cx+40-(rad/1.5), cy+(rad/1.1)); vertex(cx+40-(rad/1.4), cy+(rad/1.3)); endShape(CLOSE); //draw eyes and nose fill(0, 0, 0); ellipse(cx-(1.4*rad), cy+(rad/1.8), 5, 5); ellipse(cx-(rad/1.2), cy+(rad/2), 9, 7); //draw spikey back of hedgehog strokeWeight(1); fill(83, 59, 21); beginShape(); for (float t=0; t<2*PI; t= t+0.21) { cx =rad*cos(t); cy = rad*sin(t); vertex(center_x+cx, center_y+cy); cx = in_rad*cos(t); cy = in_rad*sin(t); vertex(center_x+cx, center_y+cy); } endShape(CLOSE); strokeWeight(1); fill(93, 69, 31); rad = 29; in_rad = 9; beginShape(); for (float t=.13; t<2*PI; t= t+0.3) { cx =rad*cos(t); cy = rad*sin(t); vertex(center_x+cx, center_y+cy); cx = in_rad*cos(t); cy = in_rad*sin(t); vertex(center_x+cx, center_y+cy); } endShape(CLOSE); } void draw() { //set the background color background(185, 227, 222); //draw the hedgehog in the center and possibly scaled smaller pushMatrix(); translate((height/2), (height/2)); scale(scale_factor); draw_hedgehog(); popMatrix(); //saveFrame("Hedgehog.jpg"); } void mousePressed() { //each time the mouse is pressed the hedgehog gets smaller if (scale_factor > .1) { scale_factor = scale_factor-.2; } else { scale_factor = 3.5; } }