I'm trying do add contrast as a filter to KineticJS (I know, it's not a filter technically). It works, but I want to add contrast()
modifier too (like noise()
for Noise filter etc.).
Here is my function (after including KineticJS 5.0.1 library):
(function() {
Kinetic.Filters.Contrast = function(imageData) {
var data = imageData.data,
len = data.length,
i,
adjust = this.contrast(),
x = [];
//[cut] processing, not important here
};
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'contrast', 0, null, Kinetic.Factory.afterSetFilter);
})();
As you can see, Kinetic.Factory.addGetterSetter
should provide me contrast()
modifier, but it doesn't. When I run the code, resuls is TypeError: imgs.contrast is not a function
:
imgs.filters([Kinetic.Filters.Contrast]);
imgs.contrast(30);
What I'm doing wrong?
//update
My temporary solution: just put my function into kineticJS file. Not perfect, but it works.