ol 8.1.1-dev.1695384407499 → 8.1.1-dev.1695514538535

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/color.d.ts CHANGED
@@ -13,6 +13,23 @@
13
13
  * @api
14
14
  */
15
15
  export function asString(color: Color | string): string;
16
+ /**
17
+ * @param {Color} color A color that may or may not have an alpha channel.
18
+ * @return {Color} The input color with an alpha channel. If the input color has
19
+ * an alpha channel, the input color will be returned unchanged. Otherwise, a new
20
+ * array will be returned with the input color and an alpha channel of 1.
21
+ */
22
+ export function withAlpha(color: Color): Color;
23
+ /**
24
+ * @param {Color} color RGBA color.
25
+ * @return {Color} LCHuv color with alpha.
26
+ */
27
+ export function rgbaToLcha(color: Color): Color;
28
+ /**
29
+ * @param {Color} color LCHuv color with alpha.
30
+ * @return {Color} RGBA color.
31
+ */
32
+ export function lchaToRgba(color: Color): Color;
16
33
  /**
17
34
  * @param {string} s String.
18
35
  * @return {Color} Color.
package/color.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["color.js"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,gCAJW,QAAM,MAAM,GACX,MAAM,CAQjB;AAoBD;;;GAGG;AACH,8BAHW,MAAM,SA8BhB;AAED;;;;;;GAMG;AACH,+BAJW,QAAM,MAAM,SAStB;AAED;;;;GAIG;AACH,+CAMC;AAED;;;GAGG;AACH,wCAFY,MAAM,CAiBjB;AAED;;;GAGG;AACH,iCAHW,MAAM,GACL,OAAO,CASlB;;;;;;;oBA/HY,MAAM,MAAM,CAAC"}
1
+ {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["color.js"],"names":[],"mappings":"AASA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,gCAJW,QAAM,MAAM,GACX,MAAM,CAQjB;AAoBD;;;;;GAKG;AACH,+CAOC;AAED;;;GAGG;AACH,gDAIC;AAED;;;GAGG;AACH,gDAIC;AAED;;;GAGG;AACH,8BAHW,MAAM,SA8BhB;AAED;;;;;;GAMG;AACH,+BAJW,QAAM,MAAM,SAStB;AAED;;;;GAIG;AACH,+CAMC;AAED;;;GAGG;AACH,wCAFY,MAAM,CAiBjB;AAED;;;GAGG;AACH,iCAHW,MAAM,GACL,OAAO,CASlB;;;;;;;oBAlKY,MAAM,MAAM,CAAC"}
package/color.js CHANGED
@@ -1,7 +1,10 @@
1
1
  /**
2
2
  * @module ol/color
3
3
  */
4
+ import lchuv from 'color-space/lchuv.js';
4
5
  import parseRgba from 'color-rgba';
6
+ import rgb from 'color-space/rgb.js';
7
+ import xyz from 'color-space/xyz.js';
5
8
  import {clamp} from './math.js';
6
9
 
7
10
  /**
@@ -44,6 +47,41 @@ const cache = {};
44
47
  */
45
48
  let cacheSize = 0;
46
49
 
50
+ /**
51
+ * @param {Color} color A color that may or may not have an alpha channel.
52
+ * @return {Color} The input color with an alpha channel. If the input color has
53
+ * an alpha channel, the input color will be returned unchanged. Otherwise, a new
54
+ * array will be returned with the input color and an alpha channel of 1.
55
+ */
56
+ export function withAlpha(color) {
57
+ if (color.length === 4) {
58
+ return color;
59
+ }
60
+ const output = color.slice();
61
+ output[3] = 1;
62
+ return output;
63
+ }
64
+
65
+ /**
66
+ * @param {Color} color RGBA color.
67
+ * @return {Color} LCHuv color with alpha.
68
+ */
69
+ export function rgbaToLcha(color) {
70
+ const output = xyz.lchuv(rgb.xyz(color));
71
+ output[3] = color[3];
72
+ return output;
73
+ }
74
+
75
+ /**
76
+ * @param {Color} color LCHuv color with alpha.
77
+ * @return {Color} RGBA color.
78
+ */
79
+ export function lchaToRgba(color) {
80
+ const output = xyz.rgb(lchuv.xyz(color));
81
+ output[3] = color[3];
82
+ return output;
83
+ }
84
+
47
85
  /**
48
86
  * @param {string} s String.
49
87
  * @return {Color} Color.