Named exports from ol/colorlike
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
* @module ol/colorlike
|
||||
*/
|
||||
import _ol_color_ from './color.js';
|
||||
var _ol_colorlike_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -10,24 +9,23 @@ var _ol_colorlike_ = {};
|
||||
* @return {ol.ColorLike} The color as an ol.ColorLike
|
||||
* @api
|
||||
*/
|
||||
_ol_colorlike_.asColorLike = function(color) {
|
||||
if (_ol_colorlike_.isColorLike(color)) {
|
||||
export function asColorLike(color) {
|
||||
if (isColorLike(color)) {
|
||||
return /** @type {string|CanvasPattern|CanvasGradient} */ (color);
|
||||
} else {
|
||||
return _ol_color_.asString(/** @type {ol.Color} */ (color));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {?} color The value that is potentially an ol.ColorLike
|
||||
* @return {boolean} Whether the color is an ol.ColorLike
|
||||
*/
|
||||
_ol_colorlike_.isColorLike = function(color) {
|
||||
export function isColorLike(color) {
|
||||
return (
|
||||
typeof color === 'string' ||
|
||||
color instanceof CanvasPattern ||
|
||||
color instanceof CanvasGradient
|
||||
);
|
||||
};
|
||||
export default _ol_colorlike_;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import {inherits} from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import _ol_colorlike_ from '../../colorlike.js';
|
||||
import {asColorLike} from '../../colorlike.js';
|
||||
import {intersects} from '../../extent.js';
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
import SimpleGeometry from '../../geom/SimpleGeometry.js';
|
||||
@@ -829,7 +829,7 @@ _ol_render_canvas_Immediate_.prototype.setFillStrokeStyle = function(fillStyle,
|
||||
} else {
|
||||
var fillStyleColor = fillStyle.getColor();
|
||||
this.fillState_ = {
|
||||
fillStyle: _ol_colorlike_.asColorLike(fillStyleColor ?
|
||||
fillStyle: asColorLike(fillStyleColor ?
|
||||
fillStyleColor : _ol_render_canvas_.defaultFillStyle)
|
||||
};
|
||||
}
|
||||
@@ -856,7 +856,7 @@ _ol_render_canvas_Immediate_.prototype.setFillStrokeStyle = function(fillStyle,
|
||||
strokeStyleWidth : _ol_render_canvas_.defaultLineWidth),
|
||||
miterLimit: strokeStyleMiterLimit !== undefined ?
|
||||
strokeStyleMiterLimit : _ol_render_canvas_.defaultMiterLimit,
|
||||
strokeStyle: _ol_colorlike_.asColorLike(strokeStyleColor ?
|
||||
strokeStyle: asColorLike(strokeStyleColor ?
|
||||
strokeStyleColor : _ol_render_canvas_.defaultStrokeStyle)
|
||||
};
|
||||
}
|
||||
@@ -912,7 +912,7 @@ _ol_render_canvas_Immediate_.prototype.setTextStyle = function(textStyle) {
|
||||
} else {
|
||||
var textFillStyleColor = textFillStyle.getColor();
|
||||
this.textFillState_ = {
|
||||
fillStyle: _ol_colorlike_.asColorLike(textFillStyleColor ?
|
||||
fillStyle: asColorLike(textFillStyleColor ?
|
||||
textFillStyleColor : _ol_render_canvas_.defaultFillStyle)
|
||||
};
|
||||
}
|
||||
@@ -940,7 +940,7 @@ _ol_render_canvas_Immediate_.prototype.setTextStyle = function(textStyle) {
|
||||
textStrokeStyleWidth : _ol_render_canvas_.defaultLineWidth,
|
||||
miterLimit: textStrokeStyleMiterLimit !== undefined ?
|
||||
textStrokeStyleMiterLimit : _ol_render_canvas_.defaultMiterLimit,
|
||||
strokeStyle: _ol_colorlike_.asColorLike(textStrokeStyleColor ?
|
||||
strokeStyle: asColorLike(textStrokeStyleColor ?
|
||||
textStrokeStyleColor : _ol_render_canvas_.defaultStrokeStyle)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {getUid, inherits, nullFunction} from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import _ol_colorlike_ from '../../colorlike.js';
|
||||
import {asColorLike} from '../../colorlike.js';
|
||||
import {buffer, clone, coordinateRelationship, createEmpty, createOrUpdate,
|
||||
createOrUpdateEmpty, extend, extendCoordinate, intersects} from '../../extent.js';
|
||||
import Relationship from '../../extent/Relationship.js';
|
||||
@@ -912,14 +912,14 @@ _ol_render_canvas_Replay_.prototype.setFillStrokeStyle = function(fillStyle, str
|
||||
var state = this.state;
|
||||
if (fillStyle) {
|
||||
var fillStyleColor = fillStyle.getColor();
|
||||
state.fillStyle = _ol_colorlike_.asColorLike(fillStyleColor ?
|
||||
state.fillStyle = asColorLike(fillStyleColor ?
|
||||
fillStyleColor : _ol_render_canvas_.defaultFillStyle);
|
||||
} else {
|
||||
state.fillStyle = undefined;
|
||||
}
|
||||
if (strokeStyle) {
|
||||
var strokeStyleColor = strokeStyle.getColor();
|
||||
state.strokeStyle = _ol_colorlike_.asColorLike(strokeStyleColor ?
|
||||
state.strokeStyle = asColorLike(strokeStyleColor ?
|
||||
strokeStyleColor : _ol_render_canvas_.defaultStrokeStyle);
|
||||
var strokeStyleLineCap = strokeStyle.getLineCap();
|
||||
state.lineCap = strokeStyleLineCap !== undefined ?
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/render/canvas/TextReplay
|
||||
*/
|
||||
import {getUid, inherits} from '../../index.js';
|
||||
import _ol_colorlike_ from '../../colorlike.js';
|
||||
import {asColorLike} from '../../colorlike.js';
|
||||
import {createCanvasContext2D} from '../../dom.js';
|
||||
import {intersects} from '../../extent.js';
|
||||
import _ol_geom_flat_straightchunk_ from '../../geom/flat/straightchunk.js';
|
||||
@@ -478,7 +478,7 @@ _ol_render_canvas_TextReplay_.prototype.setTextStyle = function(textStyle, declu
|
||||
if (!fillState) {
|
||||
fillState = this.textFillState_ = /** @type {ol.CanvasFillState} */ ({});
|
||||
}
|
||||
fillState.fillStyle = _ol_colorlike_.asColorLike(
|
||||
fillState.fillStyle = asColorLike(
|
||||
textFillStyle.getColor() || _ol_render_canvas_.defaultFillStyle);
|
||||
}
|
||||
|
||||
@@ -503,7 +503,7 @@ _ol_render_canvas_TextReplay_.prototype.setTextStyle = function(textStyle, declu
|
||||
lineWidth === undefined ? _ol_render_canvas_.defaultLineWidth : lineWidth;
|
||||
strokeState.miterLimit =
|
||||
miterLimit === undefined ? _ol_render_canvas_.defaultMiterLimit : miterLimit;
|
||||
strokeState.strokeStyle = _ol_colorlike_.asColorLike(
|
||||
strokeState.strokeStyle = asColorLike(
|
||||
textStrokeStyle.getColor() || _ol_render_canvas_.defaultStrokeStyle);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/render/webgl/TextReplay
|
||||
*/
|
||||
import {getUid, inherits} from '../../index.js';
|
||||
import _ol_colorlike_ from '../../colorlike.js';
|
||||
import {asColorLike} from '../../colorlike.js';
|
||||
import {createCanvasContext2D} from '../../dom.js';
|
||||
import GeometryType from '../../geom/GeometryType.js';
|
||||
import _ol_has_ from '../../has.js';
|
||||
@@ -359,7 +359,7 @@ _ol_render_webgl_TextReplay_.prototype.setTextStyle = function(textStyle) {
|
||||
state.fillColor = null;
|
||||
} else {
|
||||
var textFillStyleColor = textFillStyle.getColor();
|
||||
state.fillColor = _ol_colorlike_.asColorLike(textFillStyleColor ?
|
||||
state.fillColor = asColorLike(textFillStyleColor ?
|
||||
textFillStyleColor : _ol_render_webgl_.defaultFillStyle);
|
||||
}
|
||||
if (!textStrokeStyle) {
|
||||
@@ -367,7 +367,7 @@ _ol_render_webgl_TextReplay_.prototype.setTextStyle = function(textStyle) {
|
||||
state.lineWidth = 0;
|
||||
} else {
|
||||
var textStrokeStyleColor = textStrokeStyle.getColor();
|
||||
state.strokeColor = _ol_colorlike_.asColorLike(textStrokeStyleColor ?
|
||||
state.strokeColor = asColorLike(textStrokeStyleColor ?
|
||||
textStrokeStyleColor : _ol_render_webgl_.defaultStrokeStyle);
|
||||
state.lineWidth = textStrokeStyle.getWidth() || _ol_render_webgl_.defaultLineWidth;
|
||||
state.lineCap = textStrokeStyle.getLineCap() || _ol_render_webgl_.defaultLineCap;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/style/RegularShape
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_colorlike_ from '../colorlike.js';
|
||||
import {asColorLike} from '../colorlike.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import _ol_has_ from '../has.js';
|
||||
import _ol_ImageState_ from '../ImageState.js';
|
||||
@@ -327,7 +327,7 @@ _ol_style_RegularShape_.prototype.render_ = function(atlasManager) {
|
||||
if (strokeStyle === null) {
|
||||
strokeStyle = _ol_render_canvas_.defaultStrokeStyle;
|
||||
}
|
||||
strokeStyle = _ol_colorlike_.asColorLike(strokeStyle);
|
||||
strokeStyle = asColorLike(strokeStyle);
|
||||
strokeWidth = this.stroke_.getWidth();
|
||||
if (strokeWidth === undefined) {
|
||||
strokeWidth = _ol_render_canvas_.defaultLineWidth;
|
||||
@@ -457,7 +457,7 @@ _ol_style_RegularShape_.prototype.draw_ = function(renderOptions, context, x, y)
|
||||
if (color === null) {
|
||||
color = _ol_render_canvas_.defaultFillStyle;
|
||||
}
|
||||
context.fillStyle = _ol_colorlike_.asColorLike(color);
|
||||
context.fillStyle = asColorLike(color);
|
||||
context.fill();
|
||||
}
|
||||
if (this.stroke_) {
|
||||
|
||||
Reference in New Issue
Block a user