Returns an object that allows get/set grid semantics on the underlying image data.
Uses 8-bit sRGB values, meaning 0..255 range for red, green, blue & opacity.
// Get CANVAS element, drawing context and then image data constcanvasEl = document.querySelector(`#my-canvas`); constctx = canvasEl.getContext(`2d`); constimageData = ctx.getImageData();
// Now that we have image data, we can wrap it: constasGrid = ImageDataGrid.wrap(imageData); asGrid.get({ x:10, y:20 }); // Get pixel at 10,20 asGrid.set(colour, { x:10, y:20 }); // Set pixel value
// Display changes back on the canvas ctx.putImageData(imageData, 0, 0)
Returns an object that allows get/set grid semantics on the underlying
image
data. Uses 8-bit sRGB values, meaning 0..255 range for red, green, blue & opacity.