我有一个带有图像的 Canvas 元素。
现在我尝试在单击按钮时旋转 Canvas 中的图像:
$("#rotateC").live('click',function(e) {
e.preventDefault();
console.log("rotateC");
Pixastic.process(firstImg, 'rotate',
{
'angle': +90,
'leaveDOM': true
},
function(firstImg) {
ctx.drawImage(firstImg, 0, 0);
}
);
});
图像将旋转一次,然后如果我再次单击该按钮,则什么也不会发生。
你知道问题出在哪里吗?
最佳答案
可以看看How to rotate with pixastic jquery和 his demo在 jquery 中解决你的问题! (希望你没问题)
$(function(){
$('#rotate').live('click',function() {
$("#img1").pixastic("rotate", {angle:90});
});
});
如果你的按钮有 id rotate
并且你的图像有 id img1
应该可以工作
关于javascript - 使用 Pixastic 旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9910086/