Give three different statements that could be used to replace the statement background(127). Hint: Ideally, we'd like you to explore the various ways that parameters to background can be used to express a color. However, we will allow you to try to mimic a similar effect by using other functions for one of your three statements, such as use of rect() to effectively cover the background.
All of the following uses of the background() method
are equivalent in effect:
background(127);
background(127, 255); // second parameter is opacity
background(127, 127, 127); // this is used of rgb value
background(127, 127, 127, 255); // rgb + opacity
background(#7f7f7f);
color gray = color(127);
background(gray);
Give a command that draws an ellipse having width 100 and height 50, with a center point that matches the center point of the sketch window, irrespectively of the size of the sketch window.
ellipse(0.5*width, 0.5*height, 100, 50);
Give a command that draws a line extending from the bottom-left corner of the sketch window to the top-right corner of the sketch window.
line(0, height, width, 0);
Give a short program that draws the left half of a filled circle, having radius 25, and centered at point (70,20).
fill(0);
ellipse(70, 20, 50, 50, 0.5 * PI, 1.5 * PI);
Give a short program that draws a red rectangle that covers the upper-left quadrant, a green rectangle that covers the upper-right quadrant, a blue rectangle that covers the lower-left quadrant, and white rectangle that covers the lower-right quadrant of the sketch window, irrespective of the size of the sketch window.
// red quadrant
fill(255, 0, 0);
rect(0, 0, 0.5 * width, 0.5 * height);
// green quadrant
fill(0, 255, 0);
rect(0.5 * width, 0, 0.5 * width, 0.5 * height);
// blue quadrant
fill(0, 0, 255);
rect(0, 0.5 * height, 0.5 * width, 0.5 * height);
// white quadrant
fill(255);
rect(0.5 * width, 0.5 * height, 0.5 * width, 0.5 * height);