Saturday, August 3, 2013

processing exercise: rectMode()

rectMode() modifies the location from which rectangles are drawn by changing the way in which parameters given to rect() are intepreted.

processing exercise: rectMode()
processing exercise: rectMode()

size(250, 250);
smooth();
strokeWeight(3);

fill(255, 0, 0);
rectMode(CORNER);  // Default Mode
/* the first two parameters of rect() as the location of one 
corner, and the third and fourth parameters as the location 
of the opposite corner.*/
rect(100, 100, 80, 80);

noFill();
stroke(200, 0, 0);  //set stroke color = red
rectMode(CENTER);
/* the first two parameters of rect() as the shape's center 
point, while the third and fourth parameters are its width 
and height. */
rect(100, 100, 80, 80);

stroke(0, 200, 0);  //set stroke color = green
rectMode(RADIUS);
/* uses the first two parameters of rect() as the shape's 
center point, but uses the third and fourth parameters to 
specify half of the shapes's width and height.*/
rect(100, 100, 80, 80);


Related: processing exercise: rect()

No comments:

Post a Comment