gpt4 book ai didi

javascript - excanvas drawimage 不适用于 IE8

转载 作者:行者123 更新时间:2023-11-30 05:49:28 26 4
gpt4 key购买 nike

您好,对于简单的示例,我已经设法使 excanvas 在 IE8 中工作,但是我无法使以下包含 drawimage 的 Canvas 示例在 IE8 中工作。有没有人有使用 excanvas 和 drawimage 的经验。感谢您的帮助...

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

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

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

最佳答案

使用测试用例隔离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 test cases: drawimage.html

关于javascript - excanvas drawimage 不适用于 IE8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15816263/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com