Javascript 使用KineticJS旋转层内的图像或层本身
我有一个阶段的尺寸800x600初始化如下Javascript 使用KineticJS旋转层内的图像或层本身,javascript,image,rotation,kineticjs,Javascript,Image,Rotation,Kineticjs,我有一个阶段的尺寸800x600初始化如下 stage = new Kinetic.Stage({ width:800, height:600, container:'container' }); backgroundLayer = new Kinetic.Layer({ width:800, height:600, visible:true, draggable:true, }); imageObj = new Image() im
stage = new Kinetic.Stage({
width:800,
height:600,
container:'container'
});
backgroundLayer = new Kinetic.Layer({
width:800,
height:600,
visible:true,
draggable:true,
});
imageObj = new Image()
image.src = "../path/to/image/"
imageObj.onload = function (){
backgroundImage = new Kinetic.Image({
image:imageObj,
width:800,
height:600,
offset: {x: 400, y:300}
});
backgroundLayer.add(backgroundImage);
}
然后我像这样初始化一个背景层
stage = new Kinetic.Stage({
width:800,
height:600,
container:'container'
});
backgroundLayer = new Kinetic.Layer({
width:800,
height:600,
visible:true,
draggable:true,
});
imageObj = new Image()
image.src = "../path/to/image/"
imageObj.onload = function (){
backgroundImage = new Kinetic.Image({
image:imageObj,
width:800,
height:600,
offset: {x: 400, y:300}
});
backgroundLayer.add(backgroundImage);
}
还有像这样的图像对象
stage = new Kinetic.Stage({
width:800,
height:600,
container:'container'
});
backgroundLayer = new Kinetic.Layer({
width:800,
height:600,
visible:true,
draggable:true,
});
imageObj = new Image()
image.src = "../path/to/image/"
imageObj.onload = function (){
backgroundImage = new Kinetic.Image({
image:imageObj,
width:800,
height:600,
offset: {x: 400, y:300}
});
backgroundLayer.add(backgroundImage);
}
我将图像添加到背景层和舞台层
stage.add(backgroundLayer);
使用这样的偏移设置会使图像仅出现在舞台的上角,并且必须拖动它才能看到它。如果我旋转一个图像,前一个图像仍然在那里(未旋转),直到我拖动它。因此,我的问题是: