Newbie Need some assistance please

Hi all,
I am installing DRL strips on my car, I have this pattern I like but I need it to go to static white after X amount of seconds and not loop after that, I don’t know how to go about this.

when I unlock the car it plays the pattern then after X amount of seconds it stays on static white

distance = 10

export function beforeRender(delta) {
t1 = time(.02)
}

export function render(index) {
h = index/pixelCount
s = 1
v = 1

head = t1 * pixelCount
offset = (head - index + pixelCount) % pixelCount

hsv(h, s, clamp(1 - offset / distance, 0, 1))
}

Try this – you were almost there, just needed to add the accumulator to count up the elapsed time and compare it to the time you wanted it to run.

var distance = 10
var timeToRun = 10000   // number of milliseconds before we go all white
var timeSinceStart = 0
var t1;

function renderColor(index) {
  h = index/pixelCount
  s = 1
  v = 1

  head = t1 * pixelCount
  offset = (head - index + pixelCount) % pixelCount
  hsv(h, s, clamp(1 - offset / distance, 0, 1))  
}

function renderWhite(index) {
  hsv(0,0,1)
}

renderfn = renderColor

export function beforeRender(delta) {
  timeSinceStart += delta
  if (timeSinceStart > timeToRun) renderfn = renderWhite
  t1 = time(.02)
}

export function render(index) {
  renderfn(index)
}
4 Likes

Wow thanks for the quick reply, It’s working like I wanted, I appreciate the support zranger1

1 Like