pwambach / angular-canvas-painter

Angular.js directive to paint on a canvas on desktop or touch devices
MIT License
116 stars 35 forks source link

Dynamically resize the canvas? #15

Closed sebastientromp closed 8 years ago

sebastientromp commented 9 years ago

Hello,

I have started playing with the canvas-painter, and it looks very promising so far :)

The only thing is that I would like the canvas to take the full width of my page, and it seems the options only accept 'px' width. Do you have any plan to support a '%' width?

On a related note, it looks like you can't resize the canvas once it has been instantiated (the only watched options are related to the drawing style). Is there a reason for this?

Thanks for your work! Sébastien

pwambach commented 9 years ago

Hey,

the reason i didn't make the size of the canvas dynamic is that i'm not sure how the image should behave when its canvas is resized.

One option would be to scale the image up or down, which results in a bad quality because its not a vector image.

The other option would be to leave the image as it is and just resize the canvas. The problem here is that if you resize the canvas to a smaller size, the cropped part of the image will be lost. So when you resize the image back to its original size the information is lost.

What is your expected behaviour when changing the canvas size?

Cheers Phil

sebastientromp commented 9 years ago

In my case, I'm resizing the canvas before any drawing actually happens. I had a look at how canvas behave since then, and totally understand the reasons to use only px sizes.

I guess I should programmatically create a canvas once the initial page has been rendered and I know the exact size the canvas should be.

pwambach commented 8 years ago

Yes, create the canvas when you know the size it should have. Dynamic resizing is not possible with the directive.