Ahoy StackOverflow!
I ve run into the following problem: on IE7 only, if I call drawImage() after drawing anything to the canvas, excanvas does not draw the image at the desired x,y coordinates. I have looked on the excanvas project page/ google group, and found that there are known issues with the drawImage() function. ( for example: http://code.google.com/p/explorercanvas/issues/detail?id=104&q=IE7 )
我已尝试恢复身份表,如下文所示:。 Excanvas vmlpositioning issue,尽管看来没有效果。
附有一份简单的html文件,表明这一问题:
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="excanvas.js"></script>
<script type="text/javascript">
window.onload = function(){
var icon, ctx;
icon = new Image();
icon.width = "20";
icon.height = "20";
icon.src = "http://www.shangalulu.com/resources/images/icons/small/30.png";
icon.onload = function(){
var ctx;
ctx = document.getElementById( the_canvas ).getContext( 2d );
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(500,0);
ctx.lineTo(500,500);
ctx.lineTo(0,500);
ctx.lineTo(0,0);
ctx.moveTo(200,200);
ctx.lineTo(300,200);
ctx.lineTo(300,300);
ctx.lineTo(200,300);
ctx.lineTo(200,200);
ctx.moveTo(0,0);
ctx.lineTo(500,500);
ctx.moveTo(0,500);
ctx.lineTo(500,0);
ctx.stroke();
ctx.drawImage(icon, 190, 190, 20, 20);
ctx.drawImage(icon, 240, 240, 20, 20);
ctx.drawImage(icon, 290, 290, 20, 20);
return;
}
}
</script>
</head>
<body>
<canvas id="the_canvas" width="500" height="500"></canvas>
</body>
</html>
如果您需要外查斯图书馆来管理,你可以在此追索:。
上述文字应当做到如下:
- it should draw an outline of the outer edges of the canvas (so you can see it)
- it should draw a 100x100 rectangle in the middle of the canvas.
- it should draw two lines that cross through the center of the canvas.
- it should draw three images: one on the top left corner of the inner box, one at the center, and one on the bottom right corner of the inner box.
我知道的是:是否有人知道这个问题的拼凑/工作?