Simple 2 color wipe

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