The triangular wheels on the bus go round & round. Or something like that

I finally got around to replacing the dead & flaky pixels in my nanoleaf panels and started playing with the code again. I just posted this on the pattern site, it orbits a single pixel around the perimeter of all the triangles simultaneously.

Not the most exciting, but a start. It’s also kind of jerky and would probably look better with smooth transitions from one to the next instead of on/off but I’m not sure how to achieve that.

I’m just starting to wrap my head around using the time function, but I’m struggling to come up with good ways to do some of the things I want to do that reflect the nature of the panels. It’s probably worth a thread of its own, but imagine a linear chase pattern, but randomly on a panel boundary, loops the panel again, or even better, splits off a second chase that loops while the original keeps going.

Note this is slightly improved from the one I uploaded to make the color progression more interesting.

/***
 * Nano Orbital by UnstoppableDrew v1.0
 * This pattern is meant for Nanoleaf-style setups where a series of triangles or
 * other shapes are connected together in some arrangement, and each individual
 * panel has the same number of LED. In my case, there are 12 triangles with
 * 12 LED (4 at each apex). Adjust numPanels and pixPerPanel to fit your layout.
 * It could definitely stand to be smoother but I'm not sure how best to do that.
 ***/

pixels = array(pixelCount)
numPanels = 12
pixPerPanel = 12

export function beforeRender(delta) {
  t1 = time(1 / 65.536)
  t2 = time(5 / 65.536)
  idx = trunc(t1 * numPanels)
  
  for (i=0; i<pixelCount; i++) {
    pixels[i] = 0
  }
  for (i=0; i<numPanels; i++) {
    pixels[(i*pixPerPanel)+idx] = 1;
  }
}

export function render(index) {
  h = t1 * t2 + index/pixelCount
  s = 1
  v = pixels[index]
  hsv(h, s, v)
}
1 Like