ol 9.0.0-dev.1699990564210 → 9.0.0-dev.1700073859078
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/colorlike.d.ts +38 -7
- package/colorlike.d.ts.map +1 -1
- package/colorlike.js +76 -4
- package/dist/ol.js +2 -2
- package/dist/ol.js.map +1 -1
- package/dom.d.ts +4 -0
- package/dom.d.ts.map +1 -1
- package/dom.js +13 -0
- package/expr/cpu.d.ts +4 -0
- package/expr/cpu.d.ts.map +1 -1
- package/expr/cpu.js +4 -0
- package/package.json +1 -1
- package/render/canvas/Builder.d.ts.map +1 -1
- package/render/canvas/Builder.js +8 -2
- package/render/canvas/Executor.d.ts +2 -2
- package/render/canvas/Executor.d.ts.map +1 -1
- package/render/canvas/Executor.js +12 -10
- package/render/canvas/TextBuilder.d.ts.map +1 -1
- package/render/canvas/TextBuilder.js +6 -5
- package/render/canvas/style.d.ts.map +1 -1
- package/render/canvas/style.js +71 -10
- package/render/canvas.d.ts +5 -0
- package/render/canvas.d.ts.map +1 -1
- package/render/canvas.js +1 -0
- package/renderer/vector.d.ts.map +1 -1
- package/renderer/vector.js +14 -4
- package/style/Fill.d.ts +27 -13
- package/style/Fill.d.ts.map +1 -1
- package/style/Fill.js +53 -6
- package/style/Icon.d.ts.map +1 -1
- package/style/Icon.js +4 -0
- package/style/IconImage.d.ts +21 -11
- package/style/IconImage.d.ts.map +1 -1
- package/style/IconImage.js +52 -11
- package/style/IconImageCache.d.ts +25 -5
- package/style/IconImageCache.d.ts.map +1 -1
- package/style/IconImageCache.js +54 -11
- package/style/Image.d.ts +4 -0
- package/style/Image.d.ts.map +1 -1
- package/style/Image.js +7 -0
- package/style/RegularShape.d.ts +1 -0
- package/style/RegularShape.d.ts.map +1 -1
- package/style/RegularShape.js +12 -1
- package/style/flat.d.ts +19 -0
- package/style/flat.d.ts.map +1 -1
- package/style/flat.js +5 -0
- package/util.js +1 -1
package/colorlike.d.ts
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} PatternDescriptor
|
|
3
|
+
* @property {string} src Pattern image URL
|
|
4
|
+
* @property {import("./color.js").Color|string} [color] Color to tint the pattern with.
|
|
5
|
+
* @property {import("./size.js").Size} [size] Size of the desired slice from the pattern image.
|
|
6
|
+
* Use this together with `offset` when the pattern image is a sprite sheet.
|
|
7
|
+
* @property {import("./size.js").Size} [offset] Offset of the desired slice from the pattern image.
|
|
8
|
+
* Use this together with `size` when the pattern image is a sprite sheet.
|
|
9
|
+
*/
|
|
1
10
|
/**
|
|
2
11
|
* A type accepted by CanvasRenderingContext2D.fillStyle
|
|
3
12
|
* or CanvasRenderingContext2D.strokeStyle.
|
|
4
|
-
* Represents a color,
|
|
5
|
-
*
|
|
13
|
+
* Represents a color, [CanvasPattern](https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern),
|
|
14
|
+
* or [CanvasGradient](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient). The origin for
|
|
15
|
+
* patterns and gradients as fill style is an increment of 512 css pixels from map coordinate
|
|
6
16
|
* `[0, 0]`. For seamless repeat patterns, width and height of the pattern image
|
|
7
17
|
* must be a factor of two (2, 4, 8, ..., 512).
|
|
8
18
|
*
|
|
@@ -10,16 +20,37 @@
|
|
|
10
20
|
* @api
|
|
11
21
|
*/
|
|
12
22
|
/**
|
|
13
|
-
* @param {import("./color.js").Color|ColorLike} color Color.
|
|
14
|
-
* @return {ColorLike} The color as an {@link ol/colorlike~ColorLike}.
|
|
23
|
+
* @param {import("./color.js").Color|ColorLike|PatternDescriptor|null} color Color.
|
|
24
|
+
* @return {ColorLike|null} The color as an {@link ol/colorlike~ColorLike}.
|
|
15
25
|
* @api
|
|
16
26
|
*/
|
|
17
|
-
export function asColorLike(color: import("./color.js").Color | ColorLike): ColorLike;
|
|
27
|
+
export function asColorLike(color: import("./color.js").Color | ColorLike | PatternDescriptor | null): ColorLike | null;
|
|
28
|
+
export type PatternDescriptor = {
|
|
29
|
+
/**
|
|
30
|
+
* Pattern image URL
|
|
31
|
+
*/
|
|
32
|
+
src: string;
|
|
33
|
+
/**
|
|
34
|
+
* Color to tint the pattern with.
|
|
35
|
+
*/
|
|
36
|
+
color?: string | import("./color.js").Color | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Size of the desired slice from the pattern image.
|
|
39
|
+
* Use this together with `offset` when the pattern image is a sprite sheet.
|
|
40
|
+
*/
|
|
41
|
+
size?: import("./size.js").Size | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Offset of the desired slice from the pattern image.
|
|
44
|
+
* Use this together with `size` when the pattern image is a sprite sheet.
|
|
45
|
+
*/
|
|
46
|
+
offset?: import("./size.js").Size | undefined;
|
|
47
|
+
};
|
|
18
48
|
/**
|
|
19
49
|
* A type accepted by CanvasRenderingContext2D.fillStyle
|
|
20
50
|
* or CanvasRenderingContext2D.strokeStyle.
|
|
21
|
-
* Represents a color,
|
|
22
|
-
*
|
|
51
|
+
* Represents a color, [CanvasPattern](https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern),
|
|
52
|
+
* or [CanvasGradient](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient). The origin for
|
|
53
|
+
* patterns and gradients as fill style is an increment of 512 css pixels from map coordinate
|
|
23
54
|
* `[0, 0]`. For seamless repeat patterns, width and height of the pattern image
|
|
24
55
|
* must be a factor of two (2, 4, 8, ..., 512).
|
|
25
56
|
*/
|
package/colorlike.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorlike.d.ts","sourceRoot":"","sources":["colorlike.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"colorlike.d.ts","sourceRoot":"","sources":["colorlike.js"],"names":[],"mappings":"AASA;;;;;;;;GAQG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;GAIG;AACH,mCAJW,OAAO,YAAY,EAAE,KAAK,GAAC,SAAS,GAAC,iBAAiB,GAAC,IAAI,GAC1D,SAAS,GAAC,IAAI,CAczB;;;;;SArCa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;wBAiBP,MAAM,GAAC,aAAa,GAAC,cAAc"}
|
package/colorlike.js
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module ol/colorlike
|
|
3
3
|
*/
|
|
4
|
+
import ImageState from './ImageState.js';
|
|
5
|
+
import {createCanvasContext2D} from './dom.js';
|
|
6
|
+
import {get as getIconImage} from './style/IconImage.js';
|
|
7
|
+
import {shared as iconCache} from './style/IconImageCache.js';
|
|
4
8
|
import {toString} from './color.js';
|
|
5
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {Object} PatternDescriptor
|
|
12
|
+
* @property {string} src Pattern image URL
|
|
13
|
+
* @property {import("./color.js").Color|string} [color] Color to tint the pattern with.
|
|
14
|
+
* @property {import("./size.js").Size} [size] Size of the desired slice from the pattern image.
|
|
15
|
+
* Use this together with `offset` when the pattern image is a sprite sheet.
|
|
16
|
+
* @property {import("./size.js").Size} [offset] Offset of the desired slice from the pattern image.
|
|
17
|
+
* Use this together with `size` when the pattern image is a sprite sheet.
|
|
18
|
+
*/
|
|
19
|
+
|
|
6
20
|
/**
|
|
7
21
|
* A type accepted by CanvasRenderingContext2D.fillStyle
|
|
8
22
|
* or CanvasRenderingContext2D.strokeStyle.
|
|
9
|
-
* Represents a color,
|
|
10
|
-
*
|
|
23
|
+
* Represents a color, [CanvasPattern](https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern),
|
|
24
|
+
* or [CanvasGradient](https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient). The origin for
|
|
25
|
+
* patterns and gradients as fill style is an increment of 512 css pixels from map coordinate
|
|
11
26
|
* `[0, 0]`. For seamless repeat patterns, width and height of the pattern image
|
|
12
27
|
* must be a factor of two (2, 4, 8, ..., 512).
|
|
13
28
|
*
|
|
@@ -16,13 +31,70 @@ import {toString} from './color.js';
|
|
|
16
31
|
*/
|
|
17
32
|
|
|
18
33
|
/**
|
|
19
|
-
* @param {import("./color.js").Color|ColorLike} color Color.
|
|
20
|
-
* @return {ColorLike} The color as an {@link ol/colorlike~ColorLike}.
|
|
34
|
+
* @param {import("./color.js").Color|ColorLike|PatternDescriptor|null} color Color.
|
|
35
|
+
* @return {ColorLike|null} The color as an {@link ol/colorlike~ColorLike}.
|
|
21
36
|
* @api
|
|
22
37
|
*/
|
|
23
38
|
export function asColorLike(color) {
|
|
39
|
+
if (!color) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
24
42
|
if (Array.isArray(color)) {
|
|
25
43
|
return toString(color);
|
|
26
44
|
}
|
|
45
|
+
if (typeof color === 'object' && 'src' in color) {
|
|
46
|
+
return asCanvasPattern(color);
|
|
47
|
+
}
|
|
27
48
|
return color;
|
|
28
49
|
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param {PatternDescriptor} pattern Pattern descriptor.
|
|
53
|
+
* @return {CanvasPattern|null} Canvas pattern or null if the pattern referenced in the
|
|
54
|
+
* PatternDescriptor was not found in the icon image cache.
|
|
55
|
+
*/
|
|
56
|
+
function asCanvasPattern(pattern) {
|
|
57
|
+
if (!pattern.offset || !pattern.size) {
|
|
58
|
+
return iconCache.getPattern(pattern.src, 'anonymous', pattern.color);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const cacheKey = pattern.src + ':' + pattern.offset;
|
|
62
|
+
|
|
63
|
+
const canvasPattern = iconCache.getPattern(
|
|
64
|
+
cacheKey,
|
|
65
|
+
undefined,
|
|
66
|
+
pattern.color
|
|
67
|
+
);
|
|
68
|
+
if (canvasPattern) {
|
|
69
|
+
return canvasPattern;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const iconImage = iconCache.get(pattern.src, 'anonymous', null);
|
|
73
|
+
if (iconImage.getImageState() !== ImageState.LOADED) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const patternCanvasContext = createCanvasContext2D(
|
|
77
|
+
pattern.size[0],
|
|
78
|
+
pattern.size[1]
|
|
79
|
+
);
|
|
80
|
+
patternCanvasContext.drawImage(
|
|
81
|
+
iconImage.getImage(1),
|
|
82
|
+
pattern.offset[0],
|
|
83
|
+
pattern.offset[1],
|
|
84
|
+
pattern.size[0],
|
|
85
|
+
pattern.size[1],
|
|
86
|
+
0,
|
|
87
|
+
0,
|
|
88
|
+
pattern.size[0],
|
|
89
|
+
pattern.size[1]
|
|
90
|
+
);
|
|
91
|
+
getIconImage(
|
|
92
|
+
patternCanvasContext.canvas,
|
|
93
|
+
cacheKey,
|
|
94
|
+
undefined,
|
|
95
|
+
ImageState.LOADED,
|
|
96
|
+
pattern.color,
|
|
97
|
+
true
|
|
98
|
+
);
|
|
99
|
+
return iconCache.getPattern(cacheKey, undefined, pattern.color);
|
|
100
|
+
}
|