canvas2svg icon indicating copy to clipboard operation
canvas2svg copied to clipboard

Is is possible to convert only a part of the canvas?

Open FrankDaze opened this issue 2 years ago • 5 comments

Is is possible to convert only a specific area of the canvas?

This is a screenshot of a tool where you can select the area that you like to export.

image

I like to build something similar in my own tool.

Thanks in advance Frank

FrankDaze avatar Jul 28 '22 09:07 FrankDaze

Yes, just use the standard canvas clipping operations

murkle avatar Jul 28 '22 09:07 murkle

If I use clip() everything is only drawn inside the clip path, but if I export the canvas, it's still the whole canvas and not only the part in the clip path.

Correct me if I'm wrong.

FrankDaze avatar Jul 28 '22 10:07 FrankDaze

Try it - you can probably set the bounding box and/or the origin in the SVG

murkle avatar Jul 28 '22 11:07 murkle

my idea is now to translate the selected / clipped area to the upper left corner and set the canvas size to the clip size.

I think then I get only the the objects which are drawn in the selection and the file is really small.

thanks for brainstorming

FrankDaze avatar Jul 28 '22 11:07 FrankDaze

@FrankDaze I m also looking for similar solution. I was able to clip the region, but not able to translate to desired location.could you please shared code used for your logic.

jayykumar avatar Sep 09 '22 09:09 jayykumar