2

嗨,我已经设法让 excanvas 在 IE8 中用于简单的示例,但是我无法在 IE8 中制作包含 drawimage 的以下画布示例。有没有人有excanvas和drawimage的经验。谢谢你的帮助...

var foo = document.getElementById("foo");
var canvas = document.createElement('canvas');`

canvas.setAttribute("width", 300);
canvas.setAttribute("height", 300);
foo.appendChild(canvas);
canvas= G_vmlCanvasManager.initElement(canvas);
var ctx = canvas.getContext('2d');
ctx.save();
ctx.clearRect( 0, 0, canvas.width, canvas.height );
ctx.translate( canvas.width/2 , canvas.height/2 );
ctx.drawImage( image, -165, -160 );
ctx.rotate( 100 * Math.PI / 180);
ctx.drawImage( image2, -13, -121.5 );
ctx.restore();

image1.src = 'img.png';
image2.src = 'img2.png';
4

1 回答 1

1

使用测试用例隔离drawImage:

<!DOCTYPE html>
<html>
<head>
<title>Overflow Test</title>
<style>
body {
  text-align: center
}
</style>
<!--[if IE]><script src="https://cdnjs.cloudflare.com/ajax/libs/flot/0.8.3/excanvas.js"></script><![endif]-->
<script>
window.onload = function() {
  var ctx = document.getElementById('c').getContext('2d');
  var img = document.images[0];
  ctx.rotate(Math.PI / 8);
  ctx.drawImage(img, 50, 50);
  img.style.display = 'none';
};
</script>
</head>
<body>

<img src="http://opera.com/favicon.ico">

<canvas id="c" width="200" height="200"></canvas>

</body>
</html>

参考

Explorer Canvas 测试用例:drawimage.html

于 2016-08-24T15:37:15.520 回答