作为主题。我想旋转一个对象,但我不想让它移动到任何地方,只需旋转它并将其留在原处。函数 draw 只是绘制矩形。
<!DOCTYPE html>
<html>
<head>
<script>
var ctx, canvas;
window.onload = function(){
canvas = document.getElementById('myCanvas');
ctx = canvas.getContext('2d');
//sciana
draw();
}
function draw() {
//ctx.scale(0.5,0.5);
ctx.rotate(Math.PI /6);//here I rotate but it moves...
ctx.fillRect( 100, 100, 50, 50);
}
</script>
</head>
<body>
<canvas id="myCanvas" width="600" height="600" style="background-color:#D0D0D0">
Twoja przeglądarka nie obsługuje elementu Canvas.
</canvas>
</body>
</html>