Project 2 - Steps
Project 2 - Steps
For Project 2, students will create a Processing program to create custom 2D-Grid Artwork using 2 different PShape vertex patterns. Project 2 builds on understanding learned in Project 1, creating PShape objects by specifying a set of vertex points.
Inspiration:
Examine inspiration artwork - Victor Vasarely to observe pattern design rules, then incorporate similar rules in your custom design. Design rules are implemented when populating the 2D array, using logic to create patterns, see Grid Patterns for examples.
Create a 2D Array of PShape objects, create grid patterns using HSB colorMode and lerpColor to specify the color used. If using color-selector tool, specify colorMode(HSB, 360,100,100); //specify max range values
Project Structure: Functions:
Step 1 - VertexShape Functions
Create 2 functions to create PShape vertex objects using float length, color foreground, and optional color: background as input parameters:
PShape vertexShape1( float len, color foreground)
PShape vertexShape2( float len, color foreground)
PShape defined using len parameter -
As with Project1, PShapes are defined using vertices and the input parameter len , or some multiplicative factor times len. Here, many vertices are defined using len * .5. Since all vertices are defined in terms of the len input parameter, then we can vary the value of len when calling the function, and the displayed shape will be the same shape, but scaled at a different size depending on the value of len.
Note: to define our vertices, we are using len * factor
, we are not using len + factor
. By using a fractional value for factor
, we're scaling the size of our pattern, since want to use len to control the size of our pattern. If we add a factor, len + factor
, that would create a position offset or x,y
positioning of our pattern at the time we draw the pattern using the PShape: shape( s, x, y) function.
Verify VertexShape renders correctly After writing the vertexPattern functions, it's a good idea see what one of them looks like and to make sure they are displaying something, we can do this in setup
RecursivePattern Group-type PShape
Group-Type PShape with stacked child PShapes In the first project, the rendering of the PShapes was part of the logic in the Recursive functions, but in this case, we need to save / store the 'stacked' Recursive PShapes in the 2D array so they can be rendered later in the displayShapeMatrix functions. We need the recursive function to create a single Group-type PShape that contains the stacked children PShapes. To accomplish this, we create the group-type PShape before calling the RecursivePattern function. The group-type PShape is passed into the RecursivePattern function as an input. After the RecursivePattern function execution is completed, the group-type PShape object contains all of the child PShapes.
Step 2 - 2D Arrays of PShape Objects
Functions to create 2-Dimensional Arrays of PShape objects: these functions have logic that determine color, shape, pattern logic. Use lerpColor and map functions with loop-index variables: i, j.
Step 3 DisplayShapeMatrix Default Region
Create functions to display each shapeMatrix. These functions should take input parameters like:
PShape[][] shapes
,int rows
,int cols
,float cellSize
The code below has simple logic to step through each shapes[][] element and display it using the nested for loop to change the position of x and y across rows and columns.
Step 4: Use Rotate, Translate, Scale to display in other Regions.
Refactor your code, create functions to transform, scale, rotate the shapeMatrix into regions 2,3,4.
Within these functions, the canvas is transformed prior to calling the displayShapeMatrix code above. An example of using Rotate is shown for creating a ShapeMatrix in Region2. Similar functions should be created for Region3 and Region4 - See Transforms for more examples.
Final Code: Setup:
The code below shows the setup function where we're defining our variables and calling our functions, since there's no animation or interactivity in this project, setup can be used for organizing and executing our project logic.
Now that we're creating smaller grid units and combining those to create a larger artwork, we need new variables to clarify these concepts. The larger composition will be called the artWork, it has width = height = artWorkSize. Each artwork is composed of 4 regions, where a 2D array of PShapes occupy one region of space. Each shapeMatrix has dimensions defined by regionWidth = artworkSize/2, rows = 20, cols = 20. cellSize is defined as regionWidth/cols.
Last updated