forked from openlayers/openlayers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolorlike.js
29 lines (27 loc) · 813 Bytes
/
colorlike.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* @module ol/colorlike
*/
import {toString} from './color.js';
/**
* A type accepted by CanvasRenderingContext2D.fillStyle
* or CanvasRenderingContext2D.strokeStyle.
* Represents a color, pattern, or gradient. The origin for patterns and
* gradients as fill style is an increment of 512 css pixels from map coordinate
* `[0, 0]`. For seamless repeat patterns, width and height of the pattern image
* must be a factor of two (2, 4, 8, ..., 512).
*
* @typedef {string|CanvasPattern|CanvasGradient} ColorLike
* @api
*/
/**
* @param {import("./color.js").Color|ColorLike} color Color.
* @return {ColorLike} The color as an {@link ol/colorlike~ColorLike}.
* @api
*/
export function asColorLike(color) {
if (Array.isArray(color)) {
return toString(color);
} else {
return color;
}
}