4 ms·
If you don't like the jaggies in your HTML Canvas pictures, you can make the canvas size be twice as big and use CSS to set its size on the screen back to what
by jws 15y ago
If you don't like the jaggies in your HTML Canvas pictures, you can make the canvas size be twice as big and use CSS to set its size on the screen back to what you want.
Then you get nicely antialiased graphics.
Don't go crazy on the expansion though or iPhone users will hate you.
You should also be careful to drop your endpoints of horizontal and vertical lines on the xxxx.5 boundaries (in screen space) to keep nice sharp lines, otherwise you get a two pixel wide smear.
- charliepark 15y agoAwesome! Thanks for that tip. It hadn't occurred to me that that was possible, but, yeah, that makes sense. I might pick my Canvas experiments back up, then, as R and the other packages are outside the scope of my day-to-day work, but I could see a JS implementation being useful. Thanks again.
- jacobolus 15y agoI recommend you try playing with Protovis. Pretty nice for use cases like this.
- hadley 15y agoOr D3, the child of protovis and SVG.
- apmee 15y agoTo be pedantic, Protovis did also use SVG; it just had a layer of abstraction that somewhat obscured this, whereas D3's lower-level syntax makes it feel like you're manipulating SVG directly (making it a bit more intuitive to learn if you're already familiar with SVG). I'll +1 the recommendation though. D3 is (unsurprisingly, coming from Mike Bostock: http://bost.ocks.org/mike/ http://bost.ocks.org/mike/) brilliant. http://mbostock.github.com/d3/ http://mbostock.github.com/d3/
- sp332 15y agoIs that similar to this hack for faster canvas rendering on iPhone http://29a.ch/2011/5/27/fast-html5-canvas-on-iphone-mobile-safari-performance http://29a.ch/2011/5/27/fast-html5-canvas-on-iphone-mobile-s... or is it completely different?
- MartinCron 15y agoWow. That is a near perfect example of the concept of a clever hack. Thanks for sharing.
- daeken 15y agoHow exactly can you do this? I'm doing some WebGL demos and I've taken to multisampling at the shader level because I couldn't figure out a way to cause the canvas to become larger without actually taking up more screen space.