當您使用畫布旋轉圖像時,它會被切斷 - 我如何避免這種情況?我已經將畫布元素製作得更大一些,但它仍然會切掉邊緣。如何避免圖像中斷<canvas>旋轉?
例子:
<html>
<head>
<title>test</title>
<script type="text/javascript">
function startup() {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var img = new Image();
img.src = 'player.gif';
img.onload = function() {
ctx.rotate(5 * Math.PI/180);
ctx.drawImage(img, 0, 0, 64, 120);
}
}
</script>
</head>
<body onload='startup();'>
<canvas id="canvas" style="position: absolute; left: 300px; top: 300px;" width="800" height="800"></canvas>
</body>
</html>