Due: Friday 1/31 10:00am

Submission name: w01_pathShape

Step 0: Create your new work repository:

Step 1: Code!

Create a class called PathShape. A PathShape will represent a shape made by connecting a series of points that will be contained in a square area (but may not take up the entire area).

  • Start with the PathShapeDriver code available form thesource repository.

A PathShape will have the following instance variables:

  • ArrayList<PVector> points; An ArrayList of PVector objects representing the vertices of the PathShape.
    • You can see more about PVectors here but at the moment, we only need to use the fact that they have x and y instance variables.
  • int numPoints: The total number of vertices the shape should have.
  • PVector corner: (x, y) position of thew top-left area that will contain the shape.
  • int ShapeSize: The side length of the suqare area that will contain the shape.
  • color inside: The fill color for the shape.

Fill in the following methods:

  • PathShape(int np, int cx, int cy, int ss):
    • Set numPoints to np.
    • Sets the corner to (cx, cy).
    • Sets shapeSize to ss.
    • Sets inside to a color of your chosing.
    • Initializes points and calls makeRandomShape() (see below).
  • void makeRandomShape()
    • Adds np random points to points by calling makeRandomPoint()
    • The shape need not be a polygon.
  • PVector makeRandomPoint()
    • Returns a new PVector object where the x and y values will always be within the square area that defines the calling PathShape object.
  • display()
    • Use beginShape, vertex and endshape to draw the PathShape on the processing screen.
    • The shape use the instance variable colors accordingly.
    • The shape should be closed, so that last point should connect to the first.

If done correctly, the provided driver file that will create 4 PathShape objects to be displayed in a grid like so:

a00-pathgrid