I was following a course book on processing which wanted me to recreate an image: it wanted me to center a circle in each quarter of a square. It then wanted me to replace all the hard-coded numbers with variables. When I did so before the code, my image became four circles packed into the top left quarter of the square. But when i put it in void draw, it did it fine.
Why did this happen?
int ellipseSize = 50;
int bckgrndClr = 255;
int strokeClr = 0;
int fillClr = 190;
void setup(){
size(320,320);
}
void draw(){
//these are the variables which the question are about
float quartHeight = (height/4);
float halfHeight = (height/2);
float quartWidth = (width/4);
float halfWidth = (width/2);
background(bckgrndClr);
stroke(strokeClr);
fill(fillClr);
ellipse(quartHeight, quartWidth,ellipseSize,ellipseSize);
ellipse(halfHeight+quartHeight, halfWidth+quartWidth,ellipseSize,ellipseSize);
ellipse(quartHeight, halfHeight+quartWidth,ellipseSize,ellipseSize);
ellipse(halfHeight+quartHeight, quartWidth,ellipseSize,ellipseSize);
ellipseSize=ellipseSize+1;
}