SLCanvas: Now Canvas Tag Support

by Jon Davis 21. February 2010 01:24

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.

  • It’s now called slcanvas.js with a Javascript hashtable namespace of, appropriately, slcanvas.
  • You can now use HTML markup of <canvas>, no conversion/initialization scripting required! The only caveats are:
    1. 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.)
    2. 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 (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:


kick it on


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5



Add comment

(Will show your Gravatar icon)  

  Country flag

  • Comment
  • Preview


Powered by BlogEngine.NET
Theme by Mads Kristensen

About the author

Jon Davis (aka "stimpy77") has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up."

Jon was previously employed as a senior .NET developer at a very well-known Internet services company whom you're more likely than not to have directly done business with. However, this blog and all of have no affiliation with, and are not representative of, his former employer in any way.

Contact Me 

Tag cloud


<<  May 2021  >>

View posts in large calendar