Types and Datastructures


Does the pixelblaze languge support any sort of types or datastructures?

Rather than do:

pixels_h = array(pixelCount)
pixels_s = array(pixelCount)
pixels_v = array(pixelCount)

It would be much better if we could do:

interface hsv {
  h = 0
  s = 0
  v = 0

pixels = array(pixelCount, hsv)

I’m guessing this is something that’s been considered before?

(Also I know you can pack rgb or hsv into a double type in various ways, but let’s face it that’s pretty hacky!)

Even if this is possible (or too hard) for generic structures, it would still be handy for the special case of RGB!

This is a cool idea, but Pixelblaze is currently a subset of modern JavaScript, whereas I think interface comes from TypeScript and is a superset / additional keyword.

right, JavaScript doesn’t have any formal typing.

If you wanted a JavaScript-y solution you’d allow for objects. I can see that being more problematic though. Hence my idea of just stealing a small part from Typescript.

I guess that would be nice, but for me an array of 3 values is just fine:

// RGB framebuffer Storage
var FB = array(pixelCount)
FB.mutate(()=>{return array(3)})

// ... later, calculate r g b and ...

    var Pixel = FB[x + y * width]
    Pixel[0] = max(Pixel[0], r)
    Pixel[1] = max(Pixel[1], g)
    Pixel[2] = max(Pixel[2], b)