One thing to add here is that your example is not very typical. Why
would one do 40 000 1x1 rects when you can do one single rect for
this? There is hardy ever any reason to paint "pixels" using canvas
since the primitives provides you with the basic building blocks you
need.
--
erik
It's pretty normal that excanvas is so slow in this example. Imagine:
Real browsers are simply putting a single pixel into a real 2D context.
But IE (With the help of excanvas) creates a VML element with lots of
attributes and inserts it into the DOM and then the browser draws the
new VML element. And this is done 40000 times.
I think it may be possible to optimize excanvas so your example would
run faster. excanvas could check if it's just going to draw an unrotated
simple filled rectangle and in this case it could simply insert a <div>
with a background color instead of a bloated VML shape element. But I'm
not sure if it's worth the try... Maybe the if statement is going to
slow down excanvas in all other situations.
--
Bye, K <http://www.ailis.de/~k/>
[A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391]
(Finger k...@ailis.de to get public key)
If it's always the case that your canvas has 40000 Pixels which are
accessed separately then maybe you can simply do it without a canvas.
Write some javascript code which generates and positions 40000 div
Elements and store the references into a javascript array. Then you can
set pixels by changing the background color of a specific div. Maybe
this is much faster in IE then creating 40000 VML shapes every time you
update your image.
Here is a demo:
http://www.ailis.de/~k/permdata/20080429/canvas.html
Takes some time to create the 40000 pixels but changing all their colors
in IE7 takes 1-2 seconds on my machine. Maybe this can be optimized
further. Haven't checked that.