In a previous post, I mentioned that I snagged the HTML5Canvas on Silverlight code from delay’s blog [1, 2] and put it up on CodePlex. I’ve been hoping others would join in on some cooperative interest to evolve what “delay” (the original author) did, but I’m completely unsurprised that no one did. Meanwhile, I took a couple evenings—one a couple weeks ago plus tonight—to finally evolve the script a bit.
- You can now use HTML markup of <canvas>, no conversion/initialization scripting required! The only caveats are:
- You must add the attribute of renderMethod=”Silverlight” or renderMethod=”auto” to the <canvas> tag. Specifying “auto” will allow the loader to use the native canvas functionality if it’s available and use Silverlight if it’s not, while specifying “silverlight” will more or less replace the <canvas> tag with a Silverlight instance outright. (I’m thinking about changing this attribute to renderer=”..” or something else. I was going to seek feedback on the official canvas developers group list but I’m still waiting for my membership to be approved by the moderator. Feel free to post a comment about your preference here.)
- Any canvas-executing code must execute after window.load has occurred, or you can populate an onload attribute on the <canvas> tag which will allow script to be executed after slcanvas.js has converted the tag properly.
With these important changes, I posted the original test page, with a few tweaks such as the second Silverlight test replaced with a <canvas renderMethod=”Silverlight”></canvas> tag, at the following URL:
The changes I made to allow for the <canvas renderMethod=”Silverlight”> tag execution have been tested in IE6, IE8, Firefox 3.6, Google Chrome 126.96.36.199 (beta), Opera 10, and Safari 4.
I have not yet created a release of these changes yet on CodePlex, you can access everything from trunk. It's now released.
The project is maintained here, and anyone else is welcome to get involved: http://slcanvas.codeplex.com/