2 ms·
What's the point of using Uint8ClampedArray instead of just a normal array?
by Kiro 11y ago
What's the point of using Uint8ClampedArray instead of just a normal array?
- onion2k 11y agoTyped arrays are faster. https://hacks.mozilla.org/2011/12/faster-canvas-pixel-manipulation-with-typed-arrays/ https://hacks.mozilla.org/2011/12/faster-canvas-pixel-manipu...
- imaginenore 11y agoasm.js
- zschuessler 11y agoMore than speed, it's easier working with the Uint8ClampedArray since the values correlate to RGB values (0-255). If it was a matter of speed only, the author would have used Uint32Array, which gets the speed benefit of typed arrays but allows for larger values (meaning smaller overall array size, but it's more complex to work with). If you hop down to the annotated source, you can see Uint32Array used here: http://zschuessler.github.io/DeltaE/demos/de76-chroma-key/ http://zschuessler.github.io/DeltaE/demos/de76-chroma-key/