# Help with some patterns

**URL:** <https://forum.electromage.com/t/help-with-some-patterns/854>\
**Category:** Patterns and Code\
**Created:** [December 26, 2020, 8:17pm UTC](https://forum.electromage.com/t/help-with-some-patterns/854 "2020-12-26T20:17:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickbeaulieu](https://forum.electromage.com/letter_avatar_proxy/v4/letter/n/ea5d25/32.png) [@nickbeaulieu](https://forum.electromage.com/u/nickbeaulieu)\
**Post date:** [December 26, 2020, 8:17pm UTC](https://forum.electromage.com/t/help-with-some-patterns/854/1 "2020-12-26T20:17:12Z")

</div>

Hi there 🙂 I’m wondering if anyone would be willing and able to create some patterns for me?

I’ve designed this digital stained glass window and many of the patterns that are in the repository are great, but they don’t fully take advantage of the layout.

I’d love to see something that radiates out from the center, or that has the center rotate one direction, then the next layer out in the other direction, and so forth.

 ![133400267_10158842818985505_4539877968264106591_o](https://forum.electromage.com/uploads/default/original/1X/0c8a58013894325d0987bba4a2acb09736ff9b62.jpeg)

---

<div class="post-metadata">

**Author:** ![wizard](https://forum.electromage.com/user_avatar/forum.electromage.com/wizard/32/4_2.png) [@wizard](https://forum.electromage.com/u/wizard)\
**Post date:** [December 26, 2020, 9:11pm UTC](https://forum.electromage.com/t/help-with-some-patterns/854/2 "2020-12-26T21:11:53Z")

</div>

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:

> [@2D Pixel coordinate mapping tool for images](https://forum.electromage.com/t/pixel-coordinate-mapping-tool-for-images/714):
>
> Here is a quick and dirty pixel mapping tool. You can upload a photo, click to mark a coordinate on the image, press z (not control-z) to remove the last coordinate. It puts the coordinates into a text area for copying to pixelblaze mapper tab, drawing the pixel index number on the image. Remember, Pixelblaze mapper coordinates can be in any unit, pixels work too slight_smile The coordinates are in pixels from the source image. It will also accept edits/pastes into the text area to edit …

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](https://electromage.com/patterns/) 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:

> [@How does mapping fit in the PB real-time architecture?](https://forum.electromage.com/t/how-does-mapping-fit-in-the-pb-real-time-architecture/782/6):
>
> Hi @DrOldies, You mention the thread, but I wanted to be sure to point out this framework for arranging arbitrary matrixes with various offsets and rotations: Yes, the pixel map is rendered in your browser using real JavaScript, and a 2D or 3D normalized map of the pixel coordinates is stored. While you can live code that part too in order to get the mapping right, the ideas is as @Scruffynerf mentions, the map itself is usually static once set. The mapper text should resolve to either a jso…

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

> [@RGB Clock 2D Pattern](https://forum.electromage.com/t/rgb-clock-2d-pattern/818):
>
> I’ve just uploaded a customizable clock for 2D setups to the [pattern site](https://electromage.com/patterns/). I’m putting the code here too, since it relates to several recent discussions and some of the components may be useful to folks making their own clocks. /\* Draw a clock in 2D using RGB. The second hand is drawn in red, minutes are green, and hours are blue. Sub-seconds can be displayed as white. There are several controls that can adjust the way the clock is drawn. The clock face drawing is broken up into 2 mode gro…

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![nickbeaulieu](https://forum.electromage.com/letter_avatar_proxy/v4/letter/n/ea5d25/32.png) [@nickbeaulieu](https://forum.electromage.com/u/nickbeaulieu)\
**Post date:** [December 26, 2020, 9:24pm UTC](https://forum.electromage.com/t/help-with-some-patterns/854/3 "2020-12-26T21:24:29Z")

</div>

Thanks! I’ve got a 2D pixel map set up already, so the 2D patterns work nicely. Not exactly what I’ve described here, but for the most part they’re great.

I’ll take a look at the links you posted. Thanks 🙂
