santilland/plotty

about the image position

wukong-c opened this issue · 2 comments

Can support custom image location?eg: Ctx. putImageData (imageData, x, y);

Hi cpgood,
supporting putImageData is not quite a trivial implementation as plotty uses a 3d context for fast rendering where there is no such option.
If you only need to render something once and performance is not too critical you could disable use of WebGL when creating your instance, then you could access the normal 2d context where you can use putImageData directly in the following way:

plot = new plotty.plot({
    canvas: el, width: width, height: height,
    domain: [min_range, max_range], colorScale: "viridis",
    useWebGL: false
});

plot.addDataset('dataset1', exampledata, width, height);
plot.ctx.putImageData(imageData, dx, dy);

plot.render();

I have not tested this, but i think it should work.

**Edit:
Maybe you need to first render and then use putImageData as rendering maybe overwrites the imagedata.

All right, i will close the issue for now as i have not gotten any answer, in any case i hope you managed to do what you intended to do, if there any other points let me know.