Pattern
The Pattern class is a wrapper class for geometric shapes based on the Processing PShape object. The Pattern display method has x,y postion input parameters to so that the shape can be displayed at any x,y position. The shapeColor allows programatic modification of the color. The Pattern class allows us to add logic to provide a uniform interface for displaying a variety of PSHape objects, this is necessary because Processing has inconsistent methods for setting the fill and stroke for PShape objects. We'll expand the logic of this class to handle setting fill for all types of PShape objects.
Example Usage:
To create a pattern, first create a PShape object, then pass the PShapeObject into the constructor along with a color that will be used for display
Pattern Class Definition
Pattern objects for Project 3
For this project, you will create 3 global pattern objects:
Initialize in setup
First you must create 3 PShape objects, then these PShape objects are passed into the Pattern constructor.
Match Patterns to ButtonGroup Buttons in DrawPattern
The code below shows how to connect the ButtonGroup logic with the Pattern logic in the drawPattern( ) function. Notice that we use a temporary variable: Pattern curPattern;, to match-up the activeButton with this temporary variable: curPattern, so that once the switch-case logic has completed, then we display which ever pattern is referenced by the curPattern variable.
Last updated
Was this helpful?