/* mouse_edited.pde Edited by Justin Hsia (orig. Larry Synder) Example code that draws a mouse using a parameterized function. In lecture: added row5() to draw a row of colored mice. */ void setup() { size(500, 500); background(255); } void draw() { //mouse(100,30,color(50)); //mouse(200,60,color(200)); row5(100,100, color(0,0,255)); } // draw 5 mice in a row with ears overlapping. // the middle mouse should be red, the rest should be the same color. void row5(int rowX, int rowY, color rowC) { int sp = 60; // spacing of the mice mouse(rowX,rowY,rowC); // mouse 1 mouse(rowX+sp,rowY,rowC); // mouse 2 mouse(rowX+2*sp,rowY,color(255,0,0)); // mouse 3 (red) mouse(rowX+3*sp,rowY,rowC); // mouse 4 mouse(rowX+4*sp,rowY,rowC); // mouse 5 } // draw mouse of color c at (x,y) void mouse(int x, int y, color c) { noStroke(); fill(c); // caller-specified color ellipse(50+x, 50+y, 50, 50); // head ellipse(25+x, 30+y, 30, 30); // right ear (left on screen) ellipse(75+x, 30+y, 30, 30); // left ear (right on screen) fill(0); // black ellipse(40+x, 44+y, 10, 10); // right eye (left on screen) ellipse(60+x, 44+y, 10, 10); // left eye (right on screen) stroke(0); // black line(20+x, 50+y, 48+x, 60+y); // upper-right whisker line(80+x, 50+y, 52+x, 60+y); // upper-left whisker line(25+x, 70+y, 48+x, 60+y); // lower-right whisker line(75+x, 70+y, 52+x, 60+y); // lower-left whisker }