Skip to content

extract plugin improvement suggestion #8114

@bchevalier

Description

@bchevalier

Hello,

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    📢 Accepting PRsWould welcome a PR from the community.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions