Posted: Tue Nov 17

Due: Wednesday 11/18 10:00am

Submission name: w25_connect

Drawing Program

Create a simple drawing program that will use an array of PVector objects to store the endpoints of lines. It might help to look at the solution to the previous assignment if you are stuck.

Core Features:

  • A global array of PVector objects, a global constant representing the maximum number of points to store, and a global variable representing the current amount of points in the array.
  • setup should initialize any variables as needed.
  • draw should clear the screen and call a function that will loop over the array and draw lines, that’s it.
    • This function should draw lines using consecutive entries ins the array as the endpoints until there are no more points in the array. (i.e. the first two lines would connect points[0] to points[1] and then points[1] to points[2])
  • When the mouse is pressed, a new point should be added to the array at the coordinates of the mouse.
  • The following keyboard events:
    • space: add a random point to the array.
    • r: reset the array (think cleverly, what is the simplest way to achieve this?).
    • Up/Down arrow: Move all the lines up or down.
    • Left/Right arrow: Move all the lines to the left of right.
    • +: Scale all the points up by 25%.
    • -: Scale all the points down by 25%.