Need advice for mapping and/or pattern

I am looking for experts advice on my (wife) picture frame project.
The controller is PB Pico, the strip is 300 WS2812b LEDs.
Strip is folded in a middle so it became double sided (150 LEDs
on each side) and than spiraled on a 12"x12" white plastic square.
Here is a set of pictures of my creation.

All LEDs are Off.

Running Rainbow Fonts built-in pattern

The same pattern but with white plastic diffuser on top

And final assembly with a picture on top of the diffuser

In reality all looks much better than on the above photos.

Instead of this built-in test pattern my wife wants something like
“slowly spinning star/sun” or whatever else slowly spinning…

Here are my questions:

  1. Do I need to create a mapping for this double sided spiral?
    (I think, the appropriate mapping can help with creating a desired pattern.)
  2. By any chance is similar mapping already exist?
  3. Is it any good example(s) for patterns I am looking for?

Any idea(s) on how to create the desired pattern is greatly appreciated.

I would honestly use the image mapper. A pattern would be possible, although getting the parameters for the spiral just right would be a little tough, but especially when it comes to mapping both sides of it.

Personally, I would try two things:

  1. Using the photo mapper and clicking on the “hot spot” where the light is hitting the white background rather than on the LED itself, so that the layout of the lights is more evenly spread out and more accurately reflects where the light coming from it will be visible, rather than the location of the LED. This should really help you see the entirety of a 2D pattern across the whole area of the spiral. Otherwise, the LEDs on opposing sides of the spiral will have almost the same X and Y coordinates.

  2. If that doesn’t look good, using the photo mapper and clicking as close as possible to the actual LEDs

I do wonder how much the “coolness” of the spiral will be lost by turning it into a standard 2D map, but I think the fact that the LED strip blocks light and keeps it contained will end up creating interesting patterns anyway, even when running a standard 2D pattern on it.

1 Like

Thank you very much for the link to this very useful app!
I did not know about its existence.
Now mapping is done:

and it looks right in the mapping preview window:


There are few buil-in 2D patterns looking really good.
But the original idea (and request) was/is to create a “slowly rotating star/sun” pattern.

My question is:
How do I create something like “slowly rotating star/sun” pattern?
As of now I can think only about creating “frame buffer” and then rotate it.
But I am sure, PB experts can do this without “frame buffer”.
Any help/hint/example will be greatly appreciated.

I think it’s worth looking at the Spinwheel 2D pattern. I don’t think there’s a way to directly link to patterns, but it’s on page 3 here:

I don’t have my PB around, so I can’t remember if this is the pattern I’m thinking of, but I think it makes a shape in the middle that spins. Sorry that’s not more helpful. I’ll try and mess around with making a rotating sun pattern, probably sometime this weekend.

Thank you for the advice, I tried this pattern but my wife rejected it.
I did try few more existing patterns “as is”.
For now the most acceptable pattern is built-in “spiral twirls 2D”.
It runs a bit faster then desired. There are multiple speed control sliders.
But touching any of these unfortunately makes things only worse.

This will be really helpful.
Many BIG Thanks to you upfront.

I will try to create something myself.
I can clearly see how to deal with “frame buffer” programming approach.
But many really cool things are done without using “frame buffer”.
I really have to learn this technique.

This function should let you turn any 2D pattern into something rotating.


//Rotate 2D space (around the Z axis), by an angle (in radians).

I think that rotate(t1*(2*PI)) should give you something that rotates once each time that t1 time variable cycles. There’s still a good chance that I’m totally wrong, as I haven’t yet actually used this in a pattern, but it’s worth a try if you still want to mess around and try to get something working.

1 Like

Now that you have a 2D map, lots of patterns will work for you. Yes, you can rotate any pattern by using a transform as.suggested above.

I think the SDF code that @zranger1 pioneered is likely the best… Easy to make a sun or star shape and spin it.

Many BIG Thanks to you guys (@teaderechoweb, @Scruffynerf, @zranger1).
I got the ideas what to do next.
It should be a lot of fun to implement exactly what is desired.

1 Like

@jeff had made some pretty cool star patterns that could work. It was using a polar coordinate map, but I’ve hacked up a version that will work using the normal coordinate system.

StarGen 2D.epe (15.5 KB)

@jeff’s Demo:


It’s very easy to change the various speeds to slow the animation down further. If you make the numbers in the various sliderXxxSpeed() functions bigger, you’ll get slower results when you play with the sliders.

This is exactly what I thought about.
But as I already mentioned, as soon as I am touching any controls things becomes
only worse. And this is basically related to every pattern I tried. Pattern(s) works
good and looks nice with all default parameters. But as soon as something modified
the behavior becomes unexpected.

Thanks @wizard
I tried this pattern. It looks good on my 16x16 matrix but somewhat different
from whatever in a video. Video BTW looks very nice.
I am trying to understand why my visual effects are looking differently.

I played with “SDF Testbed2” and “Geomorph 2D” patterns created by @zranger1
First one (SDF Testbed2) has variety (24) of different selectable shapes.
I tried all of them one by one.
Each one produced the intended shape except for the shapeFns[6] = hexStar
This one looks like Circle instead of Hex Star.
And of course, this is a shape I really want to use.
Second one (Geomorph 2D) runs very nice with all default parameters.
At some point I can see a very nice Rotating Star.
But all my attempts to use just this (Rotating Star) pattern failed and
produced completely unexpected results.
Even attempt to slow down morphing time by changing 1000 to 2000
in this function:

// morph to a new shape every other second...
  if (morphClock > 1000) {
    if (!wait) {
      shape = nextShape;                      // set to next shape
      nextShape = (nextShape+1) % numShapes;  
    morphClock = 0;    
    wait = !wait;

produced completely unexpected results - all shapes became oversized.
Returning this value back to 1000 did not restore a behavior.

I am loosing all understanding on what is going on and what I am doing wrong.

Finally I got a Rotating Star pattern by modifying “Geomorph 2D” code.
Again, I am not sure why my modifications did not work on a fly.
But after restarting a PB and applying the same changes I got what I wanted.

Thanks everybody for very valuable hints and ideas.

It was designed to work with concentric LED rings, with a lot of resolution on the outer ring. I agree, it doesn’t look super on my 16x16 either, but might look much better on something more circular which will have more angular resolution. Some of its patterns are dense, a few code tweaks lowering some coefficients of phi should help.

1 Like

OK, this makes sense.

Actually, @wizard, that’s part of it, but also the location differences between a 16*16 (256) matrix versus a 241 pixel ring is more than just increased resolution on the outside… The LEDs rarely fall into the “circle” for anywhere in the matrix except for the right angles. (0,90,180,270) and maybe the 45s, so tuning it to be less specific and thus light more “nearby” LEDs would help a lot I suspect in making it feel round. Same is true here, as it’s likely not lighting enough LEDs on the spiral to fill it out smoothly.

I agree, “angular resolution” for lack of a better term.

@Vitaliy have you tried it on the spiral, or just the 16x16? If you post your map I can use my new fancy feature-in-progress to see.

In this case of this back-to-back spiral strip behind a diffuser, maybe it makes more sense to click on the visual center of the illuminated area instead of the location of the LED.

1 Like

Excellent point. The idea of using a dual side strip as a spiral sounds good in practice but the sideway nature of the LEDs means the light is spreading out and the leds opposite it will be competitive, so color blending will happen in ways that are different from facing LEDs head on.

Adjustment of the map will likely improve results.

One good test: use the 2D sweep and see if you get a smooth line. Slow it down and see if you notice it looks ragged in places.

Also the 2D KITT would be helpful but really you’d want to rotate it and explore how smooth the movement looked at various angles.

@wizard just tried StarGen 2D pattern on my spiral. It looks much better vs 16x16 matrix.
Of course, my spiral is not geometrically ideal. I tried my best, it looks about right but
could be better if I was not lazy and draw an ideal mathematical spiral guide line
before gluing LEDs.
Just in case, here is my JSON map for this double sided spiral.
Photos how it looks are in this post above.


I experimented with multiple different LED layout.
Originally I thought about 32x32 Matrix right behind the picture with the diffuser.
May be the diffuser is/was not a right one but my wife did not like how it looked.
She did not like well visible dots when LEDs where right behind the diffuser.
When I moved LEDs a bit away dots disappeared but she still did not like it.
Single sided spiral looked good but produced very uneven light distribution
plus spiral itself was very well pronounced. Finally double sided spiral was
accepted and made into final design. I interleaved LEDs on both sides.
This increased LED density but strip became twice shorter, i.e. twice less spiral
turns. But visually this looks much better.

Right now this picture frame runs two patterns.
One is a built-in spiral twirls 2D
It runs a bit faster than desired but all my attempts to slow it down failed.
The pattern becomes destroyed instead just slowing speed down.

Second on is a Rotating Star.
I modified a Geomorph 2D code created by @zranger1 and left only
slowly rotating hex star.

Once again - Thank you all for very valuable ideas and hints how
to create a desired result.

1 Like