When Canvas doesn't cut it: Raphael.js
eng.wealthfront.com
When Canvas doesn't cut it: Raphael.js
1–10 of 11 posts
Re: When Canvas doesn't cut it: Raphael.js
#2For a charting library, you should absolutely use SVG/VML instead of canvas. You don't need the bitmap properties of canvas, canvas doesn't scale well and you can't transform paths like you can with SVG/VML (without redrawing the whole thing).
To do face recognition, bitmap image gymnastics or build an online Photoshop tool, SVG/VML isn't going to cut it though --- you need canvas. Try making a spray paint tool with SVG/VML. Ouch! Using a canvas that's almost trivial.
Good tutorial on using Raphael though. It's a great library.
Re: When Canvas doesn't cut it: Raphael.js
#3it turns there was a bug in IE’s implementation of VML related to radial gradient fills in arbitrary paths... In the end, this was a show-stopper for rendering our pie chart using Raphael
Re: When Canvas doesn't cut it: Raphael.js
#4In canvas's defense, canvas and SVG/VML are different tools for different jobs. For a charting library, you should absolutely use SVG/VML instead of canvas. You don't need the bitmap properties of canvas, canvas doesn't scale well and you can't transform paths like you can with SVG/VML (without redrawing the whole thing). To do face recognition, bitmap image gymnastics or build an online Photoshop tool, SVG/VML isn't…
Re: When Canvas doesn't cut it: Raphael.js
#5Great hands-on discussion. Too bad Raphael had problems with IE: it turns there was a bug in IE’s implementation of VML related to radial gradient fills in arbitrary paths ... In the end, this was a show-stopper for rendering our pie chart using Raphael
Re: When Canvas doesn't cut it: Raphael.js
#6A neat project which renders SVG's in Flash for IE, and fakes in the SVG DOM so you can code against it using JS, is svgweb.
Re: When Canvas doesn't cut it: Raphael.js
#7The problems with it are more related to the cross platform nature like the radial gradients in the article. Also translucent shapes don't seem to be transparent in IE. Another thing that I am missing out on is having some kind of scene graph. Raphael has groups of objects but it is a far cry from what you get in SVG.
Re: When Canvas doesn't cut it: Raphael.js
#8In canvas's defense, canvas and SVG/VML are different tools for different jobs. For a charting library, you should absolutely use SVG/VML instead of canvas. You don't need the bitmap properties of canvas, canvas doesn't scale well and you can't transform paths like you can with SVG/VML (without redrawing the whole thing). To do face recognition, bitmap image gymnastics or build an online Photoshop tool, SVG/VML isn't…
You make good points, however I don't think this entry was particularly negative towards canvas, or merit it needing a defense.
However I have to comment on the "different tools for different jobs" bit, as that is a response that comes up in every NoSQL/SQL discussion as well. If you drew a Venn diagram of the optimal uses of SVG and Canvas, just as with NoSQL/SQL, you're going to have a lot of overlap where it's a judgment call. They are different tools that have arguable merits for a lot of the same jobs, which is why it's important to know about both of them.
Re: When Canvas doesn't cut it: Raphael.js
#9I am confused now about canvas: this article says a downside is redraws, but http://thejit.org uses canvas, stating that it is better for animation.
Re: When Canvas doesn't cut it: Raphael.js
#10For example, I designed a number of subcomponents using rotate and scale operators, then I wanted to use them as parts of the whole. The result is very weird when you first get it as it is only the last transformation of each kind that survives which results in everything thrown all around.
But that said, if you stick to one coordinate system you will be just fine. The animation-hooks and the event-hooks might just be worth it. Just don't try to think vectors and transformations/rotations just because it's vector graphics.
(I ended up using canvas and excanvas for that project which worked fine even though the printouts weren't as pretty)