You are reading a single comment by @dwallersv and its replies. Click here to read the full conversation.
  • Thanks for the quick reply, Gordon. I have considered the solution of simply extending the Uint8Array prototype, and in the end of that's the only way, I'll do it. Memory footprint trumps OO elegance for this sort of application.

    I've not given up yet, though. Check out this: Extending JavaScript Arrays While Keeping Native Bracket-Notation Functionality

    I'm playing with this idea as we speak, and will report back on the memory usage if successful. If I can get it to allocate the same amount of memory per instance as simply creating a 4-element Uint8Array -- solved!

    If that doesn't work, I'll take a look at the packing approach you talk about -- a "color" in this scheme is 4 bytes -- one word. A less elegant solution is to simply add member to the Uint8Array prototype called 'color', then bury all the color-related methods in there as properties of the color object, on the prototype.

About

Avatar for dwallersv @dwallersv started