我想使用camanjs在Phonegap上操作我的画布,但是当我在这里使用这段代码时
function applySunrise(){
Caman("#myCanvas", function () {
this.sunrise();
this.render();
});
}
它会导致如下错误:
Uncaught TypeError: Object function () {
var i, pixel, _i, _len, _ref;
if (this.context == null) {
this.context = this.canvas.getContext('2d');
}
this.originalWidth = this.preScaledWidth
= this.width = this.canvas.width;
this.originalHeight = this.preScaledHeight
= this.height = this.canvas.height;
this.hiDPIAdjustments();
if (!this.hasId()) {
this.assignId();
}
if (this.image != null) {
this.context.drawImage(this.image, 0, 0,
this.imageWidth(), this.imageHeight(), 0,
0, this.preScaledWidth, this.preScaledHeight);
}
this.imageData = this.context.getImageData(0, 0,
this.canvas.width, this.canvas.height);
this.pixelData = this.imageData.data;
if (Caman.allowRevert) {
this.initializedPixelData = Util.dataArray(this.pixelData.length);
this.originalPixelData = Util.dataArray(this.pixelData.length);
_ref = this.pixelData;
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
pixel = _ref[i];
this.initializedPixelData[i] = pixel;
this.originalPixelData[i] = pixel;
}
}
this.dimensions = {
width: this.canvas.width,
height: this.canvas.height
};
Store.put(this.id, this);
this.callback.call(this, this);
return this.callback = function() {};
} has no method 'bind' at file:///android_asset/www/old/js/caman.full.js:219
我正在使用cordova 2.8.1.js
和caman.full.js
,如果有帮助,我还会使用jquery-1.8.3.min.js
和jquery.mobile-1.2.1.min.js
。
答案 0 :(得分:0)
很难从你给出的代码中看出来,但它可能与你在this.sunrise(); this.render();
中使用'this'有关。我看到的唯一另一件事是你可能需要调用new Caman(...);
来实例化一个新对象吗?