mirror of
https://github.com/konvajs/konva.git
synced 2025-10-14 20:04:52 +08:00
Added HSL filter.
This commit is contained in:
@@ -86,4 +86,41 @@
|
||||
* @param {Number} value 1 is no change, 0.5 halves the value, 2.0 doubles, etc..
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Node, 'luminance', 1, null, Kinetic.Factory.afterSetFilter);
|
||||
/**
|
||||
* get/set hsl luminance
|
||||
* @name value
|
||||
* @method
|
||||
* @memberof Kinetic.Node.prototype
|
||||
* @param {Number} value 1 is no change, 0.5 halves the value, 2.0 doubles, etc..
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
/**
|
||||
* HSL Filter. Adjusts the hue, saturation and luminance (or lightness)
|
||||
* @function
|
||||
* @memberof Kinetic.Filters
|
||||
* @param {Object} imageData
|
||||
* @author ippo615
|
||||
*/
|
||||
|
||||
Kinetic.Filters.HSL = function (imageData) {
|
||||
// Hue stays the same but saturation, value and brightness will be
|
||||
// adjusted to match common photo-editing software's extreme values
|
||||
var oldSaturation = this.saturation(),
|
||||
oldBrightness = this.brightness(),
|
||||
oldValue = this.value();
|
||||
|
||||
this.saturation(oldSaturation*oldSaturation);
|
||||
this.brightness(0.5*(this.luminance()-1));
|
||||
this.value(1.0);
|
||||
|
||||
Kinetic.Filters.HSV.call(this,imageData);
|
||||
Kinetic.Filters.Brighten.call(this,imageData);
|
||||
|
||||
this.saturation(oldSaturation);
|
||||
this.brightness(oldBrightness);
|
||||
this.value(oldValue);
|
||||
};
|
||||
})();
|
||||
|
Reference in New Issue
Block a user