mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
36 lines
999 B
JavaScript
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. 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}
|
|
*/
|
|
|
|
})();
|