Simple 2 color wipe

I’d like to create a “simple” two color whip across the entire strip, that is 500 pixels long…

So for example 100 pixels blue, being chased by 100 pixels white, before being chased by 100 blue again. Fading between not necessary.

How would this be possible - I’ve looked at the Christmas patterns which are close, but not a simple “chase” of one color after another.

Hey @jpm!

I really appreciate how you contributed the 3D printable open PB mount, so I made you a video explaining how you might think about designing it (and working code below).

Square wave approach:

export function beforeRender(delta) {
  t1 = time(2 / 65.536) // 2 seconds to repeat
}

export function render(index) { 
  pos = index/pixelCount
  s = square(pos - t1, .5) // .5 => 50% blue
  hsv(.666, s, 1)
}

More flexible sawtooth wave (time()) approach:

var speed
export function sliderSpeed (_v) { speed = _v }

export function beforeRender(delta) {
  t1 = time(.1 / speed / 65.536)
}

export function render(index) { 
  pos = index/pixelCount
  v = (1 + pos * 3 - t1) % 1 // 3 is the number of repetitions we see at once

  // .95 is where white starts (5% white)
  // .15 is where any brightness starts (15% black)
  // The remainder is blue 
  hsv(.666, v < .95, v > .15) 
}
5 Likes

WOW … that was immensely helpful and detailed! - thank you for taking the time to make that excellent explanation.

I am very grateful.

Comments in code examples helps allot … wish that was a minimum requirement for all patterns in the gallery.

@jpm,
@jeff has been working a LOT on doing exactly that for all of the default patterns that ship with v3, and has a repo for these in his github.

At some point when my hair isn’t on fire, we’ll run the entire pattern site database from a github repo where folks can help contribute clarifications and improvements so they should keep getting better and better!

I too am blown away with the explanations and comments. Very cool @jeff!

4 Likes