p8g icon indicating copy to clipboard operation
p8g copied to clipboard

[Feature]: Direct pixel access

Open bernhardfritz opened this issue 2 years ago • 0 comments

Describe your idea

As requested by finite ape machine https://discord.com/channels/959169147550445598/959169147550445601/1021407778260127754 and iddq_tea on discord https://discord.com/channels/959169147550445598/959169147550445601/1025135923781963826, they would like to have a way to access individual canvas pixels.

p5.js had a loadPixels function which loaded pixels into an array called pixels. They also supported write operations on this array. The internal representation could then be updated using updatePixels.

A more generic way to deal with direct pixel access could as well be achieved by offering an off-screen canvas that can be drawn to the screen by calling canvas.draw(). Pixel write operations can then be achieved by using the p8g functions that you are used to like e.g. point. For pixel read operations yet another function is required.

https://registry.khronos.org/OpenGL-Refpages/gl4/html/glReadPixels.xhtml

bernhardfritz avatar Nov 20 '22 22:11 bernhardfritz