@d3plus/color 3.1.1 → 3.1.3

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/README.md CHANGED
@@ -53,7 +53,7 @@ Live examples can be found on [d3plus.org](https://d3plus.org/), which includes
53
53
 
54
54
  > **colorAdd**(`c1`: `string`, `c2`: `string`, `o1?`: `number`, `o2?`: `number`): `string`
55
55
 
56
- Defined in: [add.ts:10](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/add.ts#L10)
56
+ Defined in: [add.ts:10](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/add.ts#L10)
57
57
 
58
58
  Adds two colors together.
59
59
 
@@ -78,7 +78,7 @@ Adds two colors together.
78
78
 
79
79
  > **colorAssign**(`c`: `string` \| `boolean` \| `null` \| `undefined`, `u?`: `Partial`\<[`ColorDefaults`](#colordefaults)\>): `string`
80
80
 
81
- Defined in: [assign.ts:9](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/assign.ts#L9)
81
+ Defined in: [assign.ts:9](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/assign.ts#L9)
82
82
 
83
83
  Assigns a color to a value using a predefined set of defaults.
84
84
 
@@ -101,7 +101,7 @@ Assigns a color to a value using a predefined set of defaults.
101
101
 
102
102
  > **colorContrast**(`c`: `string`, `u?`: `Partial`\<[`ColorDefaults`](#colordefaults)\>): `string`
103
103
 
104
- Defined in: [contrast.ts:9](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/contrast.ts#L9)
104
+ Defined in: [contrast.ts:9](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/contrast.ts#L9)
105
105
 
106
106
  A set of default color values used when assigning colors based on data.
107
107
 
@@ -124,7 +124,7 @@ A set of default color values used when assigning colors based on data.
124
124
 
125
125
  > **colorLegible**(`c`: `string`): `string`
126
126
 
127
- Defined in: [legible.ts:7](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/legible.ts#L7)
127
+ Defined in: [legible.ts:7](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/legible.ts#L7)
128
128
 
129
129
  Darkens a color so that it will appear legible on a white background.
130
130
 
@@ -146,7 +146,7 @@ Darkens a color so that it will appear legible on a white background.
146
146
 
147
147
  > **colorLighter**(`c`: `string`, `i?`: `number`): `string`
148
148
 
149
- Defined in: [lighter.ts:8](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/lighter.ts#L8)
149
+ Defined in: [lighter.ts:8](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/lighter.ts#L8)
150
150
 
151
151
  Similar to d3.color.brighter, except that this also reduces saturation so that colors don't appear neon.
152
152
 
@@ -169,7 +169,7 @@ Similar to d3.color.brighter, except that this also reduces saturation so that c
169
169
 
170
170
  > **colorSubtract**(`c1`: `string`, `c2`: `string`, `o1?`: `number`, `o2?`: `number`): `string`
171
171
 
172
- Defined in: [subtract.ts:10](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/subtract.ts#L10)
172
+ Defined in: [subtract.ts:10](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/subtract.ts#L10)
173
173
 
174
174
  Subtracts one color from another.
175
175
 
@@ -194,7 +194,7 @@ Subtracts one color from another.
194
194
 
195
195
  > `const` **colorDefaults**: [`ColorDefaults`](#colordefaults)
196
196
 
197
- Defined in: [defaults.ts:37](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/defaults.ts#L37)
197
+ Defined in: [defaults.ts:37](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/defaults.ts#L37)
198
198
 
199
199
  A set of default color values used when assigning colors based on data.
200
200
 
@@ -224,15 +224,15 @@ A set of default color values used when assigning colors based on data.
224
224
 
225
225
  ### ColorDefaults
226
226
 
227
- Defined in: [defaults.ts:6](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/defaults.ts#L6)
227
+ Defined in: [defaults.ts:6](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/defaults.ts#L6)
228
228
 
229
229
  #### Properties
230
230
 
231
231
  | Property | Type | Defined in |
232
232
  | ------ | ------ | ------ |
233
- | <a id="property-dark"></a> `dark` | `string` | [defaults.ts:7](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/defaults.ts#L7) |
234
- | <a id="property-light"></a> `light` | `string` | [defaults.ts:8](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/defaults.ts#L8) |
235
- | <a id="property-missing"></a> `missing` | `string` | [defaults.ts:9](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/defaults.ts#L9) |
236
- | <a id="property-off"></a> `off` | `string` | [defaults.ts:10](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/defaults.ts#L10) |
237
- | <a id="property-on"></a> `on` | `string` | [defaults.ts:11](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/defaults.ts#L11) |
238
- | <a id="property-scale"></a> `scale` | `ScaleOrdinal`\<`string`, `string`\> | [defaults.ts:12](https://github.com/d3plus/d3plus/blob/fe174c3153bf379a226e4a41b6a8492a86c3a1b7/packages/color/src/defaults.ts#L12) |
233
+ | <a id="property-dark"></a> `dark` | `string` | [defaults.ts:7](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/defaults.ts#L7) |
234
+ | <a id="property-light"></a> `light` | `string` | [defaults.ts:8](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/defaults.ts#L8) |
235
+ | <a id="property-missing"></a> `missing` | `string` | [defaults.ts:9](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/defaults.ts#L9) |
236
+ | <a id="property-off"></a> `off` | `string` | [defaults.ts:10](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/defaults.ts#L10) |
237
+ | <a id="property-on"></a> `on` | `string` | [defaults.ts:11](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/defaults.ts#L11) |
238
+ | <a id="property-scale"></a> `scale` | `ScaleOrdinal`\<`string`, `string`\> | [defaults.ts:12](https://github.com/d3plus/d3plus/blob/0405c9f5ac264236505d00e38073b163abf830e5/packages/color/src/defaults.ts#L12) |
package/es/index.js CHANGED
@@ -5,3 +5,5 @@ export { default as colorDefaults } from "./src/defaults.js";
5
5
  export { default as colorLegible } from "./src/legible.js";
6
6
  export { default as colorLighter } from "./src/lighter.js";
7
7
  export { default as colorSubtract } from "./src/subtract.js";
8
+
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts"],"sourcesContent":["export {default as colorAdd} from \"./src/add.js\";\nexport {default as colorAssign} from \"./src/assign.js\";\nexport {default as colorContrast} from \"./src/contrast.js\";\nexport {default as colorDefaults} from \"./src/defaults.js\";\nexport {default as colorLegible} from \"./src/legible.js\";\nexport {default as colorLighter} from \"./src/lighter.js\";\nexport {default as colorSubtract} from \"./src/subtract.js\";\nexport type {ColorDefaults} from \"./src/defaults.js\";\n"],"names":["default","colorAdd","colorAssign","colorContrast","colorDefaults","colorLegible","colorLighter","colorSubtract"],"mappings":"AAAA,SAAQA,WAAWC,QAAQ,QAAO,eAAe;AACjD,SAAQD,WAAWE,WAAW,QAAO,kBAAkB;AACvD,SAAQF,WAAWG,aAAa,QAAO,oBAAoB;AAC3D,SAAQH,WAAWI,aAAa,QAAO,oBAAoB;AAC3D,SAAQJ,WAAWK,YAAY,QAAO,mBAAmB;AACzD,SAAQL,WAAWM,YAAY,QAAO,mBAAmB;AACzD,SAAQN,WAAWO,aAAa,QAAO,oBAAoB"}
package/es/src/add.js CHANGED
@@ -16,3 +16,5 @@ import { hsl } from "d3-color";
16
16
  if (h < 0) h += 360;
17
17
  return hsl("hsl(".concat(h, ",").concat(s * 100, "%,").concat(l * 100, "%)")).toString();
18
18
  }
19
+
20
+ //# sourceMappingURL=add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/add.ts"],"sourcesContent":["import {hsl} from \"d3-color\";\n\n/**\n Adds two colors together.\n @param c1 The first color, a valid CSS color string.\n @param c2 The second color, also a valid CSS color string.\n @param o1 Value from 0 to 1 of the first color's opacity.\n @param o2 Value from 0 to 1 of the first color's opacity.\n*/\nexport default function (\n c1: string,\n c2: string,\n o1: number = 1,\n o2: number = 1,\n): string {\n const hsl1 = hsl(c1);\n const hsl2 = hsl(c2);\n let d: number = Math.abs(hsl2.h * o2 - hsl1.h * o1);\n if (d > 180) d -= 360;\n let h: number = (Math.min(hsl1.h, hsl2.h) + d / 2) % 360;\n const l: number = hsl1.l + (hsl2.l * o2 - hsl1.l * o1) / 2,\n s: number = hsl1.s + (hsl2.s * o2 - hsl1.s * o1) / 2;\n if (h < 0) h += 360;\n return hsl(`hsl(${h},${s * 100}%,${l * 100}%)`).toString();\n}\n"],"names":["hsl","c1","c2","o1","o2","hsl1","hsl2","d","Math","abs","h","min","l","s","toString"],"mappings":"AAAA,SAAQA,GAAG,QAAO,WAAW;AAE7B;;;;;;AAMA,GACA,eAAe,SACbC,EAAU,EACVC,EAAU;QACVC,KAAAA,iEAAa,GACbC,KAAAA,iEAAa;IAEb,IAAMC,OAAOL,IAAIC;IACjB,IAAMK,OAAON,IAAIE;IACjB,IAAIK,IAAYC,KAAKC,GAAG,CAACH,KAAKI,CAAC,GAAGN,KAAKC,KAAKK,CAAC,GAAGP;IAChD,IAAII,IAAI,KAAKA,KAAK;IAClB,IAAIG,IAAY,AAACF,CAAAA,KAAKG,GAAG,CAACN,KAAKK,CAAC,EAAEJ,KAAKI,CAAC,IAAIH,IAAI,CAAA,IAAK;IACrD,IAAMK,IAAYP,KAAKO,CAAC,GAAG,AAACN,CAAAA,KAAKM,CAAC,GAAGR,KAAKC,KAAKO,CAAC,GAAGT,EAAC,IAAK,GACvDU,IAAYR,KAAKQ,CAAC,GAAG,AAACP,CAAAA,KAAKO,CAAC,GAAGT,KAAKC,KAAKQ,CAAC,GAAGV,EAAC,IAAK;IACrD,IAAIO,IAAI,GAAGA,KAAK;IAChB,OAAOV,IAAI,AAAC,OAAWa,OAALH,GAAE,KAAeE,OAAZC,IAAI,KAAI,MAAY,OAARD,IAAI,KAAI,OAAKE,QAAQ;AAC1D"}
package/es/src/assign.js CHANGED
@@ -20,3 +20,5 @@ import defaults from "./defaults.js";
20
20
  return c;
21
21
  }
22
22
  }
23
+
24
+ //# sourceMappingURL=assign.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/assign.ts"],"sourcesContent":["import {color} from \"d3-color\";\nimport defaults, {ColorDefaults} from \"./defaults.js\";\n\n/**\n Assigns a color to a value using a predefined set of defaults.\n @param c A valid CSS color string.\n @param u An object containing overrides of the default colors.\n*/\nexport default function (\n c: string | boolean | null | undefined,\n u: Partial<ColorDefaults> = {},\n): string {\n // If the value is null or undefined, set to grey.\n if ([null, undefined].indexOf(c as null) >= 0)\n return u[\"missing\"] || defaults[\"missing\"];\n // Else if the value is true, set to green.\n else if (c === true) return u[\"on\"] || defaults[\"on\"];\n // Else if the value is false, set to red.\n else if (c === false) return u[\"off\"] || defaults[\"off\"];\n else {\n const p = color(c as string);\n // If the value is not a valid color string, use the color scale.\n if (!p) return (u[\"scale\"] || defaults[\"scale\"])(c as string);\n return c as string;\n }\n}\n"],"names":["color","defaults","c","u","undefined","indexOf","p"],"mappings":"AAAA,SAAQA,KAAK,QAAO,WAAW;AAC/B,OAAOC,cAA+B,gBAAgB;AAEtD;;;;AAIA,GACA,eAAe,SACbC,CAAsC;QACtCC,IAAAA,iEAA4B,CAAC;IAE7B,kDAAkD;IAClD,IAAI;QAAC;QAAMC;KAAU,CAACC,OAAO,CAACH,MAAc,GAC1C,OAAOC,CAAC,CAAC,UAAU,IAAIF,QAAQ,CAAC,UAAU;SAEvC,IAAIC,MAAM,MAAM,OAAOC,CAAC,CAAC,KAAK,IAAIF,QAAQ,CAAC,KAAK;SAEhD,IAAIC,MAAM,OAAO,OAAOC,CAAC,CAAC,MAAM,IAAIF,QAAQ,CAAC,MAAM;SACnD;QACH,IAAMK,IAAIN,MAAME;QAChB,iEAAiE;QACjE,IAAI,CAACI,GAAG,OAAO,AAACH,CAAAA,CAAC,CAAC,QAAQ,IAAIF,QAAQ,CAAC,QAAQ,AAAD,EAAGC;QACjD,OAAOA;IACT;AACF"}
@@ -10,3 +10,5 @@ import { rgb } from "d3-color";
10
10
  var yiq = (rgbColor.r * 299 + rgbColor.g * 587 + rgbColor.b * 114) / 1000;
11
11
  return yiq >= 128 ? u["dark"] || defaults["dark"] : u["light"] || defaults["light"];
12
12
  }
13
+
14
+ //# sourceMappingURL=contrast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/contrast.ts"],"sourcesContent":["import defaults, {ColorDefaults} from \"./defaults.js\";\nimport {rgb} from \"d3-color\";\n\n/**\n A set of default color values used when assigning colors based on data.\n @param c A valid CSS color string.\n @param u An object containing overrides of the default colors.\n*/\nexport default function (c: string, u: Partial<ColorDefaults> = {}): string {\n const rgbColor = rgb(c);\n const yiq: number =\n (rgbColor.r * 299 + rgbColor.g * 587 + rgbColor.b * 114) / 1000;\n return yiq >= 128\n ? u[\"dark\"] || defaults[\"dark\"]\n : u[\"light\"] || defaults[\"light\"];\n}\n"],"names":["defaults","rgb","c","u","rgbColor","yiq","r","g","b"],"mappings":"AAAA,OAAOA,cAA+B,gBAAgB;AACtD,SAAQC,GAAG,QAAO,WAAW;AAE7B;;;;AAIA,GACA,eAAe,SAAUC,CAAS;QAAEC,IAAAA,iEAA4B,CAAC;IAC/D,IAAMC,WAAWH,IAAIC;IACrB,IAAMG,MACJ,AAACD,CAAAA,SAASE,CAAC,GAAG,MAAMF,SAASG,CAAC,GAAG,MAAMH,SAASI,CAAC,GAAG,GAAE,IAAK;IAC7D,OAAOH,OAAO,MACVF,CAAC,CAAC,OAAO,IAAIH,QAAQ,CAAC,OAAO,GAC7BG,CAAC,CAAC,QAAQ,IAAIH,QAAQ,CAAC,QAAQ;AACrC"}
@@ -51,3 +51,5 @@ var openColor = pkg.theme;
51
51
  ])
52
52
  };
53
53
  export default defaults;
54
+
55
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/defaults.ts"],"sourcesContent":["import {ScaleOrdinal, scaleOrdinal} from \"d3-scale\";\n// @ts-ignore\nimport pkg from \"open-color/open-color.js\";\nconst {theme: openColor} = pkg;\n\nexport interface ColorDefaults {\n dark: string;\n light: string;\n missing: string;\n off: string;\n on: string;\n scale: ScaleOrdinal<string, string>;\n}\n\n/**\n * A set of default color values used when assigning colors based on data.\n *\n * @defaultValue\n * ```\n * {\n * dark: \"#495057\",\n * light: \"#f8f9fa\",\n * missing: \"#ced4da\",\n * off: \"#c92a2a\",\n * on: \"#2b8a3e\",\n * scale: d3.scaleOrdinal().range([\n * \"#364fc7\", \"#fab005\", \"#c92a2a\",\n * \"#2b8a3e\", \"#fd7e14\", \"#862e9c\",\n * \"#15aabf\", \"#e64980\", \"#82c91e\",\n * \"#74c0fc\", \"#faa2c1\", \"#c0eb75\",\n * \"#b197fc\", \"#c5f6fa\", \"#ffe8cc\",\n * \"#d3f9d8\", \"#f3d9fa\", \"#ffe3e3\"\n * ])\n * }\n * ```\n */\nconst defaults: ColorDefaults = {\n dark: openColor.colors.gray[700],\n light: openColor.colors.gray[50],\n missing: openColor.colors.gray[400],\n off: openColor.colors.red[900],\n on: openColor.colors.green[900],\n scale: scaleOrdinal<string>().range([\n openColor.colors.indigo[900],\n openColor.colors.yellow[600],\n openColor.colors.red[900],\n openColor.colors.green[900],\n openColor.colors.orange[600],\n openColor.colors.grape[900],\n openColor.colors.cyan[600],\n openColor.colors.pink[600],\n openColor.colors.lime[600],\n openColor.colors.blue[300],\n openColor.colors.pink[300],\n openColor.colors.lime[300],\n openColor.colors.violet[300],\n openColor.colors.cyan[100],\n openColor.colors.orange[100],\n openColor.colors.green[100],\n openColor.colors.grape[100],\n openColor.colors.red[100],\n ]),\n};\n\nexport default defaults;\n"],"names":["scaleOrdinal","pkg","theme","openColor","defaults","dark","colors","gray","light","missing","off","red","on","green","scale","range","indigo","yellow","orange","grape","cyan","pink","lime","blue","violet"],"mappings":"AAAA,SAAsBA,YAAY,QAAO,WAAW;AACpD,aAAa;AACb,OAAOC,SAAS,2BAA2B;AAC3C,IAAOC,AAAOC,YAAaF,IAApBC;AAWP;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,IAAME,WAA0B;IAC9BC,MAAMF,UAAUG,MAAM,CAACC,IAAI,CAAC,IAAI;IAChCC,OAAOL,UAAUG,MAAM,CAACC,IAAI,CAAC,GAAG;IAChCE,SAASN,UAAUG,MAAM,CAACC,IAAI,CAAC,IAAI;IACnCG,KAAKP,UAAUG,MAAM,CAACK,GAAG,CAAC,IAAI;IAC9BC,IAAIT,UAAUG,MAAM,CAACO,KAAK,CAAC,IAAI;IAC/BC,OAAOd,eAAuBe,KAAK,CAAC;QAClCZ,UAAUG,MAAM,CAACU,MAAM,CAAC,IAAI;QAC5Bb,UAAUG,MAAM,CAACW,MAAM,CAAC,IAAI;QAC5Bd,UAAUG,MAAM,CAACK,GAAG,CAAC,IAAI;QACzBR,UAAUG,MAAM,CAACO,KAAK,CAAC,IAAI;QAC3BV,UAAUG,MAAM,CAACY,MAAM,CAAC,IAAI;QAC5Bf,UAAUG,MAAM,CAACa,KAAK,CAAC,IAAI;QAC3BhB,UAAUG,MAAM,CAACc,IAAI,CAAC,IAAI;QAC1BjB,UAAUG,MAAM,CAACe,IAAI,CAAC,IAAI;QAC1BlB,UAAUG,MAAM,CAACgB,IAAI,CAAC,IAAI;QAC1BnB,UAAUG,MAAM,CAACiB,IAAI,CAAC,IAAI;QAC1BpB,UAAUG,MAAM,CAACe,IAAI,CAAC,IAAI;QAC1BlB,UAAUG,MAAM,CAACgB,IAAI,CAAC,IAAI;QAC1BnB,UAAUG,MAAM,CAACkB,MAAM,CAAC,IAAI;QAC5BrB,UAAUG,MAAM,CAACc,IAAI,CAAC,IAAI;QAC1BjB,UAAUG,MAAM,CAACY,MAAM,CAAC,IAAI;QAC5Bf,UAAUG,MAAM,CAACO,KAAK,CAAC,IAAI;QAC3BV,UAAUG,MAAM,CAACa,KAAK,CAAC,IAAI;QAC3BhB,UAAUG,MAAM,CAACK,GAAG,CAAC,IAAI;KAC1B;AACH;AAEA,eAAeP,SAAS"}
package/es/src/legible.js CHANGED
@@ -10,3 +10,5 @@ import { hsl } from "d3-color";
10
10
  }
11
11
  return hslColor.toString();
12
12
  }
13
+
14
+ //# sourceMappingURL=legible.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/legible.ts"],"sourcesContent":["import {hsl} from \"d3-color\";\n\n/**\n Darkens a color so that it will appear legible on a white background.\n @param c A valid CSS color string.\n*/\nexport default function (c: string): string {\n const hslColor = hsl(c);\n if (hslColor.l > 0.45) {\n if (hslColor.s > 0.8) hslColor.s = 0.8;\n hslColor.l = 0.45;\n }\n return hslColor.toString();\n}\n"],"names":["hsl","c","hslColor","l","s","toString"],"mappings":"AAAA,SAAQA,GAAG,QAAO,WAAW;AAE7B;;;AAGA,GACA,eAAe,SAAUC,CAAS;IAChC,IAAMC,WAAWF,IAAIC;IACrB,IAAIC,SAASC,CAAC,GAAG,MAAM;QACrB,IAAID,SAASE,CAAC,GAAG,KAAKF,SAASE,CAAC,GAAG;QACnCF,SAASC,CAAC,GAAG;IACf;IACA,OAAOD,SAASG,QAAQ;AAC1B"}
package/es/src/lighter.js CHANGED
@@ -11,3 +11,5 @@ import { hsl } from "d3-color";
11
11
  hslColor.s -= i;
12
12
  return hslColor.toString();
13
13
  }
14
+
15
+ //# sourceMappingURL=lighter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lighter.ts"],"sourcesContent":["import {hsl} from \"d3-color\";\n\n/**\n Similar to d3.color.brighter, except that this also reduces saturation so that colors don't appear neon.\n @param c A valid CSS color string.\n @param i Strength of the lightening effect, from 0 to 1.\n*/\nexport default function (c: string, i: number = 0.5): string {\n const hslColor = hsl(c);\n i *= 1 - hslColor.l;\n hslColor.l += i;\n hslColor.s -= i;\n return hslColor.toString();\n}\n"],"names":["hsl","c","i","hslColor","l","s","toString"],"mappings":"AAAA,SAAQA,GAAG,QAAO,WAAW;AAE7B;;;;AAIA,GACA,eAAe,SAAUC,CAAS;QAAEC,IAAAA,iEAAY;IAC9C,IAAMC,WAAWH,IAAIC;IACrBC,KAAK,IAAIC,SAASC,CAAC;IACnBD,SAASC,CAAC,IAAIF;IACdC,SAASE,CAAC,IAAIH;IACd,OAAOC,SAASG,QAAQ;AAC1B"}
@@ -18,3 +18,5 @@ import { hsl } from "d3-color";
18
18
  return hsl("hsl(".concat(h, ",").concat(s * 100, "%,").concat(l * 100, "%)")).toString();
19
19
  // return hsl(`hsl(${h},${s * 100}%,${l * 100}%,${a})`).toString();
20
20
  }
21
+
22
+ //# sourceMappingURL=subtract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/subtract.ts"],"sourcesContent":["import {hsl} from \"d3-color\";\n\n/**\n Subtracts one color from another.\n @param c1 The base color, a valid CSS color string.\n @param c2 The color to remove from the base color, also a valid CSS color string.\n @param o1 Value from 0 to 1 of the first color's opacity.\n @param o2 Value from 0 to 1 of the first color's opacity.\n*/\nexport default function (\n c1: string,\n c2: string,\n o1: number = 1,\n o2: number = 1,\n): string {\n const hsl1 = hsl(c1);\n const hsl2 = hsl(c2);\n let d: number = hsl2.h * o2 - hsl1.h * o1;\n if (Math.abs(d) > 180) d -= 360;\n let h: number = (hsl1.h - d) % 360;\n const l: number = hsl1.l - (hsl2.l * o2 - hsl1.l * o1) / 2,\n s: number = hsl1.s - (hsl2.s * o2 - hsl1.s * o1) / 2;\n // a = o1 - (o2 - o1) / 2;\n if (h < 0) h += 360;\n return hsl(`hsl(${h},${s * 100}%,${l * 100}%)`).toString();\n // return hsl(`hsl(${h},${s * 100}%,${l * 100}%,${a})`).toString();\n}\n"],"names":["hsl","c1","c2","o1","o2","hsl1","hsl2","d","h","Math","abs","l","s","toString"],"mappings":"AAAA,SAAQA,GAAG,QAAO,WAAW;AAE7B;;;;;;AAMA,GACA,eAAe,SACbC,EAAU,EACVC,EAAU;QACVC,KAAAA,iEAAa,GACbC,KAAAA,iEAAa;IAEb,IAAMC,OAAOL,IAAIC;IACjB,IAAMK,OAAON,IAAIE;IACjB,IAAIK,IAAYD,KAAKE,CAAC,GAAGJ,KAAKC,KAAKG,CAAC,GAAGL;IACvC,IAAIM,KAAKC,GAAG,CAACH,KAAK,KAAKA,KAAK;IAC5B,IAAIC,IAAY,AAACH,CAAAA,KAAKG,CAAC,GAAGD,CAAAA,IAAK;IAC/B,IAAMI,IAAYN,KAAKM,CAAC,GAAG,AAACL,CAAAA,KAAKK,CAAC,GAAGP,KAAKC,KAAKM,CAAC,GAAGR,EAAC,IAAK,GACvDS,IAAYP,KAAKO,CAAC,GAAG,AAACN,CAAAA,KAAKM,CAAC,GAAGR,KAAKC,KAAKO,CAAC,GAAGT,EAAC,IAAK;IACrD,0BAA0B;IAC1B,IAAIK,IAAI,GAAGA,KAAK;IAChB,OAAOR,IAAI,AAAC,OAAWY,OAALJ,GAAE,KAAeG,OAAZC,IAAI,KAAI,MAAY,OAARD,IAAI,KAAI,OAAKE,QAAQ;AACxD,mEAAmE;AACrE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d3plus/color",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "description": "Color functions that extent the ability of d3-color.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,5 +1,5 @@
1
1
  /*
2
- @d3plus/color v3.1.0
2
+ @d3plus/color v3.1.2
3
3
  Color functions that extent the ability of d3-color.
4
4
  Copyright (c) 2026 D3plus - https://d3plus.org
5
5
  @license MIT
@@ -1,5 +1,5 @@
1
1
  /*
2
- @d3plus/color v3.1.0
2
+ @d3plus/color v3.1.2
3
3
  Color functions that extent the ability of d3-color.
4
4
  Copyright (c) 2026 D3plus - https://d3plus.org
5
5
  @license MIT
@@ -1,5 +1,5 @@
1
1
  /*
2
- @d3plus/color v3.1.0
2
+ @d3plus/color v3.1.2
3
3
  Color functions that extent the ability of d3-color.
4
4
  Copyright (c) 2026 D3plus - https://d3plus.org
5
5
  @license MIT
@@ -1,5 +1,5 @@
1
1
  /*
2
- @d3plus/color v3.1.0
2
+ @d3plus/color v3.1.2
3
3
  Color functions that extent the ability of d3-color.
4
4
  Copyright (c) 2026 D3plus - https://d3plus.org
5
5
  @license MIT