Some Bloating Circles (download) Problems
Run the Bloating Circles program to make sure it works.
- Make sure the latest version of Processing is on your computer. You can download it here.
- Fix the Circle class so the fields and parameters adhere to proper coding covention.
- Modify one line of code to change the number of bloating circles to 20. (Using constants is an important concept.)
- Change the thickness of the circles to 5. (Think about how annoying this is when you can't find a constant.)
- Make Gunn bloating circles by having alternating red and black circles instead of random colors.
- Make it so the center of the circles goes to wherever you click:
- Create two new variables xClicked and yClicked and put them with the other global variables at the start of the whole program.
- Create a new tab called "Mouse Events" (without the quotes).
- The method mousePressed() is a special method in Processing (like the setup() and draw() methods). Write a mousePressed() method that captures the mouseX and mouseY of a mouse click and stores them in your new xClicked and yClicked variables.
- Modify your program so it draws circles from where the mouse was clicked rather than the center of the whole display.
- Make a separate project that does bloating squares.
Some notes...
- Processing has global variables. These are similar to public static variables in Scheme.
- When Processing starts, it goes through three methods in this order:
- settings(), which runs before the sketch is set up; settings() is not used in this program;
- setup(), which can call Processing commands (i.e., the stuff in the Processing API reference);
- draw(), which behaves as if it is in an infinite loop.
- Unlike Eclipse, Processing doesn't have a fancy editor. It catches compiler errors to some extent, but it can be hard to find the problems as the offending code is often not what gets underlined.
- If, when you compile your code, you are taken to a line that does not seem to have any errors, it probably doesn't! The most likely issue is a syntax error in a previous tab. While the tabs separate code, which is good for organizing things, Processing treats the code as one, long file. Often, a missing curly brace or an extra curly brace is the culprit.