Hi @Vitaliy! Welcome to the forums!
(PS: I don’t have access to a running Pixelblaze at the moment to validate these - if anyone sees a problem, feel free to DM me and I’ll correct it)
I like to put this code before beforeRender(delta)
, or if I wrap it in a function, I’ll put it anywhere and then call it as the last line of the pattern. For example:
var hues = array(pixelCount)
// Let's initialize the hues to a random red-yellow hue per pixel. This only runs once.
hues.mutate(() => random(.2))
export function beforeRender(delta) {
pulse = time(5/65.535)
}
export function render(index) {
hsv(hues[index], 1, pulse)
}
Wrapped and called on the last line:
var hues = array(pixelCount)
function init() {
// Let's initialize the hues to a random red-yellow hue per pixel. This only runs once.
hues.mutate(() => random(.2))
}
export function beforeRender(delta) {
pulse = time(5/65.535)
}
export function render(index) {
hsv(hues[index], 1, pulse))
}
init()
Sure - there’s a few ways. Hopefully these are clear:
var arr2D = [[0, 0], [0, 1], [1, 0], [1, 1]]
arr2D[3][1] = 2 // [[0, 0], [0, 1], [1, 0], [1, ***2***]]
var arr2D = array(3)
arr2D.mutate(() => array(2))
arr2D[2][1] = 2 // [[null, null], [null, null], [null, ***2***]]
// A for loop works too
var width = 16
var height = pixelCount / width
var arr2D = array(width)
for (i = 0; i < arr2D.length; i++) arr2D[i] = array(height)
// Can access with arr2D[col][row]
Nope! We usually create our own if one is needed, though you’ll find some occasional functional bliss in discovering situations where you thought you needed one but you don’t.
Welcome to the club. Except for in my case, I’m an inexperienced EE.