Coding Challenge (Assignment Oct 19th)

In the Assignments folder in the class Dropbox, locate the processingA2Z archive. Download, unzip and place the folder into your Processing folder. You can find the Processing folder in the Documents folder from Finder –> Go –> Documents –> Processing. The folder should appear in the menu when you open Processing.

There are 14 code examples without comments. Your assignment is to:

  1. Explore each file to consider what each program does.
  2. Save each file with a new name to preserve the original and distinguish them from your modified programs.
  3. Add comments on each line of the code as originally written.
  4. Modify the code to do something else. Include your own comments and save each sketch with a different name from the original code with and without your comments.
  5. You will have three sets of sketches per example: 1. The original; 2. The original with your comments; 3. Your modified version of the sketch that distinguishes it from the original. It should also include your own comments.
  6. Upon completion of the code challenge, you must update your blog with thorough documentation.
  7. Be prepared to demo work in class today.

Note: Every line of code should include YOUR OWN comments.

Documentation on Code

9

Code 9


Code 9 was one of the examples I enjoyed working on. For the example, having the cursor follow around with the circle added nice interaction as opposed to any static sketch. If the program detects on canvas that the mouse is clicked, void mousePressed() is executed which will cause the background color to turn white and circles disappear.

13

Code 13


For code 13, the statements in the examples were the focus. When the canvas detects mouse is clicked inside the square, the program executes the statement if (on) { background (RGB); //which changes the background color. Otherwise executes } else background (RGB); } //which would be a different color when not clicked.

14

Code 14

Lastly, code 14 was interesting as well. Understanding that squares on the canvas can be repeated and with looping was very convenient instead of having to type every single line of code repeating the squares. By having the int y = 0; this allows the following while (y <= height) { //repeats the loops of squares to display on the canvas. With the y being stated as 0 and whenever the height is smaller than y (which in this case is for the whole height of the canvas) the squares will keep looping till the end of the canvas in y coordinates.

Advertisements