@Scruffynerf,
Neat! Fun!
If you are looking for an accurate replica, I tweaked the render function to more closely match tixy’s for mono mode.
export function render2D(index,xo,yo) {
x = floor(xo * 16)
y = floor(yo * 16)
result = tixy[pattern](t1,index,x,y);
if (MonoOrColor) { //Color
h = result * ColorShift;
v = abs(result) + BrightShift
hsv(h,1,v)
} else { // Mono
if (result < 0) {
result = -result
h = Negative
} else {
h = Positive
}
v = clamp(result , 0, 1) //clamp to range
hsv(h,1,v*v)
}
}
They take the result and scale it up to a radius, clamping to max size. The result’s already in an appropriate scale in our case, but should still clamp before squaring to avoid overflows. I square for better detail at the low end, instead of cube it.
In some places, tixy uses sneaky side effects to reduce character count. This is a good example in moving cross:
(y-4*t|0) * (x-2-t|0)
The bitwise or |
happens last, and in JavaScript implicitly converts the number to a 32 bit signed integer. In Pixelblaze, this doesn’t happen and you get a bitwise or across the whole number.
For positive numbers, floor
does the same thing, but it makes negative numbers more negative, unlike bitwise OR with 0. You can’t just logical AND away the fractional bits on a fixed point negative number either (removing them makes negative numbers more negative, two’s compliment and all that).
This can do the trick:
function toInt(v) {
return v - (v % 1)
}
Applying this to the moving cross pattern:
toInt(y-4*t) * toInt(x-2-t)
Gives similar results to tixy (2 pixel wide bars).
BTW, Pixelblaze supports the same lambda expressions as JS / tixy.
tixy[10] = (t,i,x,y) => { return y - x }; // simple triangle
Can be written like this as well
tixy[10] = (t,i,x,y) => y - x // simple triangle