void setup() { size(500, 500); } Tiger tiger = new Tiger(); void draw() { smooth(); background(200); tiger.draw(); } float extraAng; void mouseMoved() { extraAng = map(mouseX, 0, 500, -.2, .2); } color ORANGE = color(255, 128, 0); color WHITE = color(255); color BLACK = color(0); color GREEN = color(0,128,0); color PINK = color(255,200,200); float BASE = 100; class Tiger { void draw() { pushMatrix(); translate(250, 250); rotate(map(mouseY, 0, 500, -.3, .3)); noStroke(); drawLegs(); drawTail(); drawBody(); drawStripes(false); drawHead(); popMatrix(); } void drawHead(){ pushMatrix(); fill(ORANGE); translate(BASE*1.3,0); rotate(map(mouseX, 0, 500, -.3, .3)); triangle(BASE*.375,0,-BASE*.375,0,-BASE*.45,-BASE*.712); triangle(-BASE*.375,0,BASE*.375,0,BASE*.45,-BASE*.712); ellipse(0,0,BASE,BASE); drawStripes(true); fill(GREEN); //eye iris ellipse(-BASE*.2,-BASE*.1,BASE*.2,BASE*.2); ellipse(BASE*.2,-BASE*.1,BASE*.2,BASE*.2); fill(BLACK); //eye pupil ellipse(-BASE*.2,-BASE*.1,BASE*.1,BASE*.2); ellipse(BASE*.2,-BASE*.1,BASE*.1,BASE*.2); fill(PINK); triangle(-BASE*.1,0,BASE*.1,0,0,BASE*.1); strokeWeight(2); stroke(BLACK); line(-BASE*.2,-BASE*.25,-BASE*.05,-BASE*.1); line(BASE*.2,-BASE*.25,BASE*.05,-BASE*.1); fill(BLACK); pushMatrix(); translate(0,BASE*.3); ellipse(0,0,BASE*.5,BASE*.25); fill(WHITE); noStroke(); triangle(-BASE*.15, -BASE*.15,-BASE*.07,-BASE*.15,-BASE*.1,BASE*.05); triangle(BASE*.15, -BASE*.15,BASE*.07,-BASE*.15,BASE*.1,BASE*.05); triangle(-BASE*.1, BASE*.15,-BASE*.02,BASE*.15,-BASE*.05,-BASE*0); triangle(BASE*.1, BASE*.15,BASE*.02,BASE*.15,BASE*.05,-BASE*0); popMatrix(); popMatrix(); } void drawBody() { fill(ORANGE); ellipse(0, 0, BASE*2, BASE); fill(WHITE); ellipse(0, BASE/4, BASE*3/2, BASE*.6); } void drawTail() { drawLeg(-BASE*.8, -BASE*.1, PI/2-extraAng*3, true); } void drawLegs() { drawLeg(-BASE*.8, 0, -extraAng*4, false); drawLeg(-BASE*.6, BASE*.2, -extraAng*3, false); drawLeg(BASE*.8, 0, extraAng*4, false); drawLeg(BASE*.6, BASE*.2, extraAng*3, false); } void drawLeg(float x, float y, float initAng, boolean isTail) { fill(ORANGE); pushMatrix(); translate(x, y); rotate(initAng); float LENGTH = BASE; if (isTail) LENGTH *= 1.25; rect( -BASE * .1, 0, BASE * .2, LENGTH); if ( isTail) { // fill(BLACK); ellipse(0, LENGTH, BASE*.2, BASE*.2); int TAILSTRIPECOUNT = 4; // drawStripe( ax,ay, LENGTH * .15,-PI/2); for (int i = 0; i < TAILSTRIPECOUNT; i++) { float m = map(i, -1, TAILSTRIPECOUNT, 0, 2); drawStraightStripe(-LENGTH*.11, m * LENGTH *.6 , LENGTH * .15, -PI/2); } } else { drawFoot(0, BASE); } popMatrix(); } void drawFoot(float x, float y) { pushMatrix(); translate(x, y); fill(WHITE); ellipse(0, 0, BASE*.25, BASE*.25); drawClaws(); popMatrix(); } void drawClaws() { int CLAWCOUNT = 3; pushMatrix();// rotate(extraAng); for (int i = 0; i < CLAWCOUNT; i++) { float m = map(i, -1, CLAWCOUNT, -1, 1); drawStripe(m * BASE*.1, .3 * BASE * .1-abs(m), BASE * .15, map(m, 1, -1, -PI/3, PI/3 )); } popMatrix(); } void drawStripes(boolean isHead) { int STRIPECOUNT = isHead?10:6; pushMatrix(); rotate(extraAng); for (int i = isHead?1:0; i < STRIPECOUNT -(isHead?1:0); i++) { float m = map(i, -1, STRIPECOUNT, -1, 1); drawStripe(m * BASE*.55, -.3 * BASE * 1-abs(m), BASE * (isHead?.2:.5), map(m, -1, 1, isHead?-PI:-PI/3, isHead?PI:PI/3 )); } popMatrix(); } void drawStripe(float x, float y, float sz, float angle) { fill(BLACK); pushMatrix(); translate(x, y); rotate(angle); triangle( x-sz/6, y, x + sz/6, y, x, y + sz ); popMatrix(); } void drawStraightStripe(float x, float y, float sz, float angle) { fill(BLACK); pushMatrix(); translate(x, y); rotate(-PI/2); triangle( 0-sz/6, 0, sz/6, 0, 0, 0 + sz ); popMatrix(); } }