What is the problem or limitation you are having?
I am building an app in which a preview of a document is displayed onscreen that is drawn using Canvas; however, I needed the ability to export that preview onto an arbitrarily-sized image.
Describe the solution you'd like
A size parameter on as_image of Canvas that lets you export a scaled view of the Canvas.
This will be implemented in most backends by scaling the Canvas before rendering onto an image; reset_transform must be handled appropriately. Cocoa and iOS allows for setting a different logical size for an image than the physical size, which can be useful to implement this
Describe alternatives you've considered
- Status quo. One must manually resize the canvas, wait for layout, and then grab the image, and then reset image.
- An canvas-like API on toga.Image that allows directly annotating an image.
Additional context
A desktop implementation (with some additional fixes) without reset_transform support lives in johnzhou721/togax-frost, my personal component library. It has been used in johnzhou721/tiler successfully.
What is the problem or limitation you are having?
I am building an app in which a preview of a document is displayed onscreen that is drawn using Canvas; however, I needed the ability to export that preview onto an arbitrarily-sized image.
Describe the solution you'd like
A size parameter on as_image of Canvas that lets you export a scaled view of the Canvas.
This will be implemented in most backends by scaling the Canvas before rendering onto an image; reset_transform must be handled appropriately. Cocoa and iOS allows for setting a different logical size for an image than the physical size, which can be useful to implement this
Describe alternatives you've considered
Additional context
A desktop implementation (with some additional fixes) without reset_transform support lives in johnzhou721/togax-frost, my personal component library. It has been used in johnzhou721/tiler successfully.