Dynamic initialization canvas

60 views
Skip to first unread message
Message has been deleted

Mikhailov Denis

unread,
Oct 30, 2007, 4:07:08 AM10/30/07
to google-excanvas
The text translated through "Google translate".

Dynamic creation and initialization canvas now in the current version
of the library excanvas.js:

var canvas = document.createElement("canvas");
canvas.width = 100;
canvas.height = 100;

// dynamical initialize canvas
if (/msie/i.test(navigator.userAgent))
{
canvas.id = "myCanvas";
document.body.appendChild(canvas);
G_vmlCanvasManager.initElement(canvas);
canvas = document.getElementById("myCanvas");
}
else
{
document.body.appendChild(canvas);
}

var ctx = canvas.getContext("2d");
ctx.fillRect(25, 25, 50, 50);

Dynamic creation and initialization canvas in a modified version of my
library excanvas.js:

var canvas = excanvas(document.createElement("canvas"));
canvas.width = 100;
canvas.height = 100;

var ctx = canvas.getContext("2d");
ctx.fillRect(25, 25, 50, 50);

document.body.appendChild(canvas);

Repro code: http://groups.google.com/group/google-excanvas/web/DynamicInitializationCanvas.zip

Reply all
Reply to author
Forward
0 new messages