这是一个json对象的函数。canvas param是加载了图像的画布,canvasCtx是画布的上下文。问题是,当我移动滑块时,画布只编辑一次,如果我再次移动,则不会发生任何事情。但如果我加上我标记的字符串,一切都很好。为什么?
EditBrightness : function(canvas, canvasCtx)
{
var image = new Image(); // image that is used as default image for current operation
image.onload = function() {
var sliderLayout = "<div header='Brightness'>" +
"<span></span><br />" +
"<div></div>" +
"</div>";
var dialog = $(sliderLayout).dialog();
$('div', dialog).slider({
max : 150,
min : -150,
change : function (event, ui) {
var canvas = $("#edit_canvas")[0]; // <-- Those are
var canvasCtx = canvas.getContext('2d'); // <-- the strings
$('span', dialog).html(ui.value);
canvasCtx.drawImage(image, 0, 0);
Pixastic.process(canvas, "brightness", {
brightness : ui.value
});
}
});
};
image.src = canvas.toDataURL();
}
可能是因为您在显示给我们的代码之外的某个地方更改了传递给此方法的canvas
、canvasCtx
变量。