Size Command Not Following

My code will not adjust when I change my size command, such that my variables do not pick up on what command size I have requested, why is that?

void setup() {
size(500,500); //Canvas Size
}

// The following are all the constants for the bunny.
// Each part of the bunny is broken for the constants.

// Basic center variables
int CENTER_X = width/2; //Center of the canvax, horizontally
int CENTER_Y = height/2; //Center of the canvas, vertically
// The bunny's body
float BODY_Y = height/1.5; //Determines the Y position for the body
int BODY_SIZE_X = width/3; //Determines the size of the body, for width
int BODY_SIZE_Y = CENTER_Y; //Determines the size of the body, for height
// The bunny's head
int HEAD_X = width/2; //Determines the X position for the head
int HEAD_Y = height/3; //Determines the Y position for the head
int HEAD_SIZE_X = width/3; //Determines the size of the head, for width
int HEAD_SIZE_Y = height/3; //Determines the size of the head. for height
// The bunny's ear
float EAR_LEFT = width/2.5; //Determines the X position for the left ear
float EAR_RIGHT = (width/2.5)*1.5; //Determines the X position for the right ear
int EAR_Y = height/5; //Determines the Y position for both ears
int EAR_SIZE_X = width/10; //Determines the ear size, for width
int EAR_SIZE_Y = height/3; //Determines the ear size, for height
// The bunny's eye
float EYE_LEFT = width/2.5; //Determines the X position for the left eye
float EYE_RIGHT = (width/2.5)*1.5; //Determines the X position for the right eye
int EYE_Y = HEAD_Y; //Determines the Y position for both ears
int EYE_SIZE = HEAD_SIZE_X/4; //Determines the size of the eyes
// The bunny's arm
int ARM_LEFT_X = CENTER_X - (BODY_SIZE_X/2); //Determines the X position for the left arm
int ARM_RIGHT_X = CENTER_X + (BODY_SIZE_X/2); //Determines the X position for the right arm
float ARM_Y = height/1.5; //Determines the Y position for both arms
int ARM_SIZE_X = EAR_SIZE_X; //Determines the size of the arms, for width
int ARM_SIZE_Y = EAR_SIZE_Y/2; //Determines the size of the arms, for height
// The bunny's nose
int NOSE_TOP_Y = HEAD_Y + (EYE_SIZE/5); //Determines the Y-coordinate/top point of the nose
int NOSE_BOTTOM_Y = HEAD_Y + (HEAD_SIZE_Y/5); //Determines the Y-coordinate/bottom points of the nose
int NOSE_X_DIFFERENCE = HEAD_SIZE_X/10; //Determines the +/- for the X-coordinate for the bottom left and bottom right points for the nose
// The bunny's feet
int LEFT_FOOT_X = CENTER_X - (BODY_SIZE_X/4); //Determines the X position for the left foot
int RIGHT_FOOT_X = CENTER_X + (BODY_SIZE_X/4); //Determines the X position for the right foot
float FOOT_Y = BODY_Y + (BODY_SIZE_Y/2); //Determines the Y position for both feet
int FOOT_SIZE_X = width/10; //Determines the foot size, for width
int FOOT_SIZE_Y = height/15; //Determines the foot size, for height
// Active Code, provided for Question 2

// Beginning of the code
void draw() {
  background(0,215,255);
  drawBunny();
}
void drawBunny() {
fill(255); // Color - White (For the bunny's body,head,ears,arms,feet)
ellipse(CENTER_X,BODY_Y,BODY_SIZE_X,BODY_SIZE_Y); //Body
ellipse(EAR_LEFT,EAR_Y,EAR_SIZE_X,EAR_SIZE_Y); //Left Ear
ellipse(EAR_RIGHT,EAR_Y,EAR_SIZE_X,EAR_SIZE_Y); //Right Ear
ellipse(HEAD_X,HEAD_Y,HEAD_SIZE_X,HEAD_SIZE_Y); //Head
ellipse(ARM_LEFT_X,ARM_Y,ARM_SIZE_X,ARM_SIZE_Y); //Left Arm
ellipse(ARM_RIGHT_X,ARM_Y,ARM_SIZE_X,ARM_SIZE_Y); //Right Arm
ellipse(LEFT_FOOT_X,FOOT_Y,FOOT_SIZE_X,FOOT_SIZE_Y); //Left Foot
ellipse(RIGHT_FOOT_X,FOOT_Y,FOOT_SIZE_X,FOOT_SIZE_Y); //Right Foot
fill(255,192,203); // Color - Pink (For the bunny's nose)
triangle(CENTER_X, NOSE_TOP_Y, CENTER_X - NOSE_X_DIFFERENCE, NOSE_BOTTOM_Y, CENTER_X + NOSE_X_DIFFERENCE, NOSE_BOTTOM_Y); //Nose
line(CENTER_X, NOSE_TOP_Y, CENTER_X, NOSE_BOTTOM_Y); //Line splits the nose
fill(0); // Color - Black (For the bunny's eyes)
ellipse(EYE_LEFT, EYE_Y, EYE_SIZE,EYE_SIZE); //Left Eye
ellipse(EYE_RIGHT, EYE_Y, EYE_SIZE,EYE_SIZE); //Right Eye
}
1 Like

yes, at the moment variables are declared the size width height is not known
and also have the setup ( and size ) declared above does not help

there are several ways to deal with that

// The following are all the constants for the bunny.
// Each part of the bunny is broken for the constants.
int myw=500, myh=500;

// Basic center variables
int CENTER_X = myw/2; //Center of the canvax, horizontally
int CENTER_Y = myh/2; //Center of the canvas, vertically
// The bunny’s body
float BODY_Y = myh/1.5; //Determines the Y position for the body
int BODY_SIZE_X = myw/3; //Determines the size of the body, for myw
int BODY_SIZE_Y = CENTER_Y; //Determines the size of the body, for myh
// The bunny’s head
int HEAD_X = myw/2; //Determines the X position for the head
int HEAD_Y = myh/3; //Determines the Y position for the head
int HEAD_SIZE_X = myw/3; //Determines the size of the head, for myw
int HEAD_SIZE_Y = myh/3; //Determines the size of the head. for myh
// The bunny’s ear
float EAR_LEFT = myw/2.5; //Determines the X position for the left ear
float EAR_RIGHT = (myw/2.5)*1.5; //Determines the X position for the right ear
int EAR_Y = myh/5; //Determines the Y position for both ears
int EAR_SIZE_X = myw/10; //Determines the ear size, for myw
int EAR_SIZE_Y = myh/3; //Determines the ear size, for myh
// The bunny’s eye
float EYE_LEFT = myw/2.5; //Determines the X position for the left eye
float EYE_RIGHT = (myw/2.5)*1.5; //Determines the X position for the right eye
int EYE_Y = HEAD_Y; //Determines the Y position for both ears
int EYE_SIZE = HEAD_SIZE_X/4; //Determines the size of the eyes
// The bunny’s arm
int ARM_LEFT_X = CENTER_X - (BODY_SIZE_X/2); //Determines the X position for the left arm
int ARM_RIGHT_X = CENTER_X + (BODY_SIZE_X/2); //Determines the X position for the right arm
float ARM_Y = myh/1.5; //Determines the Y position for both arms
int ARM_SIZE_X = EAR_SIZE_X; //Determines the size of the arms, for myw
int ARM_SIZE_Y = EAR_SIZE_Y/2; //Determines the size of the arms, for myh
// The bunny’s nose
int NOSE_TOP_Y = HEAD_Y + (EYE_SIZE/5); //Determines the Y-coordinate/top point of the nose
int NOSE_BOTTOM_Y = HEAD_Y + (HEAD_SIZE_Y/5); //Determines the Y-coordinate/bottom points of the nose
int NOSE_X_DIFFERENCE = HEAD_SIZE_X/10; //Determines the +/- for the X-coordinate for the bottom left and bottom right points for the nose
// The bunny’s feet
int LEFT_FOOT_X = CENTER_X - (BODY_SIZE_X/4); //Determines the X position for the left foot
int RIGHT_FOOT_X = CENTER_X + (BODY_SIZE_X/4); //Determines the X position for the right foot
float FOOT_Y = BODY_Y + (BODY_SIZE_Y/2); //Determines the Y position for both feet
int FOOT_SIZE_X = myw/10; //Determines the foot size, for myw
int FOOT_SIZE_Y = myh/15; //Determines the foot size, for myh
// Active Code, provided for Question 2

void settings() {
  size(myw, myh); //Canvas Size  
}

void setup() {
}

// Beginning of the code
void draw() {
  background(0, 215, 255);
  drawBunny();
}
void drawBunny() {
  fill(255); // Color - White (For the bunny’s body,head,ears,arms,feet)
  ellipse(CENTER_X, BODY_Y, BODY_SIZE_X, BODY_SIZE_Y); //Body
  ellipse(EAR_LEFT, EAR_Y, EAR_SIZE_X, EAR_SIZE_Y); //Left Ear
  ellipse(EAR_RIGHT, EAR_Y, EAR_SIZE_X, EAR_SIZE_Y); //Right Ear
  ellipse(HEAD_X, HEAD_Y, HEAD_SIZE_X, HEAD_SIZE_Y); //Head
  ellipse(ARM_LEFT_X, ARM_Y, ARM_SIZE_X, ARM_SIZE_Y); //Left Arm
  ellipse(ARM_RIGHT_X, ARM_Y, ARM_SIZE_X, ARM_SIZE_Y); //Right Arm
  ellipse(LEFT_FOOT_X, FOOT_Y, FOOT_SIZE_X, FOOT_SIZE_Y); //Left Foot
  ellipse(RIGHT_FOOT_X, FOOT_Y, FOOT_SIZE_X, FOOT_SIZE_Y); //Right Foot
  fill(255, 192, 203); // Color - Pink (For the bunny’s nose)
  triangle(CENTER_X, NOSE_TOP_Y, CENTER_X - NOSE_X_DIFFERENCE, NOSE_BOTTOM_Y, CENTER_X + NOSE_X_DIFFERENCE, NOSE_BOTTOM_Y); //Nose
  line(CENTER_X, NOSE_TOP_Y, CENTER_X, NOSE_BOTTOM_Y); //Line splits the nose
  fill(0); // Color - Black (For the bunny’s eyes)
  ellipse(EYE_LEFT, EYE_Y, EYE_SIZE, EYE_SIZE); //Left Eye
  ellipse(EYE_RIGHT, EYE_Y, EYE_SIZE, EYE_SIZE); //Right Eye
}

better way might be to pack it all to a SHAPE
https://processing.org/reference/PShape_addChild_.html
and position and resize it while draw
https://processing.org/reference/shape_.html

1 Like