Animation for ShapeMatrix

In order to animate anything in Processing, the draw( ) function must be included in your project. Within the draw( ) function, some parameters of the design must be changing over time, such as size, color. frameCount, modulus can be used to create a timer that controls animation of size, color. Mouse horizontal movement is used to modify the hue of the accent color.

Animate: PShape Color, Length (size)

Animation - cycle through ranges For animation of shape patterns, it will be convenient to have color and size repeatedly cycle through a fixed range of colors and size.

  • CellSize - create a changing fraction to animate size

  • Color: - create a changing fraction to animate lerpColor

FrameCount timer

We can use frameCount, modulus to create a timer that cycles from 0 to some maxValue.

can be used to increase the size beyond cellSize

Similar logic to above, but this will cause the fraction to range from .2 to 2.0, since the map function extends the mapping for values outside the range.

Similar logic can be used to create animated color by using map to create a

float fractionLerp = map(frameCount%maxTime, 0, maxTime, 0.0,1.0) ; //for lerpColor, keep range: 0.0-1.0

Interaction - Accent color Hue changes with mouseX movement

Add the code below into the animation color logic, horizontal mouse movement will change the accent color hue.

;

Move code into the draw function for animation

Added logic: mousePressed for noLoop(), keyPressed for loop()

Animation Code:

Last updated

Was this helpful?