extract plugin improvement suggestion
See original GitHub issueHello,
This is to suggest an improvement to the extract plugin API.
What I am trying to achieve is fetching a single pixel from an offscreen rendered container. For this purpose, I use the extract image API.
By extracting the image and then rendering it into a canvas I can then read the desired pixel. However, I only need a single pixel from the image and therefore this solution is overkill.
Here is the current usage of the extract.image
API:
const image = renderer.plugins['extract'].image(container);
The extract.pixels
API is probably faster but still overkill. However it is made unusable by the fact that it is impossible to know the dimensions of the image that the pixels represent:
const pixels = renderer.plugins['extract'].pixels(container);
The pixels
object is an array, it contains no information on width or height.
Ideally, the extract.pixels
and extract.image
APIs would accept a scale, a position and a dimension:
const pixels = renderer.plugins['extract'].pixels(spineView.parent, scale, x, y, width, height);
The position and dimension would determine which part of the container to clip for extraction purposes. And the scale would define the scaling ratio of the rendering. For instance a 200x300 clipped extraction with a scale of 0.5 would generate a pixel buffer corresponding to a 100x150px dimension.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
exactly, as suggested above: https://github.com/pixijs/pixijs/issues/8114#issuecomment-1021993657
Use an options object with this many arguments. There are too many arguments here to remember the order, so object is better.