Project #7 - Pixels
Create a program that draws randomly colored boxes at different scales
REQUIREMENTS
Create a program that draws a grid of randomly colored rectangles on the screen each time the user clicks the mouse.
The window must be sized exactly 512 x 512
Your program must start with boxes that are sized 32 x 32
Each time the user left clicks, the size is halved and new boxes are drawn
Each time the user right clicks, the size is doubled and new boxes are drawn
There is a minimum size of 1 and a maximum size of 512.
Your program must display the current pixel size in large, readable text.
FAQ / Tips
Step by Step
Set your window size and a variable called pixelSize
In draw, use text to display pixelSize to the screen
Write a mousePressed method:
On a left click, reduce size by half
On a right click, double size
Add in minimum and maximum size requirements
Make your text size, color, and positioning look good.
Create a method that draws boxes on the screen based on pixelSize
This is the main part of your program
You'll need to use a nested for loop
This is a little drawing stars, but you won't need modulus
Make sure you use noStroke() to remove the outline for each rectangle
Call that method in setup and on mouse press
What colors can I use?
As long as the colors have some randomness, feel free to change the palette. For example, it might be "shades of blue" or "fall colors."
My mousePressed() isn't doing anything!
Explanation: mousePressed() only works in programs with a draw method
Solution: Add a draw method (even if it's empty)
EXAMPLE: RUNNING PROGRAM
Click here to download a running version of the program.
Start
Minimum Size
Maximum Size
Examples with Alternate Colors