Remove hue, saturation, contrast, and brightness

This commit is contained in:
Tim Schaub
2015-09-21 07:34:41 +09:00
parent 6c5775e6f6
commit d6f03697d7
22 changed files with 46 additions and 1686 deletions

View File

@@ -13,11 +13,7 @@ goog.require('ol.source.State');
* @enum {string}
*/
ol.layer.LayerProperty = {
BRIGHTNESS: 'brightness',
CONTRAST: 'contrast',
HUE: 'hue',
OPACITY: 'opacity',
SATURATION: 'saturation',
VISIBLE: 'visible',
EXTENT: 'extent',
Z_INDEX: 'zIndex',
@@ -29,11 +25,7 @@ ol.layer.LayerProperty = {
/**
* @typedef {{layer: ol.layer.Layer,
* brightness: number,
* contrast: number,
* hue: number,
* opacity: number,
* saturation: number,
* sourceState: ol.source.State,
* visible: boolean,
* managed: boolean,
@@ -67,16 +59,8 @@ ol.layer.Base = function(options) {
* @type {Object.<string, *>}
*/
var properties = goog.object.clone(options);
properties[ol.layer.LayerProperty.BRIGHTNESS] =
options.brightness !== undefined ? options.brightness : 0;
properties[ol.layer.LayerProperty.CONTRAST] =
options.contrast !== undefined ? options.contrast : 1;
properties[ol.layer.LayerProperty.HUE] =
options.hue !== undefined ? options.hue : 0;
properties[ol.layer.LayerProperty.OPACITY] =
options.opacity !== undefined ? options.opacity : 1;
properties[ol.layer.LayerProperty.SATURATION] =
options.saturation !== undefined ? options.saturation : 1;
properties[ol.layer.LayerProperty.VISIBLE] =
options.visible !== undefined ? options.visible : true;
properties[ol.layer.LayerProperty.Z_INDEX] =
@@ -91,48 +75,11 @@ ol.layer.Base = function(options) {
goog.inherits(ol.layer.Base, ol.Object);
/**
* Return the brightness of the layer.
* @return {number} The brightness of the layer.
* @observable
* @api
*/
ol.layer.Base.prototype.getBrightness = function() {
return /** @type {number} */ (this.get(ol.layer.LayerProperty.BRIGHTNESS));
};
/**
* Return the contrast of the layer.
* @return {number} The contrast of the layer.
* @observable
* @api
*/
ol.layer.Base.prototype.getContrast = function() {
return /** @type {number} */ (this.get(ol.layer.LayerProperty.CONTRAST));
};
/**
* Return the hue of the layer.
* @return {number} The hue of the layer.
* @observable
* @api
*/
ol.layer.Base.prototype.getHue = function() {
return /** @type {number} */ (this.get(ol.layer.LayerProperty.HUE));
};
/**
* @return {ol.layer.LayerState} Layer state.
*/
ol.layer.Base.prototype.getLayerState = function() {
var brightness = this.getBrightness();
var contrast = this.getContrast();
var hue = this.getHue();
var opacity = this.getOpacity();
var saturation = this.getSaturation();
var sourceState = this.getSourceState();
var visible = this.getVisible();
var extent = this.getExtent();
@@ -141,11 +88,7 @@ ol.layer.Base.prototype.getLayerState = function() {
var minResolution = this.getMinResolution();
return {
layer: /** @type {ol.layer.Layer} */ (this),
brightness: ol.math.clamp(brightness, -1, 1),
contrast: Math.max(contrast, 0),
hue: hue,
opacity: ol.math.clamp(opacity, 0, 1),
saturation: Math.max(saturation, 0),
sourceState: sourceState,
visible: visible,
managed: true,
@@ -221,17 +164,6 @@ ol.layer.Base.prototype.getOpacity = function() {
};
/**
* Return the saturation of the layer.
* @return {number} The saturation of the layer.
* @observable
* @api
*/
ol.layer.Base.prototype.getSaturation = function() {
return /** @type {number} */ (this.get(ol.layer.LayerProperty.SATURATION));
};
/**
* @return {ol.source.State} Source state.
*/
@@ -261,59 +193,6 @@ ol.layer.Base.prototype.getZIndex = function() {
};
/**
* Adjust the layer brightness. A value of -1 will render the layer completely
* black. A value of 0 will leave the brightness unchanged. A value of 1 will
* render the layer completely white. Other values are linear multipliers on
* the effect (values are clamped between -1 and 1).
*
* The filter effects draft [1] says the brightness function is supposed to
* render 0 black, 1 unchanged, and all other values as a linear multiplier.
*
* The current WebKit implementation clamps values between -1 (black) and 1
* (white) [2]. There is a bug open to change the filter effect spec [3].
*
* TODO: revisit this if the spec is still unmodified before we release
*
* [1] https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html
* [2] https://github.com/WebKit/webkit/commit/8f4765e569
* [3] https://www.w3.org/Bugs/Public/show_bug.cgi?id=15647
*
* @param {number} brightness The brightness of the layer.
* @observable
* @api
*/
ol.layer.Base.prototype.setBrightness = function(brightness) {
this.set(ol.layer.LayerProperty.BRIGHTNESS, brightness);
};
/**
* Adjust the layer contrast. A value of 0 will render the layer completely
* grey. A value of 1 will leave the contrast unchanged. Other values are
* linear multipliers on the effect (and values over 1 are permitted).
*
* @param {number} contrast The contrast of the layer.
* @observable
* @api
*/
ol.layer.Base.prototype.setContrast = function(contrast) {
this.set(ol.layer.LayerProperty.CONTRAST, contrast);
};
/**
* Apply a hue-rotation to the layer. A value of 0 will leave the hue
* unchanged. Other values are radians around the color circle.
* @param {number} hue The hue of the layer.
* @observable
* @api
*/
ol.layer.Base.prototype.setHue = function(hue) {
this.set(ol.layer.LayerProperty.HUE, hue);
};
/**
* Set the extent at which the layer is visible. If `undefined`, the layer
* will be visible at all extents.
@@ -359,21 +238,6 @@ ol.layer.Base.prototype.setOpacity = function(opacity) {
};
/**
* Adjust layer saturation. A value of 0 will render the layer completely
* unsaturated. A value of 1 will leave the saturation unchanged. Other
* values are linear multipliers of the effect (and values over 1 are
* permitted).
*
* @param {number} saturation The saturation of the layer.
* @observable
* @api
*/
ol.layer.Base.prototype.setSaturation = function(saturation) {
this.set(ol.layer.LayerProperty.SATURATION, saturation);
};
/**
* Set the visibility of the layer (`true` or `false`).
* @param {boolean} visible The visibility of the layer.

View File

@@ -215,12 +215,7 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) {
var i, ii, layerState;
for (i = pos, ii = states.length; i < ii; i++) {
layerState = states[i];
layerState.brightness = ol.math.clamp(
layerState.brightness + ownLayerState.brightness, -1, 1);
layerState.contrast *= ownLayerState.contrast;
layerState.hue += ownLayerState.hue;
layerState.opacity *= ownLayerState.opacity;
layerState.saturation *= ownLayerState.saturation;
layerState.visible = layerState.visible && ownLayerState.visible;
layerState.maxResolution = Math.min(
layerState.maxResolution, ownLayerState.maxResolution);