How IE <canvas> tag emulation works
The <canvas> tag is the current fangled way of displaying vector graphics in a web browser. Before, all graphics were images, Flash animations, or even thousands of one-pixel <div>s. Finally, Internet browsers have caught up to the 1970s and will be able to draw lines and curves programmatically, and you don't have to pay $699 USD for the priviledge.
At the time of this writing, Internet Explorer at version 8.0 still lacks the <canvas> tag. But you can easily add the capability by including a short javascript file in your page. At first glance, that's astounding. How do you implement an entire vector graphics API in a few lines of Javascript?
Actually, IE has had the ability to do vector graphics for years. For IE 5.0, Microsoft was aware at how useful it would be, and also keenly aware of how long standardization takes, so they went ahead and implemented something called VML (Vector Markup Language), after it had been submitted to the standards process. SVG is simply VML (combined with some competing submissions) after it went through the process of being standardized.
For example, this code will draw an ellipse in VML.
<style>v: * { behavior:url(#default#VML); display:inline-block }</style> <xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v" /> <v:oval style="width:100pt;height:50pt" fillcolor="red"> </v:oval>
In 2005, Emil A Eklund created a simple translation layer in Javascript that emulates canvas.
IE doesn’t support SVG natively either, it does support something called VML though, and it’s been around since the 5.0 days, if I remember correctly. VML does pretty much the same thing as SVG (as far as basic drawing is concerned).So there is it. The ExplorerCanvas script isn't magic. It inserts VML tags into your web page when you call its various drawing routines.Using VML, in combination with behaviors, it should therefor be possible to emulate a subset of SVG or Canvas in IE. That’s the idea I got a few days ago when working on a basic drawing abstraction, and according to Google a few others have thought along those lines as well. Couldn’t find any actual implementation though so I decided to make my own, how hard could it be?
If such implementation could be created it would open up the world of client side drawing to web site developers and allow all kind of neat widgets to be developed.