新しいEaselJS 0.7.0のColorMatrix.clone()
メソッドが、正しくオブジェクトを返しません。
The ColorMatrix.clone()
method of EaselJS 0.7.0 does not properly return a object.
ColorMatrix.clone()
メソッドは、実質的に以下のように実装されています。内部的に呼出しているColorMatrix()
コンストラクタに渡す引数は、オブジェクトでなく数値でなければなりません。
The ColorMatrix.clone()
method is basically implemented as follows. It internally calls the ColorMatrix() constructor, of which arguments should be numbers but not objects.
function ColorMatrix(brightness, contrast, saturation, hue) {
this.initialize(brightness, contrast, saturation, hue);
}
ColorMatrix.IDENTITY_MATRIX = [
1,0,0,0,0,
0,1,0,0,0,
0,0,1,0,0,
0,0,0,1,0,
0,0,0,0,1
];
ColorMatrix.prototype.clone = function() {
return new ColorMatrix(this);
};
ColorMatrix.prototype.initialize = function(brightness,contrast,saturation,hue) {
this.reset();
this.adjustColor(brightness,contrast,saturation,hue);
return this;
};
ColorMatrix.prototype.reset = function() {
return this.copyMatrix(ColorMatrix.IDENTITY_MATRIX);
};
ColorMatrix.prototype.adjustColor = function(brightness,contrast,saturation,hue) {
this.adjustHue(hue);
this.adjustContrast(contrast);
this.adjustBrightness(brightness);
return this.adjustSaturation(saturation);
};
ColorMatrix.prototype.copyMatrix = function(matrix) {
var l = ColorMatrix.LENGTH;
for (var i = 0;i < l;i++) {
this[i] = matrix[i];
}
return this;
};
おそらく、ColorMatrix.clone()
メソッドからは、内部的にColorMatrix.copyMatrix()
メソッドを呼出すのが適切でしょう。[追記: 2013/11/09] EaselJS次期バージョン候補(NEXT)で以下のように修正されます。
The ColorMatrix.clone()
method would have been internally call the ColorMatrix.copyMatrix()
method instead. [P.S.: 2013/11/09] The NEXT version of EaselJS is fixed in the way below.
ColorMatrix.prototype.clone = function() {
// return new ColorMatrix(this);
var clone = new ColorMatrix();
return clone.copyMatrix(this);
};