Creating canvas objects at a higher DPI than screen?
I've got a canvas object that I need to be able to create at a higher resolution than what native screen resolution is. I'm using the Flot graphs library, and I'd ne开发者_如何学JAVAed to output a graph that looks just as good when it's printed as when it's displayed on screen.
The only method I can think of is making the canvas size 3x larger, then scaling, but I don't think that'd work properly when I go to print.
Any ideas?
So you are suggesting that you create a canvas element with a particular width and height (it's native resolution) and scale it to different window coordinates, e.g.:
<canvas width="320" height="240" style="width: 640px; height: 480px"></canvas>
I think a problem with doing this would be that the print renderer may treat the scaled canvas like an image and just render it at document pixel resolution, so you might not get the improvement you want.
For what you want it might be worth finding out if you could use SVG.
Closing the loop on this one - I've found the best option is to create a canvas object at 2x resolution, then scale it using width and height CSS parameters.
精彩评论