I am trying to create my own filter in Fabric.js. But I would like to use the Caman.js filter set. I feel like I'm uber here, but can't make it work. Does anyone have any experience combining the two or see where I can go wrong here?
There are no errors in the console. Right now I'm trying to install putImageDatawith new data received from Caman.js ... no luck. However, I can see the data in the console. Help?
(function(global) {
'use strict';
var fabric = global.fabric || (global.fabric = { });
fabric.Image.filters.Lomo = fabric.util.createClass(fabric.Image.filters.BaseFilter, {
type: 'Lomo',
applyTo: function(canvas) {
var context = canvas.getContext("2d");
var width = canvas.width;
var height = canvas.height;
var imageData = context.getImageData(0, 0, width, height);
var c = Caman(canvas, function(value) {
this.lomo().render();
});
Caman.Event.listen(c, 'processComplete', function(job) {
console.log(this.imageData);
context.putImageData(this.imageData, 0, 0);
});
}
});
fabric.Image.filters.Lomo.fromObject = function(object) {
return new fabric.Image.filters.Lomo(object);
};
})(typeof exports !== 'undefined' ? exports : this);
source
share