Need help making a Theater Marquee pattern

I’m very new to Pixelblazes and I’m trying to make a few patterns, Fill (from one direction to the end), Fill (both ends and overlapping in the middle) and Theater Marquee (which I’m working on right now) and this Theater Marquee is giving me trouble, mostly because I don’t know what I’m doing.

I’m playing around with the code from the K.I.T.T. pattern and I’ve removed the fade, changed the number of pixels that move and added a custom color picker. But I can’t for the life of me figure out how to get multiple lines of light separated by dark going across it. (3 pixels on, 3 pixels off, 3 pixels on, 3 pixels off across the whole strip and always moving forward) I know a good amount of C# and C++ but I just don’t understand how these Pixelblaze keywords work.

Here’s the code I’ve played with

var H1 = 0, S1 = 0, V1 = 0;
export function hsvPickerFirstColor(_h, _s, _v) {
  H1 = _h
  S1 = _s
  V1 = _v
}

leader = 0
direction = 1
pixels = array(pixelCount)

speed = pixelCount / 8000
export function beforeRender(delta) {
  lastLeader = floor(leader)
  leader += direction * delta * speed
  
  if (leader >= pixelCount + 3) {
    leader = 1
    lastLeader = leader - 1
  }
  
  if (leader < 0) {
    direction = -direction
    leader = 0
  }
  
    up = lastLeader < leader 
  for (i = lastLeader; i != floor(leader); up ? i++ : i-- ) pixels[i] = 1
    
  for (i = 0; i < pixelCount; i++) {
    pixels[i] -= delta * 0
    pixels[i] = max(0, pixels[i])
  }
}

export function render(index) {
    v = V1 = pixels[index]
    v = v * v * v
    hsv(H1, S1, v);
  
  if (index > leader || index < leader - 3) rgb(0, 0, 0)
}

If anyone could help me out with this I’d be extremely grateful. Also if there’s anywhere to learn more about how to code these Pixelblazes please tell me as I feel like Patrick from Spongebob trying to figure this stuff out. Thanks!

Hi @Neobot21!

I think you’d benefit from my video about coding basic color wipes on Pixelblaze:

That’s giving you the broader thinking tool. I love Pixelblaze because it uses math and thinking I never needed in a web engineering job. Here’s some example code to get you started:

var onLen = 3
var offLen = 3
var period = 2 // seconds

var totalLen = onLen + offLen
var offset = 0

export function beforeRender(delta) {
  var t1 = time(period / 65.535) // Ramp, 0..1 every 2 seconds
  
  // Number of pixels to offset our on/off pattern right now. Range 0..totalLen
  offset = floor(t1 * totalLen)
}

export function render(index) {
  var thisPixelOn = (index + offset) % totalLen < onLen
  hsv(0, 1, thisPixelOn)
}

or even:

export function render(index) {
  hsv(0, 1, square(index / 6 + time(.01), .5))
}

Some challenges if you want:

  1. How do you make the animation flow the other direction? You can’t just change the sign of offset to negative (but you can with the time(..01) in the second example).
  2. How would you make the strip initially start all-off, with the marching ants building into it?
  3. Can you modify this to interpolate the pixels that are about to turn on and off?

ezgif.com-gif-maker

5 Likes

This is really helpful, thank you so much!!! My pattern isn’t yet finished, but this is a major step in the right direction and I think I can finally get it how I’d like it.

It’s currently lines of 6 light pixels (blue and white) separated by 6 dark pixels just like in your video. I’m going to play around with it so I can have 3 pixels on Color One, 3 pixels off, 3 pixels on Color Two, 3 pixels off, and so on. (with the option to only use Color One across all lighted pixels)

I don’t fully understand all of it yet, but I’m going to re-watch the video multiple times to make sure I’ve got it all down and check out your other videos. Thanks again and have a good day!

1 Like