Drawn item in any size, in any position in the canvas (processing)


I’ve been able to draw an item in any size of the canvas but I can’t figure out how to draw that item in any size?

"This must be controlled by exactly 3 constants at the top of your program.

  1. There must be one constant that controls the size/scale of the item controls the size in any suitable way. All other sizes must be calculated automatically from this one, so that the entire item draws correctly no matter what value this constant is given.
    2. There must be exactly two constants that control the position of the center of the item, one for the x-direction and one for the y-direction. The x constant should control where the center (left to right) of the item is located. The y constant should control the position of the lowest point of the item.
    3. Give values to these three constants that make the item roughly half the width, or half the height, of the canvas."



int tailW=2*height/35, tailH=1*height/35, tailLeft=(width-tailW)/2;
int handleW=tailW/2, handleH=tailH6, handleLeft=(width-handleW)/2;
int quadX1=handleLeft, quadY1=tailH+handleH;
int quadX2=quadX1+handleW;
int quadX3=quadX2+tailW/4, quadY3=quadY1+tailH
int quadX4=quadX1-tailW/4;
int bodyLeft=quadX4, bodyH=(tailH+handleH)*2, bodyW=quadX3-quadX4;

rect(tailLeft,0,tailW,tailH); //tail

rect(handleLeft,tailH,handleW,handleH); //handle

quad(quadX1,quadY1,quadX2,quadY1,quadX3,quadY3,quadX4,quadY3); //between tail and handle

rect(bodyLeft,quadY3,bodyW,bodyH,0,0,25,25); //body


Which part are you stuck on? Can you please edit your post to properly format your code? Paste your code between three tick marks, like this:

// code goes here

It looks like you already have some directions. Which one of those are you confused about?