Help with some patterns

Hi @nickbeaulieu,
That looks pretty sweet! To get the most out of it, you’ll want a 2D pixel map. Then you can use a bunch of the 2D patterns and get some sweet effects.

Check out this post for a simple click mapper:

Once you have a pixel map, you can get things like radius and angle (and some patterns do this already) and use that instead of index/pixelCount to upgrade many patterns.

There’s a pattern on the pattern sharing site with some utility functions for getting angle/radius (assuming centered in a piece) called “angle and radius from coordinates”

Here’s a post with some more background and examples of how these might be used:

Once you get a 2D pixel map installed, I would humbly suggest you try out my clock pattern :slight_smile:

As an example of upgrading a pattern I took millipede and have it use angle. you can see the 1D render and render2D side by side to see how it was modified:

speed = 20
legs = 10

export function beforeRender(delta) {
  t1 = time(1 / speed)
  t2 = time(2 / speed)
}

export function render(index) {
  h = index / pixelCount 
  h += (index / pixelCount + t2) * legs / 2 % .5
  v = wave(h + t2)
  v = v * v // Gamma correction
  hsv(h, 1, v)
}

export function render2D(index, x, y) {
  //use angle around a center point instead of distance on a strip
  h = (1 + atan2(x - .5, y - .5)/PI2) * .5 
  h += (h + t2) * legs / 2 % .5
  v = wave(h + t2)
  v = v * v // Gamma correction
  hsv(h, 1, v)
}

I’ve also uploaded a fancier version with controls to the sharing site.

1 Like