Help with Drawing scaling

hello. I need help figuring out how to do this specific function. My assignment asks that I make an animal that grows bigger and smaller depending on the Y value of the mouse. I managed to make the main body parts scale but they don’t retain the original shape of the turtle. How do I make it so that as the animal gets smaller or bigger, it retains its original shape of the turtle?

here is what I have so far. any help or suggestions is appreciated!

  int X = mouseX;
  int Y = mouseY;
  final int MIN_SIZE = 3;
  final int MAX_SIZE = 5;
  int LO = 0;
  int HI = 1;
  float animalSize;
void setup() {
  size(500,500);
}

void draw() {
  background(255);
  drawTurtle();
}

void drawTurtle() {
  animalSize = MIN_SIZE + (mouseY-LO) / (HI-LO) * (MAX_SIZE-MIN_SIZE);
  X = mouseX;
  Y = mouseY;
  final int SHELL_X = width/2; //the ellipse's centre x value
  final int SHELL_Y = height/2; // the ellipse's centre y value
  final int SHELL_WIDTH = width/2; //width of the ellipse
  int shellHeight = (height/2);
  final int SHELL_HEIGHT = shellHeight + (height/10); //height of the ellipse


  // this section is for the colors of the turtle
  color shell = color(74, 128, 97);
  color limbs = color(89, 156, 118);
  color eyes = color(0);


  //this section is for the head of the turtle
  final int HEAD_X = X; //head centre x value
  final int HEAD_Y = Y - (height/10)*3; //head centre y value
  final int HEAD_WIDTH = (width/5); //width of head
  final int HEAD_LENGTH = (height/3); //length of head

  final int LF_LEG_X = X-(width/4); //left front leg values
  final int LB_LEG_X = X-(width/4); //left back leg values

  final int RF_LEG_X = X+(width/4); //right front leg values
  final int RB_LEG_X = X+(width/4); //right back leg values

  final int LEG_WIDTH = (height/10)*(7/2); //width size of legs
  final int LEG_HEIGHT = (height/10); //height size of legs

final int F_LEG_Y = (Y)-((height/10)*2); //front legs y values
final int B_LEG_Y = (Y)+((height/10)*2); //back legs y values

  // these are the legs of the turtle
  fill (limbs);
  ellipse(RF_LEG_X, F_LEG_Y, LEG_WIDTH*(animalSize/height), LEG_HEIGHT*(animalSize/height)); //right front leg
  ellipse(LF_LEG_X, F_LEG_Y, LEG_WIDTH*(animalSize/height), LEG_HEIGHT*(animalSize/height)); //left front leg
  ellipse(LB_LEG_X, B_LEG_Y, LEG_WIDTH*(animalSize/height), LEG_HEIGHT*(animalSize/height)); //left back leg
  ellipse(RB_LEG_X, B_LEG_Y, LEG_WIDTH*(animalSize/height), LEG_HEIGHT*(animalSize/height)); //right back leg
  
  final int X_LEFT = X - (width/10); //th
  final int X_RIGHT = X + (width/10);
  final int ADJ_TRI_Y = Y;
  final int TAIL_TIP_Y = Y+200;

  triangle(X_LEFT, ADJ_TRI_Y, X_RIGHT, ADJ_TRI_Y, X, TAIL_TIP_Y); //this is the tail of the turtle

  ellipse(HEAD_X, HEAD_Y, HEAD_WIDTH*(animalSize/height), HEAD_LENGTH*(animalSize/height)); //head of the turtle
  fill(shell);
  ellipse(X, Y, SHELL_WIDTH*(animalSize/height), SHELL_HEIGHT*(animalSize/height)); //shell of the turtle

  final int RIGHT_EYE_X = X + (width/20); //eye constants
  final int LEFT_EYE_X = X - (width/20);
  final float EYE_Y = Y -(height*0.4);
  final int EYE_WIDTH = width/50;
  final int EYE_HEIGHT = height/50;

  fill(eyes);
  ellipse(RIGHT_EYE_X, EYE_Y, EYE_WIDTH, EYE_HEIGHT); //right & left eye
  ellipse(LEFT_EYE_X, EYE_Y, EYE_WIDTH, EYE_HEIGHT);

  final int MID_LINE_X = X; // line values
  final int MID_LINE_Y_1 = Y-100;
  final int MID_LINE_Y_2 = Y+100;
  

  line(MID_LINE_X, MID_LINE_Y_1, MID_LINE_X, MID_LINE_Y_2); //line on the middle of the turtles back
}
1 Like

Try in draw before calling the turtle:

scale (mouseY);

1 Like