Skip to content

v2.0.0

Latest

Choose a tag to compare

@ebeneliason ebeneliason released this 16 Dec 07:04
· 1 commit to main since this release
f42b212

New Features

More Pattern Formats

EasyPattern now supports four pattern specification formats. Provide any of these for the pattern property to define your pattern, or call the overloaded setPattern() function:

  1. Bit pattern. An array of 8 numbers representing the bit pattern for each row. (previously supported)
  2. Dither pattern. A table containing a ditherType constant, and optional alpha and color. (revised, see breaking changes)
  3. Image. An 8x8 playdate.graphics.image. (new)
  4. ImageTable. An 8x8 playdate.graphics.imagetable. (new)

Pattern Composition

Set the new bgPattern property to provide a pattern that appears behind your partially transparent EasyPattern. This property supports static patterns or another EasyPattern instance, allowing recursive composition of animated patterns and enabling more nuanced effects. See an example.

Dynamic phase shifts

Set xShift and yShift to additively adjust the displayed X and Y phases of your pattern. This feature enables your patterns to respond dynamically to inputs or game conditions. For instance, you could use it to scroll a pattern with the crank or create a parallax background effect as the player moves. See an example.

Reflection & Rotation

Apply reflection and rotation transformations to your patterns to change their orientation with the xReflected, yReflected, and rotated properties. This simplifies the process, as both pattern and animation properties automatically adjust, eliminating the need for manual adjustments of individual properties. See an example.

Inverted Patterns

Set the inverted flag to render a pattern with inverted colors, so that black pixels appear white, and white pixels appear black. See an example.

Animated Patterns

The pattern property now accepts a playdate.graphics.imagetable. This enables patterns themselves to animate, in addition to the animated easing of the overall pattern that EasyPattern applies. Set the tickDuration property to indicate how long each image in the sequence should be shown. See an example.

Variable Opacity

Set the opacity of your pattern with the alpha property, and optionally specify a ditherType for the opacity effect. This will cause the pattern to render in a similar manner to playdate.graphics.image:drawFaded(), allowing anything behind the pattern—even in otherwise opaque areas—to show through. See an example.

Loop Duration and Callbacks

New getters provide convenient access to the X, Y, and total pattern loop duration. The returned values account for all animation properties including duration, speed, and offset, as well as those of any background pattern. New callbacks which trigger when looping enable you to modify the pattern itself over time, or trigger other events in sync with your pattern. See an example.

Update Callback

Dynamic behaviors, such as adjusting the phase offset of a pattern based on crank input or character position, can now be encapsulated within the EasyPattern declaration via the update(pattern, time) callback. This function gets called immediately before every phase computation, allowing you to modify the pattern as needed. See an example.

Bug Fixes

  • isDirty() now reports accurately even when called multiple times per frame before calling apply(). This makes it much easier to use the same pattern with multiple sprites, which can be marked dirty in their update() functions without needing to cache a dirty bit.

Breaking Changes

  • Legacy parameter names. Previously deprecated legacy parameter names have been removed. See the list of supported parameters.
  • Dithered patterns. Patterns constructed with ditherType and alpha are no longer defined using individual properties. Instead, provide a table containing the values (and optional color) to the pattern property. (ditherType and alpha properties remain, but are now reserved for setting the opacity effect of the pattern itself.) setDitherPattern(alpha, ditherType) is still supported, although setColor() is removed in favor of a third, optional argument to setPattern(ditherType, [alpha], [color]). See an example.

Full Changelog: v1.3.0...v2.0.0