@pixerate/editor 0.249.0 → 0.251.0
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/dist/agent/index.cjs +40 -41
- package/dist/agent/index.js +9 -10
- package/dist/animation/index.cjs +6 -7
- package/dist/animation/index.js +5 -6
- package/dist/animation-editor/index.cjs +124 -123
- package/dist/animation-editor/index.js +15 -14
- package/dist/brushes/index.cjs +1406 -0
- package/dist/brushes/index.d.cts +12 -0
- package/dist/brushes/index.d.ts +12 -0
- package/dist/brushes/index.js +1406 -0
- package/dist/brushes/migrate.d.cts +17 -0
- package/dist/brushes/migrate.d.ts +17 -0
- package/dist/brushes/normalize.d.cts +15 -0
- package/dist/brushes/normalize.d.ts +15 -0
- package/dist/brushes/presets.d.cts +12 -0
- package/dist/brushes/presets.d.ts +12 -0
- package/dist/brushes/resolve.d.cts +56 -0
- package/dist/brushes/resolve.d.ts +56 -0
- package/dist/brushes/schema.d.cts +29 -0
- package/dist/brushes/schema.d.ts +29 -0
- package/dist/brushes/types.d.cts +323 -0
- package/dist/brushes/types.d.ts +323 -0
- package/dist/{brushstrokeRender-T3JZST44.js → brushstrokeRender-5PYSKZIJ.js} +9 -8
- package/dist/{brushstrokeRender-GCKK7V2I.cjs → brushstrokeRender-7FLLSQEC.cjs} +15 -14
- package/dist/canvas/index.cjs +120 -65
- package/dist/canvas/index.d.cts +1 -0
- package/dist/canvas/index.d.ts +1 -0
- package/dist/canvas/index.js +88 -33
- package/dist/canvas/stickers.d.cts +35 -0
- package/dist/canvas/stickers.d.ts +35 -0
- package/dist/chart/index.cjs +159 -160
- package/dist/chart/index.js +9 -10
- package/dist/{chunk-RXZL4NG5.js → chunk-226QDRO3.js} +1 -1
- package/dist/{chunk-DOIU7VJG.js → chunk-2ZJ4DT3M.js} +1 -1
- package/dist/{chunk-XZNU4DUX.cjs → chunk-3NS5C7FB.cjs} +76 -76
- package/dist/{chunk-UTI5IITZ.cjs → chunk-4ZC5QJE2.cjs} +3 -3
- package/dist/{chunk-L3JFOTBQ.js → chunk-5E2Q7ZHI.js} +1 -1
- package/dist/{chunk-6BIDVPED.js → chunk-5JNA6LLY.js} +1 -1
- package/dist/{chunk-RD7RX52G.cjs → chunk-5UEFBM2M.cjs} +207 -18
- package/dist/{chunk-WA44NKPF.js → chunk-62Z5WLRA.js} +1 -1
- package/dist/{chunk-BVRRIW7F.js → chunk-6GRUVGKU.js} +3 -3
- package/dist/{chunk-QARCM66V.js → chunk-6ZZKRH7R.js} +3 -3
- package/dist/{chunk-BP6KSGVD.js → chunk-7272D3K2.js} +4 -6
- package/dist/{chunk-O75V4ZS3.js → chunk-7P6VF3FG.js} +2 -2
- package/dist/{chunk-AU6MWQKZ.js → chunk-ABL7IWFZ.js} +1 -1
- package/dist/{chunk-5RH3VXAK.js → chunk-APX63ILU.js} +4 -100
- package/dist/{chunk-W7L4HUT2.cjs → chunk-CJ6TBL2N.cjs} +16 -16
- package/dist/{chunk-7PT4RJL5.cjs → chunk-EUIDTZNQ.cjs} +111 -113
- package/dist/{chunk-CXXXAZ7H.js → chunk-F6R67I3A.js} +1 -1
- package/dist/{chunk-I7NJPHWV.cjs → chunk-FQPUF2W2.cjs} +35 -606
- package/dist/{chunk-D5KGAO4Z.js → chunk-GCVFEPJG.js} +2 -573
- package/dist/{chunk-LEQKZGQI.js → chunk-GOBOCZZI.js} +1 -1
- package/dist/{chunk-PZP2SZIZ.js → chunk-GYMMNCFT.js} +3 -3
- package/dist/{chunk-NUTMINJZ.cjs → chunk-H7ET2ISK.cjs} +52 -52
- package/dist/chunk-HS6QDWDF.cjs +1029 -0
- package/dist/{chunk-T7KQEMAE.cjs → chunk-HUAISCUX.cjs} +18 -18
- package/dist/{chunk-YGQVCQTG.js → chunk-ILP77UD6.js} +1 -1
- package/dist/{chunk-GHCSC2WP.cjs → chunk-ISIO63Q5.cjs} +21 -15
- package/dist/{chunk-S6OT6CTS.cjs → chunk-IWEVV63O.cjs} +31 -33
- package/dist/{chunk-OFH6Q67U.js → chunk-JA57JIT5.js} +9 -3
- package/dist/{chunk-LP2MCSBE.cjs → chunk-JFHBXNR2.cjs} +88 -88
- package/dist/{chunk-IOFVM3L3.cjs → chunk-JPEHXIB5.cjs} +10 -10
- package/dist/chunk-JSDND7DF.cjs +173 -0
- package/dist/{chunk-36ZTV7WO.js → chunk-L6Y7TSQ4.js} +1 -1
- package/dist/{chunk-KYX7NZ5V.cjs → chunk-LFMKWGFL.cjs} +1 -1
- package/dist/{chunk-V6DT2CDH.js → chunk-M2TPMYJE.js} +1 -1
- package/dist/{chunk-LJZRHVZV.cjs → chunk-M5GLQQWG.cjs} +2 -2
- package/dist/{chunk-JEGJP4OW.js → chunk-MHLU6GRJ.js} +196 -7
- package/dist/{chunk-KMPM5JM5.js → chunk-MONXNVZK.js} +4 -6
- package/dist/chunk-MTKY6K3Q.js +1029 -0
- package/dist/{chunk-MOW3JMNG.cjs → chunk-N76AMOKE.cjs} +42 -42
- package/dist/{chunk-75K3W4D6.cjs → chunk-NKGB64CW.cjs} +16 -16
- package/dist/{chunk-SGPIVHJB.js → chunk-P3K2JCJA.js} +3 -3
- package/dist/chunk-PXDIAYB6.cjs +594 -0
- package/dist/{chunk-UBRJOIR5.js → chunk-QC3OXRE4.js} +9 -9
- package/dist/{chunk-QOBCBGGI.cjs → chunk-QKXO6JPP.cjs} +14 -14
- package/dist/{chunk-WLJZZHUZ.cjs → chunk-QLSGTCYT.cjs} +23 -23
- package/dist/{chunk-7YW7T5TJ.js → chunk-RHPSE2YR.js} +2 -2
- package/dist/{chunk-44BMJJVA.cjs → chunk-RUONPPMC.cjs} +8 -8
- package/dist/{chunk-LJRCU3BJ.cjs → chunk-SABJMH6M.cjs} +150 -15
- package/dist/{chunk-XWOLPNBW.cjs → chunk-SOSBOS5T.cjs} +22 -22
- package/dist/chunk-SZTI6EER.js +13 -0
- package/dist/{chunk-PPFJHTW5.cjs → chunk-TFF2GTGN.cjs} +22 -24
- package/dist/{chunk-2SMMZDMG.cjs → chunk-TLOGFIIV.cjs} +37 -37
- package/dist/chunk-TXFWZ5ZJ.js +594 -0
- package/dist/chunk-U67EN7GG.cjs +13 -0
- package/dist/{chunk-GXAK6Q5J.js → chunk-UFEDHACQ.js} +2 -2
- package/dist/{chunk-GA4EU4P3.cjs → chunk-UXETV2NC.cjs} +4 -4
- package/dist/{chunk-N4DFDI73.js → chunk-WKMUBATU.js} +1 -1
- package/dist/{chunk-3R5P3DVY.cjs → chunk-WRZ6C4TU.cjs} +6 -6
- package/dist/{chunk-EJLRBS5Q.js → chunk-WZOGDKCQ.js} +137 -2
- package/dist/{chunk-6ADHGQ73.js → chunk-YBAPT7NL.js} +2 -4
- package/dist/{chunk-K5DS2JTA.cjs → chunk-Z3BRH4JK.cjs} +6 -6
- package/dist/{chunk-XNZFVYC2.cjs → chunk-ZBCT5MEA.cjs} +7 -7
- package/dist/color/index.cjs +4 -6
- package/dist/color/index.js +7 -9
- package/dist/effects/helpers.d.cts +6 -0
- package/dist/effects/helpers.d.ts +6 -0
- package/dist/effects/index.cjs +62 -60
- package/dist/effects/index.js +5 -3
- package/dist/effects/tools.d.cts +6 -0
- package/dist/effects/tools.d.ts +6 -0
- package/dist/export/index.cjs +7 -8
- package/dist/export/index.js +6 -7
- package/dist/extensions/index.cjs +10 -11
- package/dist/extensions/index.js +9 -10
- package/dist/gradient/index.cjs +33 -34
- package/dist/gradient/index.js +4 -5
- package/dist/image-editor/effects.d.cts +1 -1
- package/dist/image-editor/effects.d.ts +1 -1
- package/dist/image-editor/index.cjs +887 -863
- package/dist/image-editor/index.d.cts +1 -0
- package/dist/image-editor/index.d.ts +1 -0
- package/dist/image-editor/index.js +69 -45
- package/dist/image-editor/stickers.d.cts +9 -0
- package/dist/image-editor/stickers.d.ts +9 -0
- package/dist/index.cjs +16 -17
- package/dist/index.js +10 -11
- package/dist/paint/index.cjs +6 -4
- package/dist/paint/index.js +21 -19
- package/dist/paint-editor/brushes.d.cts +1 -2
- package/dist/paint-editor/brushes.d.ts +1 -2
- package/dist/paint-editor/index.cjs +2199 -699
- package/dist/paint-editor/index.js +1577 -77
- package/dist/paint-editor/mark-settings.d.cts +104 -0
- package/dist/paint-editor/mark-settings.d.ts +104 -0
- package/dist/paint-editor/procedural.d.cts +2 -75
- package/dist/paint-editor/procedural.d.ts +2 -75
- package/dist/paint-editor/stickers.d.cts +1 -22
- package/dist/paint-editor/stickers.d.ts +1 -22
- package/dist/raster/index.cjs +2 -2
- package/dist/raster/index.js +9 -9
- package/dist/stickers/index.cjs +22 -16
- package/dist/stickers/index.d.cts +1 -1
- package/dist/stickers/index.d.ts +1 -1
- package/dist/stickers/index.js +14 -8
- package/dist/stickers/tools.d.cts +57 -1
- package/dist/stickers/tools.d.ts +57 -1
- package/dist/tokens/index.cjs +3 -4
- package/dist/tokens/index.js +2 -3
- package/dist/typography/index.cjs +7 -8
- package/dist/typography/index.js +2 -3
- package/dist/vector/index.cjs +1011 -977
- package/dist/vector/index.d.cts +1 -0
- package/dist/vector/index.d.ts +1 -0
- package/dist/vector/index.js +47 -13
- package/dist/vector/stickers.d.cts +11 -0
- package/dist/vector/stickers.d.ts +11 -0
- package/dist/video-editor/index.cjs +349 -350
- package/dist/video-editor/index.js +9 -10
- package/package.json +11 -1
- package/skills/pixerate-image-editor/SKILL.md +1 -1
- package/skills/pixerate-stickers/SKILL.md +13 -1
- package/dist/chunk-7AHBW2CQ.cjs +0 -200
- package/dist/chunk-F67XMVDI.js +0 -200
- package/dist/chunk-H4AOUUBE.cjs +0 -2635
- package/dist/chunk-J7T5QZ45.js +0 -2635
- package/dist/chunk-ZEYMKDYS.cjs +0 -269
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createEffectAuthoringSession
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-ABL7IWFZ.js";
|
|
4
4
|
import {
|
|
5
5
|
VIDEO_ADJUSTMENT_SCOPES,
|
|
6
6
|
VIDEO_BLEND_MODES,
|
|
@@ -149,7 +149,7 @@ import {
|
|
|
149
149
|
videoTransitionEase,
|
|
150
150
|
videoValueAt,
|
|
151
151
|
videoWipeRect
|
|
152
|
-
} from "../chunk-
|
|
152
|
+
} from "../chunk-5E2Q7ZHI.js";
|
|
153
153
|
import {
|
|
154
154
|
namedWithSuggestion
|
|
155
155
|
} from "../chunk-EUKY4KFX.js";
|
|
@@ -159,7 +159,7 @@ import {
|
|
|
159
159
|
effectSequenceTiming,
|
|
160
160
|
effectTemplateTools,
|
|
161
161
|
fillEffectTemplate
|
|
162
|
-
} from "../chunk-
|
|
162
|
+
} from "../chunk-226QDRO3.js";
|
|
163
163
|
import "../chunk-EHLOCVWB.js";
|
|
164
164
|
import {
|
|
165
165
|
CAMERA_MOVE_MAX_MS,
|
|
@@ -171,7 +171,7 @@ import {
|
|
|
171
171
|
pathControlsOf,
|
|
172
172
|
resolveCameraMoveSpec,
|
|
173
173
|
sampleEffectCameraMove
|
|
174
|
-
} from "../chunk-
|
|
174
|
+
} from "../chunk-JA57JIT5.js";
|
|
175
175
|
import "../chunk-V2ZCJRDM.js";
|
|
176
176
|
import {
|
|
177
177
|
defineEditorDocument
|
|
@@ -182,17 +182,16 @@ import {
|
|
|
182
182
|
} from "../chunk-NS62CQ2B.js";
|
|
183
183
|
import {
|
|
184
184
|
AnimationPlayer
|
|
185
|
-
} from "../chunk-
|
|
185
|
+
} from "../chunk-F6R67I3A.js";
|
|
186
186
|
import {
|
|
187
187
|
CUBIC_BEZIER_PRESETS,
|
|
188
188
|
evaluateEasing
|
|
189
189
|
} from "../chunk-5UJHB3BW.js";
|
|
190
|
-
import "../chunk-
|
|
190
|
+
import "../chunk-M2TPMYJE.js";
|
|
191
191
|
import "../chunk-2WPNAGHI.js";
|
|
192
|
-
import "../chunk-
|
|
193
|
-
import "../chunk-
|
|
194
|
-
import "../chunk-
|
|
195
|
-
import "../chunk-F67XMVDI.js";
|
|
192
|
+
import "../chunk-7272D3K2.js";
|
|
193
|
+
import "../chunk-YBAPT7NL.js";
|
|
194
|
+
import "../chunk-MHLU6GRJ.js";
|
|
196
195
|
import "../chunk-6ONMQ6WF.js";
|
|
197
196
|
|
|
198
197
|
// src/video-editor/parse.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.251.0",
|
|
4
4
|
"description": "UI-agnostic rich text and media editing core library",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -194,6 +194,16 @@
|
|
|
194
194
|
"default": "./dist/paint-editor/index.cjs"
|
|
195
195
|
}
|
|
196
196
|
},
|
|
197
|
+
"./brushes": {
|
|
198
|
+
"import": {
|
|
199
|
+
"types": "./dist/brushes/index.d.ts",
|
|
200
|
+
"default": "./dist/brushes/index.js"
|
|
201
|
+
},
|
|
202
|
+
"require": {
|
|
203
|
+
"types": "./dist/brushes/index.d.cts",
|
|
204
|
+
"default": "./dist/brushes/index.cjs"
|
|
205
|
+
}
|
|
206
|
+
},
|
|
197
207
|
"./commands": {
|
|
198
208
|
"import": {
|
|
199
209
|
"types": "./dist/commands/index.d.ts",
|
|
@@ -341,7 +341,7 @@ in the source frame at the document's bit depth, colour mode and profile. Read
|
|
|
341
341
|
| `mix_colors` | Read-only. Mix 1 to 16 `colors` (`{color: #rrggbb, weight, strength?}`) like paint (Kubelka-Munk over reflectance spectra). Returns `mixed` (#rrggbb), `rgbLerp` (the plain RGB average, for comparison) and the normalised `weights`. Call it before `paint_stroke` / `fill_pixels` to pick a paint colour. |
|
|
342
342
|
| `clear_pixels` | Remove the selected pixels (alpha to 0; a transparency-locked layer or a mask gets the background colour). Returns the changed bounds. |
|
|
343
343
|
| `import_psd` | Open a PSD / PSB (`data` base64, a `data:` URL is fine) as the document, replacing the layers, crop and rotation (one undo step). Returns the new `layers` tree with ids, `layerIds`, size and `warnings` naming the affected layers. Call `inspect_psd` first when losses matter. |
|
|
344
|
-
| `apply_effect` | Run a provider filter effect on a layer as a smart filter (`target`, `effect`, `values`, `index`, `enabled`, `opacity`, `blend`); a pixel, shape or type layer becomes a smart object in the same undo step (`converted`). It keeps the layer's transparency (`preserveTransparency`, default true: the result is drawn over the layer and takes its alpha); `false` lets a shader fill transparent pixels. With a selection the filter mask is set from it (`masked`): deselect first to filter the whole layer. Returns the filter id and `preserveTransparency`. |
|
|
344
|
+
| `apply_effect` | Run a provider filter effect, or any effect that takes a picture (the layer is its picture: a sticker from `insert_sticker` into a holo-foil treatment), on a layer as a smart filter (`target`, `effect`, `values`, `index`, `enabled`, `opacity`, `blend`); a pixel, shape or type layer becomes a smart object in the same undo step (`converted`). It keeps the layer's transparency (`preserveTransparency`, default true: the result is drawn over the layer and takes its alpha); `false` lets a shader fill transparent pixels. With a selection the filter mask is set from it (`masked`): deselect first to filter the whole layer. Returns the filter id and `preserveTransparency`. |
|
|
345
345
|
| `update_effect` | Change an effect smart filter (`values` merged, `null` resets; `enabled`, `opacity`, `blend`, `preserveTransparency`, `index`) or redraw an effect layer (`effect: "generator"`, values only). Returns the filter as it is now. |
|
|
346
346
|
| `remove_effect` | Remove an effect smart filter, or (`generator`) keep an effect layer's pixels as a plain layer. |
|
|
347
347
|
| `add_effect_layer` | Add a layer drawn by a generator, overlay or title effect at the document's size and bit depth (`values`, `time`, `animate`, `name`, `aboveId` / `belowId`, `opacity`, `blend`, `clipped`). `clipped: true` clips it to the layer directly below in the same undo step, so it shows only over that layer's pixels (refused when nothing is below it in its group). An effect with its own background (`backgroundOpacity` in `describe_effect`) starts with it transparent when there are layers below. Returns the layer id and `clipped`. |
|
|
@@ -20,9 +20,15 @@ none, it is the editor's own stamps (`editorStickers()`: `editor:dot`, `editor:s
|
|
|
20
20
|
it asks for), dominant colours, variants and outline.
|
|
21
21
|
3. **Use.** Pass refs to the editor that places them: in the paint editor, a sticker brush
|
|
22
22
|
(`set_brush` `sticker.stamps`, then `paint_stroke`) sprays them and `add_stickers` places
|
|
23
|
-
them exactly.
|
|
23
|
+
them exactly. In the vector, image and canvas editors, `insert_sticker` puts one in (`x`,
|
|
24
|
+
`y` centre, `width`): vector, a group of editable paths; image, a pixel layer; canvas, a
|
|
25
|
+
shape node from its outline in one colour. A provider's art loads before it is drawn.
|
|
24
26
|
4. **Colour.** Tintable stickers (flat, single-colour art) take the paint colour or a sticker's
|
|
25
27
|
`color`; the rest keep their own colours.
|
|
28
|
+
5. **Treat it with an effect.** In the image editor, `insert_sticker` returns the layer `id`;
|
|
29
|
+
`apply_effect` with that `target` and any effect whose `describe_effect` inputs take an
|
|
30
|
+
image (`appliesHere`) uses the sticker as its picture (holo foil, cut-out). For a whole set,
|
|
31
|
+
repeat the two calls per sticker.
|
|
26
32
|
|
|
27
33
|
## Best practices
|
|
28
34
|
|
|
@@ -30,16 +36,22 @@ none, it is the editor's own stamps (`editorStickers()`: `editor:dot`, `editor:s
|
|
|
30
36
|
and means `editor:star`.
|
|
31
37
|
- Credit stickers whose licence has an `attribution` wherever the work is published.
|
|
32
38
|
- Prefer tintable stickers when they must match a palette.
|
|
39
|
+
- Vector stickers need SVG art and canvas stickers an outline (`silhouette`); `find_stickers`
|
|
40
|
+
lists `formats`, and `describe_sticker` the outline. The image editor takes either.
|
|
33
41
|
|
|
34
42
|
## Pitfalls
|
|
35
43
|
|
|
36
44
|
- An unknown ref is refused with the closest refs: pick one of those or search again.
|
|
37
45
|
- A category that the library doesn't have is refused with the list of its categories.
|
|
38
46
|
- `limit` is 1..100; results beyond a page need `after`, not a larger limit.
|
|
47
|
+
- `color` on a sticker that is not tintable is refused; leave it out.
|
|
48
|
+
- On the canvas, multi-colour art becomes its outline in its dominant colour; for the art itself,
|
|
49
|
+
use the image editor (the vector and canvas editors take effects on stickers in a later change).
|
|
39
50
|
|
|
40
51
|
## Tool reference
|
|
41
52
|
|
|
42
53
|
| Tool | Use |
|
|
43
54
|
| --- | --- |
|
|
44
55
|
| `find_stickers` | Search or list the library: `query`, `category`, `tags`, `commercial`, `limit`, `after`. Returns `items` (each `ref`, name, category, tags, width, height, formats, tintable, licence), `total`, `next`, `categories`. Changes nothing. |
|
|
56
|
+
| `insert_sticker` | Put one sticker (`ref`) into the vector, image or canvas editor, centred at `x`, `y` (default the middle), `width` wide (default natural), tinted with `color` when tintable. One undo step. Returns the new group, layer or node `id`, the size and the licence. |
|
|
45
57
|
| `describe_sticker` | One sticker by `ref`: everything `find_stickers` returns plus `silhouette` (SVG path data), `colours` and `variants`. Unknown refs are refused with the closest ones. Changes nothing. |
|
package/dist/chunk-7AHBW2CQ.cjs
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkIPJ3TEYRcjs = require('./chunk-IPJ3TEYR.cjs');
|
|
9
|
-
|
|
10
|
-
// src/color/convert.ts
|
|
11
|
-
function srgbToLinear(v) {
|
|
12
|
-
const sign = Math.sign(v);
|
|
13
|
-
const abs = Math.abs(v);
|
|
14
|
-
return sign * (abs <= 0.04045 ? abs / 12.92 : ((abs + 0.055) / 1.055) ** 2.4);
|
|
15
|
-
}
|
|
16
|
-
function linearToSrgb(v) {
|
|
17
|
-
const sign = Math.sign(v);
|
|
18
|
-
const abs = Math.abs(v);
|
|
19
|
-
return sign * (abs <= 31308e-7 ? 12.92 * abs : 1.055 * abs ** (1 / 2.4) - 0.055);
|
|
20
|
-
}
|
|
21
|
-
function rgbToHsl(rgba) {
|
|
22
|
-
const { r, g, b, a } = rgba;
|
|
23
|
-
const max = Math.max(r, g, b);
|
|
24
|
-
const min = Math.min(r, g, b);
|
|
25
|
-
const d = max - min;
|
|
26
|
-
const l = (max + min) / 2;
|
|
27
|
-
let h = 0;
|
|
28
|
-
if (d > 0) {
|
|
29
|
-
if (max === r) h = 60 * ((g - b) / d % 6);
|
|
30
|
-
else if (max === g) h = 60 * ((b - r) / d + 2);
|
|
31
|
-
else h = 60 * ((r - g) / d + 4);
|
|
32
|
-
}
|
|
33
|
-
if (h < 0) h += 360;
|
|
34
|
-
const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
|
|
35
|
-
return { h, s, l, alpha: a };
|
|
36
|
-
}
|
|
37
|
-
function hslToRgb(hsla) {
|
|
38
|
-
const { h, s, l, alpha } = hsla;
|
|
39
|
-
const hh = (h % 360 + 360) % 360 / 60;
|
|
40
|
-
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
41
|
-
const x = c * (1 - Math.abs(hh % 2 - 1));
|
|
42
|
-
const m = l - c / 2;
|
|
43
|
-
let r = 0;
|
|
44
|
-
let g = 0;
|
|
45
|
-
let b = 0;
|
|
46
|
-
if (hh < 1) {
|
|
47
|
-
r = c;
|
|
48
|
-
g = x;
|
|
49
|
-
b = 0;
|
|
50
|
-
} else if (hh < 2) {
|
|
51
|
-
r = x;
|
|
52
|
-
g = c;
|
|
53
|
-
b = 0;
|
|
54
|
-
} else if (hh < 3) {
|
|
55
|
-
r = 0;
|
|
56
|
-
g = c;
|
|
57
|
-
b = x;
|
|
58
|
-
} else if (hh < 4) {
|
|
59
|
-
r = 0;
|
|
60
|
-
g = x;
|
|
61
|
-
b = c;
|
|
62
|
-
} else if (hh < 5) {
|
|
63
|
-
r = x;
|
|
64
|
-
g = 0;
|
|
65
|
-
b = c;
|
|
66
|
-
} else {
|
|
67
|
-
r = c;
|
|
68
|
-
g = 0;
|
|
69
|
-
b = x;
|
|
70
|
-
}
|
|
71
|
-
return { r: r + m, g: g + m, b: b + m, a: alpha };
|
|
72
|
-
}
|
|
73
|
-
function rgbToHsv(rgba) {
|
|
74
|
-
const { r, g, b, a } = rgba;
|
|
75
|
-
const max = Math.max(r, g, b);
|
|
76
|
-
const min = Math.min(r, g, b);
|
|
77
|
-
const d = max - min;
|
|
78
|
-
let h = 0;
|
|
79
|
-
if (d > 0) {
|
|
80
|
-
if (max === r) h = 60 * ((g - b) / d % 6);
|
|
81
|
-
else if (max === g) h = 60 * ((b - r) / d + 2);
|
|
82
|
-
else h = 60 * ((r - g) / d + 4);
|
|
83
|
-
}
|
|
84
|
-
if (h < 0) h += 360;
|
|
85
|
-
const s = max === 0 ? 0 : d / max;
|
|
86
|
-
return { h, s, v: max, alpha: a };
|
|
87
|
-
}
|
|
88
|
-
function hsvToRgb(hsva) {
|
|
89
|
-
const { h, s, v, alpha } = hsva;
|
|
90
|
-
const hh = (h % 360 + 360) % 360 / 60;
|
|
91
|
-
const c = v * s;
|
|
92
|
-
const x = c * (1 - Math.abs(hh % 2 - 1));
|
|
93
|
-
const m = v - c;
|
|
94
|
-
let r = 0;
|
|
95
|
-
let g = 0;
|
|
96
|
-
let b = 0;
|
|
97
|
-
if (hh < 1) {
|
|
98
|
-
r = c;
|
|
99
|
-
g = x;
|
|
100
|
-
b = 0;
|
|
101
|
-
} else if (hh < 2) {
|
|
102
|
-
r = x;
|
|
103
|
-
g = c;
|
|
104
|
-
b = 0;
|
|
105
|
-
} else if (hh < 3) {
|
|
106
|
-
r = 0;
|
|
107
|
-
g = c;
|
|
108
|
-
b = x;
|
|
109
|
-
} else if (hh < 4) {
|
|
110
|
-
r = 0;
|
|
111
|
-
g = x;
|
|
112
|
-
b = c;
|
|
113
|
-
} else if (hh < 5) {
|
|
114
|
-
r = x;
|
|
115
|
-
g = 0;
|
|
116
|
-
b = c;
|
|
117
|
-
} else {
|
|
118
|
-
r = c;
|
|
119
|
-
g = 0;
|
|
120
|
-
b = x;
|
|
121
|
-
}
|
|
122
|
-
return { r: r + m, g: g + m, b: b + m, a: alpha };
|
|
123
|
-
}
|
|
124
|
-
function rgbToOklab(rgba) {
|
|
125
|
-
const lr = srgbToLinear(rgba.r);
|
|
126
|
-
const lg = srgbToLinear(rgba.g);
|
|
127
|
-
const lb = srgbToLinear(rgba.b);
|
|
128
|
-
const l = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
|
|
129
|
-
const m = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
|
|
130
|
-
const s = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
|
|
131
|
-
return {
|
|
132
|
-
l: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
|
133
|
-
a: 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
|
134
|
-
b: 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
|
|
135
|
-
alpha: rgba.a
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
function oklabToRgb(lab) {
|
|
139
|
-
const l_ = lab.l + 0.3963377774 * lab.a + 0.2158037573 * lab.b;
|
|
140
|
-
const m_ = lab.l - 0.1055613458 * lab.a - 0.0638541728 * lab.b;
|
|
141
|
-
const s_ = lab.l - 0.0894841775 * lab.a - 1.291485548 * lab.b;
|
|
142
|
-
const l = l_ ** 3;
|
|
143
|
-
const m = m_ ** 3;
|
|
144
|
-
const s = s_ ** 3;
|
|
145
|
-
return {
|
|
146
|
-
r: linearToSrgb(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
|
|
147
|
-
g: linearToSrgb(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
|
|
148
|
-
b: linearToSrgb(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s),
|
|
149
|
-
a: lab.alpha
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
function oklabToOklch(lab) {
|
|
153
|
-
const c = Math.hypot(lab.a, lab.b);
|
|
154
|
-
let h = 0;
|
|
155
|
-
if (c >= 1e-6) {
|
|
156
|
-
h = Math.atan2(lab.b, lab.a) * 180 / Math.PI;
|
|
157
|
-
if (h < 0) h += 360;
|
|
158
|
-
if (h >= 360) h -= 360;
|
|
159
|
-
}
|
|
160
|
-
return { l: lab.l, c, h, alpha: lab.alpha };
|
|
161
|
-
}
|
|
162
|
-
function oklchToOklab(lch) {
|
|
163
|
-
const rad = lch.h * Math.PI / 180;
|
|
164
|
-
return {
|
|
165
|
-
l: lch.l,
|
|
166
|
-
a: lch.c * Math.cos(rad),
|
|
167
|
-
b: lch.c * Math.sin(rad),
|
|
168
|
-
alpha: lch.alpha
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
var D65_XYZ = _chunkIPJ3TEYRcjs.xyToXyz.call(void 0, _chunkIPJ3TEYRcjs.D65_XY);
|
|
172
|
-
var SRGB_TO_XYZ = _chunkIPJ3TEYRcjs.rgbToXyzMatrix.call(void 0, [0.64, 0.33], [0.3, 0.6], [0.15, 0.06], D65_XYZ);
|
|
173
|
-
var P3_TO_XYZ = _chunkIPJ3TEYRcjs.rgbToXyzMatrix.call(void 0, [0.68, 0.32], [0.265, 0.69], [0.15, 0.06], D65_XYZ);
|
|
174
|
-
var XYZ_TO_SRGB = _chunkIPJ3TEYRcjs.invert.call(void 0, SRGB_TO_XYZ);
|
|
175
|
-
var XYZ_TO_P3 = _chunkIPJ3TEYRcjs.invert.call(void 0, P3_TO_XYZ);
|
|
176
|
-
var P3_TO_SRGB_MAT = _chunkIPJ3TEYRcjs.mul.call(void 0, XYZ_TO_SRGB, P3_TO_XYZ);
|
|
177
|
-
var SRGB_TO_P3_MAT = _chunkIPJ3TEYRcjs.mul.call(void 0, XYZ_TO_P3, SRGB_TO_XYZ);
|
|
178
|
-
function linearSrgbToDisplayP3(rgb) {
|
|
179
|
-
const out = _chunkIPJ3TEYRcjs.apply.call(void 0, SRGB_TO_P3_MAT, [rgb.r, rgb.g, rgb.b]);
|
|
180
|
-
return { r: out[0], g: out[1], b: out[2], a: rgb.a };
|
|
181
|
-
}
|
|
182
|
-
function displayP3ToLinearSrgb(rgb) {
|
|
183
|
-
const out = _chunkIPJ3TEYRcjs.apply.call(void 0, P3_TO_SRGB_MAT, [rgb.r, rgb.g, rgb.b]);
|
|
184
|
-
return { r: out[0], g: out[1], b: out[2], a: rgb.a };
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
exports.srgbToLinear = srgbToLinear; exports.linearToSrgb = linearToSrgb; exports.rgbToHsl = rgbToHsl; exports.hslToRgb = hslToRgb; exports.rgbToHsv = rgbToHsv; exports.hsvToRgb = hsvToRgb; exports.rgbToOklab = rgbToOklab; exports.oklabToRgb = oklabToRgb; exports.oklabToOklch = oklabToOklch; exports.oklchToOklab = oklchToOklab; exports.linearSrgbToDisplayP3 = linearSrgbToDisplayP3; exports.displayP3ToLinearSrgb = displayP3ToLinearSrgb;
|
package/dist/chunk-F67XMVDI.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
D65_XY,
|
|
3
|
-
apply,
|
|
4
|
-
invert,
|
|
5
|
-
mul,
|
|
6
|
-
rgbToXyzMatrix,
|
|
7
|
-
xyToXyz
|
|
8
|
-
} from "./chunk-6ONMQ6WF.js";
|
|
9
|
-
|
|
10
|
-
// src/color/convert.ts
|
|
11
|
-
function srgbToLinear(v) {
|
|
12
|
-
const sign = Math.sign(v);
|
|
13
|
-
const abs = Math.abs(v);
|
|
14
|
-
return sign * (abs <= 0.04045 ? abs / 12.92 : ((abs + 0.055) / 1.055) ** 2.4);
|
|
15
|
-
}
|
|
16
|
-
function linearToSrgb(v) {
|
|
17
|
-
const sign = Math.sign(v);
|
|
18
|
-
const abs = Math.abs(v);
|
|
19
|
-
return sign * (abs <= 31308e-7 ? 12.92 * abs : 1.055 * abs ** (1 / 2.4) - 0.055);
|
|
20
|
-
}
|
|
21
|
-
function rgbToHsl(rgba) {
|
|
22
|
-
const { r, g, b, a } = rgba;
|
|
23
|
-
const max = Math.max(r, g, b);
|
|
24
|
-
const min = Math.min(r, g, b);
|
|
25
|
-
const d = max - min;
|
|
26
|
-
const l = (max + min) / 2;
|
|
27
|
-
let h = 0;
|
|
28
|
-
if (d > 0) {
|
|
29
|
-
if (max === r) h = 60 * ((g - b) / d % 6);
|
|
30
|
-
else if (max === g) h = 60 * ((b - r) / d + 2);
|
|
31
|
-
else h = 60 * ((r - g) / d + 4);
|
|
32
|
-
}
|
|
33
|
-
if (h < 0) h += 360;
|
|
34
|
-
const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
|
|
35
|
-
return { h, s, l, alpha: a };
|
|
36
|
-
}
|
|
37
|
-
function hslToRgb(hsla) {
|
|
38
|
-
const { h, s, l, alpha } = hsla;
|
|
39
|
-
const hh = (h % 360 + 360) % 360 / 60;
|
|
40
|
-
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
41
|
-
const x = c * (1 - Math.abs(hh % 2 - 1));
|
|
42
|
-
const m = l - c / 2;
|
|
43
|
-
let r = 0;
|
|
44
|
-
let g = 0;
|
|
45
|
-
let b = 0;
|
|
46
|
-
if (hh < 1) {
|
|
47
|
-
r = c;
|
|
48
|
-
g = x;
|
|
49
|
-
b = 0;
|
|
50
|
-
} else if (hh < 2) {
|
|
51
|
-
r = x;
|
|
52
|
-
g = c;
|
|
53
|
-
b = 0;
|
|
54
|
-
} else if (hh < 3) {
|
|
55
|
-
r = 0;
|
|
56
|
-
g = c;
|
|
57
|
-
b = x;
|
|
58
|
-
} else if (hh < 4) {
|
|
59
|
-
r = 0;
|
|
60
|
-
g = x;
|
|
61
|
-
b = c;
|
|
62
|
-
} else if (hh < 5) {
|
|
63
|
-
r = x;
|
|
64
|
-
g = 0;
|
|
65
|
-
b = c;
|
|
66
|
-
} else {
|
|
67
|
-
r = c;
|
|
68
|
-
g = 0;
|
|
69
|
-
b = x;
|
|
70
|
-
}
|
|
71
|
-
return { r: r + m, g: g + m, b: b + m, a: alpha };
|
|
72
|
-
}
|
|
73
|
-
function rgbToHsv(rgba) {
|
|
74
|
-
const { r, g, b, a } = rgba;
|
|
75
|
-
const max = Math.max(r, g, b);
|
|
76
|
-
const min = Math.min(r, g, b);
|
|
77
|
-
const d = max - min;
|
|
78
|
-
let h = 0;
|
|
79
|
-
if (d > 0) {
|
|
80
|
-
if (max === r) h = 60 * ((g - b) / d % 6);
|
|
81
|
-
else if (max === g) h = 60 * ((b - r) / d + 2);
|
|
82
|
-
else h = 60 * ((r - g) / d + 4);
|
|
83
|
-
}
|
|
84
|
-
if (h < 0) h += 360;
|
|
85
|
-
const s = max === 0 ? 0 : d / max;
|
|
86
|
-
return { h, s, v: max, alpha: a };
|
|
87
|
-
}
|
|
88
|
-
function hsvToRgb(hsva) {
|
|
89
|
-
const { h, s, v, alpha } = hsva;
|
|
90
|
-
const hh = (h % 360 + 360) % 360 / 60;
|
|
91
|
-
const c = v * s;
|
|
92
|
-
const x = c * (1 - Math.abs(hh % 2 - 1));
|
|
93
|
-
const m = v - c;
|
|
94
|
-
let r = 0;
|
|
95
|
-
let g = 0;
|
|
96
|
-
let b = 0;
|
|
97
|
-
if (hh < 1) {
|
|
98
|
-
r = c;
|
|
99
|
-
g = x;
|
|
100
|
-
b = 0;
|
|
101
|
-
} else if (hh < 2) {
|
|
102
|
-
r = x;
|
|
103
|
-
g = c;
|
|
104
|
-
b = 0;
|
|
105
|
-
} else if (hh < 3) {
|
|
106
|
-
r = 0;
|
|
107
|
-
g = c;
|
|
108
|
-
b = x;
|
|
109
|
-
} else if (hh < 4) {
|
|
110
|
-
r = 0;
|
|
111
|
-
g = x;
|
|
112
|
-
b = c;
|
|
113
|
-
} else if (hh < 5) {
|
|
114
|
-
r = x;
|
|
115
|
-
g = 0;
|
|
116
|
-
b = c;
|
|
117
|
-
} else {
|
|
118
|
-
r = c;
|
|
119
|
-
g = 0;
|
|
120
|
-
b = x;
|
|
121
|
-
}
|
|
122
|
-
return { r: r + m, g: g + m, b: b + m, a: alpha };
|
|
123
|
-
}
|
|
124
|
-
function rgbToOklab(rgba) {
|
|
125
|
-
const lr = srgbToLinear(rgba.r);
|
|
126
|
-
const lg = srgbToLinear(rgba.g);
|
|
127
|
-
const lb = srgbToLinear(rgba.b);
|
|
128
|
-
const l = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
|
|
129
|
-
const m = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
|
|
130
|
-
const s = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
|
|
131
|
-
return {
|
|
132
|
-
l: 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
|
133
|
-
a: 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
|
134
|
-
b: 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
|
|
135
|
-
alpha: rgba.a
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
function oklabToRgb(lab) {
|
|
139
|
-
const l_ = lab.l + 0.3963377774 * lab.a + 0.2158037573 * lab.b;
|
|
140
|
-
const m_ = lab.l - 0.1055613458 * lab.a - 0.0638541728 * lab.b;
|
|
141
|
-
const s_ = lab.l - 0.0894841775 * lab.a - 1.291485548 * lab.b;
|
|
142
|
-
const l = l_ ** 3;
|
|
143
|
-
const m = m_ ** 3;
|
|
144
|
-
const s = s_ ** 3;
|
|
145
|
-
return {
|
|
146
|
-
r: linearToSrgb(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
|
|
147
|
-
g: linearToSrgb(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
|
|
148
|
-
b: linearToSrgb(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s),
|
|
149
|
-
a: lab.alpha
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
function oklabToOklch(lab) {
|
|
153
|
-
const c = Math.hypot(lab.a, lab.b);
|
|
154
|
-
let h = 0;
|
|
155
|
-
if (c >= 1e-6) {
|
|
156
|
-
h = Math.atan2(lab.b, lab.a) * 180 / Math.PI;
|
|
157
|
-
if (h < 0) h += 360;
|
|
158
|
-
if (h >= 360) h -= 360;
|
|
159
|
-
}
|
|
160
|
-
return { l: lab.l, c, h, alpha: lab.alpha };
|
|
161
|
-
}
|
|
162
|
-
function oklchToOklab(lch) {
|
|
163
|
-
const rad = lch.h * Math.PI / 180;
|
|
164
|
-
return {
|
|
165
|
-
l: lch.l,
|
|
166
|
-
a: lch.c * Math.cos(rad),
|
|
167
|
-
b: lch.c * Math.sin(rad),
|
|
168
|
-
alpha: lch.alpha
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
var D65_XYZ = xyToXyz(D65_XY);
|
|
172
|
-
var SRGB_TO_XYZ = rgbToXyzMatrix([0.64, 0.33], [0.3, 0.6], [0.15, 0.06], D65_XYZ);
|
|
173
|
-
var P3_TO_XYZ = rgbToXyzMatrix([0.68, 0.32], [0.265, 0.69], [0.15, 0.06], D65_XYZ);
|
|
174
|
-
var XYZ_TO_SRGB = invert(SRGB_TO_XYZ);
|
|
175
|
-
var XYZ_TO_P3 = invert(P3_TO_XYZ);
|
|
176
|
-
var P3_TO_SRGB_MAT = mul(XYZ_TO_SRGB, P3_TO_XYZ);
|
|
177
|
-
var SRGB_TO_P3_MAT = mul(XYZ_TO_P3, SRGB_TO_XYZ);
|
|
178
|
-
function linearSrgbToDisplayP3(rgb) {
|
|
179
|
-
const out = apply(SRGB_TO_P3_MAT, [rgb.r, rgb.g, rgb.b]);
|
|
180
|
-
return { r: out[0], g: out[1], b: out[2], a: rgb.a };
|
|
181
|
-
}
|
|
182
|
-
function displayP3ToLinearSrgb(rgb) {
|
|
183
|
-
const out = apply(P3_TO_SRGB_MAT, [rgb.r, rgb.g, rgb.b]);
|
|
184
|
-
return { r: out[0], g: out[1], b: out[2], a: rgb.a };
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export {
|
|
188
|
-
srgbToLinear,
|
|
189
|
-
linearToSrgb,
|
|
190
|
-
rgbToHsl,
|
|
191
|
-
hslToRgb,
|
|
192
|
-
rgbToHsv,
|
|
193
|
-
hsvToRgb,
|
|
194
|
-
rgbToOklab,
|
|
195
|
-
oklabToRgb,
|
|
196
|
-
oklabToOklch,
|
|
197
|
-
oklchToOklab,
|
|
198
|
-
linearSrgbToDisplayP3,
|
|
199
|
-
displayP3ToLinearSrgb
|
|
200
|
-
};
|