canvas resize=true and HiDPI

352 views
Skip to first unread message

Daniel O.

unread,
Dec 1, 2013, 6:45:23 AM12/1/13
to pap...@googlegroups.com
Hi,

I have a problem on HiDPI: when I resize the canvas programmatically (doing it on window.onresize for the canvas to take the whole available space in a container) the graphic created with paper.js get's blurry. I checked the main page of paper.js and noticed that the problem doesn't occur there. Is it because of the resize='true' canvas attribute? How can I achieve something like this in pure JS, can't use PaperScript in the project.

One thing that came to my mind is setting css canvas size to double the size of the canvas, but then I need to check if the device is HiDPI or not, and if the factor is not 2x I will have additional problems.

Cheers,
Daniel

Jürg Lehni

unread,
Dec 1, 2013, 7:51:26 AM12/1/13
to pap...@googlegroups.com
Just use the View#setViewSize() method to resize your canvas instead of directly resizing it. It will take care of handling the HiDPI scaling for you.
> --
> You received this message because you are subscribed to the Google Groups "Paper.js" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to paperjs+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Daniel O.

unread,
Dec 1, 2013, 8:36:12 AM12/1/13
to pap...@googlegroups.com
Great thanks, works great! 
Reply all
Reply to author
Forward
0 new messages