konva/src/filters/Brighten.js
Лаврёнов Антон 71dd7c6abe update global docs
2014-04-14 09:49:10 +08:00

36 lines
999 B
JavaScript

(function() {
/**
* Brighten Filter.
* @function
* @memberof Kinetic.Filters
* @param {Object} imageData
*/
Kinetic.Filters.Brighten = function(imageData) {
var brightness = this.brightness() * 255,
data = imageData.data,
len = data.length,
i;
for(i = 0; i < len; i += 4) {
// red
data[i] += brightness;
// green
data[i + 1] += brightness;
// blue
data[i + 2] += brightness;
}
};
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'brightness', 0, null, Kinetic.Factory.afterSetFilter);
/**
* get/set filter brightness. The brightness is a number between -1 and 1.&nbsp; Positive values
* brighten the pixels and negative values darken them.
* @name brightness
* @method
* @memberof Kinetic.Node.prototype
* @param {Number} brightness value between -1 and 1
* @returns {Number}
*/
})();