考虑以下代码:
var stage = new Kinetic.Stage({
container : "container",
width : 600,
height : 200
});
var layer = new Kinetic.Layer();
// one revolution per 4 seconds
var angularSpeed = Math.PI / 2;
var imageObj = new Image();
var image = {};
imageObj.onload = function() {
image = new Kinetic.Image({
x : 500,
y : 135,
image : imageObj,
width : 99,
height : 99,
offsetX: 0,
offsetY: 0
});
image.rotation = 0;
layer.add(image);
stage.add(layer);
stage.onFrame(function(frame) {
var angleDiff = frame.timeDiff * angularSpeed / 1000;
image.rotateDeg(angleDiff);
layer.draw();
});
stage.start();
};
imageObj.src = "images/tire-brands.png";
如何使图像就地旋转,例如 360 度,但枢轴点在中心?
所以,当我制作图像对象时,目标是让动画在那里运行。目前它只在一侧旋转图像。