KITT without arrays

Ok, golfed mapped arrayless version (with sliders and exports for exploration):

export var tailPct = .6 // length of the tail in 0..1
export var speed = .05
export var pct1
export var pct2

export function sliderTail (v) {
  tailPct = .6 + v/3;
}

export function sliderSpeed (v) {
  speed = v/10;
}

export function render2D(index,x,y) {
  pct1 =  y/2 - time(speed)
  pct2 = -y/2 - time(speed)
  v = max (0,( tailPct - 1 + triangle(pct1) * square(pct1,.5) ) / tailPct )
    + max (0,( tailPct - 1 + triangle(pct2) * square(pct2,.5) ) / tailPct )
  hsv(0, 1, v * v * v)
}

that’s running at 69+ FPS on my v3 with a 16x16 matrix

to compare:
Original KITT runs at 79 FPS
Mapped Array KITT runs at 80 FPS

So the array approach is slightly faster… but… even changing it from v*v*v to v*v adds a frame or 2 back. But still, that’s only a 15% difference in speed. You’ve entirely eliminated any arrays, pure math/waves, so it’s a bit slower but uses MUCH less memory.

1 Like