Finite Numbers and ExplorerCanvas

Posted by PhubarBaz on Geeks with Blogs See other posts from Geeks with Blogs or by PhubarBaz
Published on Thu, 03 Jun 2010 08:41:23 GMT Indexed on 2010/06/03 14:56 UTC
Read the original article Hit count: 200

Filed under:

I was working on my online mathematical graphing application, CloudGraph, and trying to make it work in IE. The app uses the HTML5 canvas element to draw graphs. Since IE doesn't support canvas yet I use ExplorerCanvas to provide that support for IE. However, it seems that when using excanvas, if you try to moveTo or drawTo a point that is not finite it loses it's mind and stops drawing anything else after that. I had no such problems in Firefox or Chrome so it took me awhile to figure out what was going on.

Next I discovered that I needed a way to check if a variable was NaN or Inifinity or any other non-finite value so I could avoid calling moveTo() in that case. I started writing a long if statement, then I thought there has to be a better way. Sure enough there was. There just happens to be an isFinite() function built into Javascript just for this purpose. Who knew! It works great.

Another difference I discovered with excanvas is that you must specify a starting point using a moveTo() when beginning a drawing path. Again, Chrome and Firefox are a lot more forgiving in this area so it took me a while to figure out why my lines weren't drawing. But, all is happy now and I'm a little wiser to the ways of the canvas.

© Geeks with Blogs or respective owner