@pixerate/editor 0.266.1 → 0.267.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 +8 -4
- package/dist/agent/index.js +6 -2
- package/dist/animation-editor/controller.d.cts +8 -0
- package/dist/animation-editor/controller.d.ts +8 -0
- package/dist/animation-editor/effect-tools.d.cts +1 -1
- package/dist/animation-editor/effect-tools.d.ts +1 -1
- package/dist/animation-editor/index.cjs +172 -105
- package/dist/animation-editor/index.js +91 -24
- package/dist/brushes/index.cjs +59 -59
- package/dist/brushes/index.js +5 -5
- package/dist/brushes/profiles.d.cts +6 -1
- package/dist/brushes/profiles.d.ts +6 -1
- package/dist/{brushstrokeRender-FSUWXUZY.cjs → brushstrokeRender-L7JYRR2R.cjs} +16 -16
- package/dist/{brushstrokeRender-KD453OBX.js → brushstrokeRender-NLFPEBGI.js} +4 -4
- package/dist/canvas/brushTypes.d.cts +12 -0
- package/dist/canvas/brushTypes.d.ts +12 -0
- package/dist/canvas/brushstroke.d.cts +1 -1
- package/dist/canvas/brushstroke.d.ts +1 -1
- package/dist/canvas/drawController.d.cts +19 -4
- package/dist/canvas/drawController.d.ts +19 -4
- package/dist/canvas/index.cjs +144 -105
- package/dist/canvas/index.js +46 -7
- package/dist/{chunk-XORJ7UZO.cjs → chunk-3VHH6V67.cjs} +13 -12
- package/dist/{chunk-T2LDTEXK.js → chunk-4IDUYB45.js} +2217 -56
- package/dist/chunk-7UKFXXWL.js +802 -0
- package/dist/chunk-ADMRNWR7.js +340 -0
- package/dist/{chunk-CIJBSUM5.js → chunk-AGNUD5BI.js} +2 -2
- package/dist/{chunk-WLUVZKVD.cjs → chunk-DT4YQUGT.cjs} +32 -32
- package/dist/{chunk-DXYHQ2VN.js → chunk-EF7LZAXQ.js} +1 -1
- package/dist/chunk-EXB2EGBE.cjs +802 -0
- package/dist/{chunk-4ODRXQRW.js → chunk-EYSHTYLG.js} +1 -1
- package/dist/{chunk-R44Y3EFS.js → chunk-FGJHJIMN.js} +8 -336
- package/dist/{chunk-AQZQWXEU.cjs → chunk-G7NHE2VD.cjs} +35 -35
- package/dist/{chunk-XC6DPRYI.js → chunk-GSTSZPSR.js} +154 -949
- package/dist/{chunk-VRK322ZC.cjs → chunk-HIO6E7LC.cjs} +2 -2
- package/dist/{chunk-TOID45I2.cjs → chunk-J2TNIZ55.cjs} +1 -1
- package/dist/{chunk-YHDHFJUC.cjs → chunk-J5VQYK7T.cjs} +217 -1012
- package/dist/{chunk-3C33YTNN.js → chunk-JGWVZPT6.js} +2 -2
- package/dist/{chunk-ACFSFUQH.js → chunk-JL6YH5WD.js} +4 -0
- package/dist/{chunk-3SBLVGOM.cjs → chunk-LA5Y4ETA.cjs} +23 -23
- package/dist/{chunk-MVUQSK5J.cjs → chunk-LHPEG5AU.cjs} +107 -435
- package/dist/{chunk-DOZ6F2K2.js → chunk-NSETJI74.js} +3 -2
- package/dist/{chunk-XRXFVRGY.cjs → chunk-OKHKA43L.cjs} +2364 -203
- package/dist/{chunk-LK4SXL3V.js → chunk-OSEXT7JL.js} +1 -1
- package/dist/{chunk-PE6YJMQT.cjs → chunk-PFHJS4HE.cjs} +20 -19
- package/dist/{chunk-ZQI3WUPP.js → chunk-QCLY5SFS.js} +12 -0
- package/dist/{chunk-7KNW3WXZ.cjs → chunk-QEVLRLUN.cjs} +63 -0
- package/dist/{chunk-OTN6VB5S.cjs → chunk-RDFHWAHL.cjs} +5 -1
- package/dist/{chunk-6JL2D5SG.js → chunk-VE6UKYQ2.js} +3 -2
- package/dist/{chunk-RFJZGTHA.cjs → chunk-XVOP3CGQ.cjs} +9 -9
- package/dist/{chunk-EZOJBP4D.js → chunk-YIC6MAJ2.js} +1 -1
- package/dist/chunk-YZWM6ZIP.cjs +340 -0
- package/dist/{chunk-472INMWH.js → chunk-ZA7L5YJB.js} +63 -0
- package/dist/{chunk-YBC3RKT2.cjs → chunk-ZGXJ7BTR.cjs} +13 -1
- package/dist/commands/builtins.d.cts +12 -1
- package/dist/commands/builtins.d.ts +12 -1
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.js +1 -1
- package/dist/image-editor/controller.d.cts +1 -1
- package/dist/image-editor/controller.d.ts +1 -1
- package/dist/image-editor/index.cjs +837 -833
- package/dist/image-editor/index.js +105 -101
- package/dist/paint/index.cjs +5 -3
- package/dist/paint/index.js +46 -44
- package/dist/paint-editor/controller.d.cts +5 -3
- package/dist/paint-editor/controller.d.ts +5 -3
- package/dist/paint-editor/index.cjs +832 -2295
- package/dist/paint-editor/index.js +285 -1748
- package/dist/paint-editor/path-samples.d.cts +2 -0
- package/dist/paint-editor/path-samples.d.ts +2 -0
- package/dist/paint-editor/presence.d.cts +20 -1
- package/dist/paint-editor/presence.d.ts +20 -1
- package/dist/stickers/helpers.d.cts +2 -0
- package/dist/stickers/helpers.d.ts +2 -0
- package/dist/stickers/index.cjs +41 -35
- package/dist/stickers/index.js +22 -16
- package/dist/stickers/types.d.cts +4 -2
- package/dist/stickers/types.d.ts +4 -2
- package/dist/tools/conformance.d.cts +8 -0
- package/dist/tools/conformance.d.ts +8 -0
- package/dist/tools/index.cjs +6 -2
- package/dist/tools/index.js +5 -1
- package/dist/vector/backdrop.d.cts +13 -0
- package/dist/vector/backdrop.d.ts +13 -0
- package/dist/vector/brushstroke.d.cts +54 -7
- package/dist/vector/brushstroke.d.ts +54 -7
- package/dist/vector/brushstrokeMedia.d.cts +96 -0
- package/dist/vector/brushstrokeMedia.d.ts +96 -0
- package/dist/vector/controller.d.cts +17 -3
- package/dist/vector/controller.d.ts +17 -3
- package/dist/vector/index.cjs +1846 -1386
- package/dist/vector/index.d.cts +2 -0
- package/dist/vector/index.d.ts +2 -0
- package/dist/vector/index.js +517 -57
- package/dist/vector/render.d.cts +6 -0
- package/dist/vector/render.d.ts +6 -0
- package/dist/vector/types.d.cts +14 -0
- package/dist/vector/types.d.ts +14 -0
- package/package.json +1 -1
- package/skills/pixerate-animation-editor/SKILL.md +1 -0
- package/skills/pixerate-brushes/SKILL.md +2 -2
- package/skills/pixerate-brushes-design/SKILL.md +7 -4
- package/skills/pixerate-brushes-design/evals/port-to-vector.json +8 -8
- package/skills/pixerate-canvas/SKILL.md +11 -1
- package/skills/pixerate-image-editor/SKILL.md +19 -64
- package/skills/pixerate-image-editor/references/color-management.md +2 -1
- package/skills/pixerate-image-editor/references/free-transform.md +12 -0
- package/skills/pixerate-image-editor/references/layer-effects.md +10 -0
- package/skills/pixerate-image-editor/references/painting.md +17 -0
- package/skills/pixerate-image-editor/references/photoshop-files.md +1 -1
- package/skills/pixerate-image-editor/references/shapes-and-type.md +14 -0
- package/skills/pixerate-image-editor/references/smart-objects.md +10 -0
- package/skills/pixerate-paint-editor/SKILL.md +8 -4
- package/skills/pixerate-paint-editor/references/wet-media.md +9 -0
- package/skills/pixerate-vector/SKILL.md +16 -6
- package/skills/pixerate-vector/references/best-practices.md +1 -0
- package/skills/pixerate-vector/references/commands.md +19 -0
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
combineCoverage,
|
|
3
|
+
flatBounds,
|
|
4
|
+
flattenPath,
|
|
5
|
+
rasterizeCoverage,
|
|
6
|
+
rasterizeCoverageSampled
|
|
7
|
+
} from "./chunk-ADMRNWR7.js";
|
|
1
8
|
import {
|
|
2
9
|
boxMean,
|
|
3
10
|
combineSelections,
|
|
@@ -108,7 +115,7 @@ import {
|
|
|
108
115
|
transformTextRect,
|
|
109
116
|
translateMatrix,
|
|
110
117
|
warpPresetMesh
|
|
111
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-4IDUYB45.js";
|
|
112
119
|
import {
|
|
113
120
|
bezierPathBounds,
|
|
114
121
|
outlineStroke,
|
|
@@ -1912,339 +1919,6 @@ function removeAlpha(imageData) {
|
|
|
1912
1919
|
}
|
|
1913
1920
|
}
|
|
1914
1921
|
|
|
1915
|
-
// src/image-editor/layers/vector-raster.ts
|
|
1916
|
-
var FLATNESS = 0.01;
|
|
1917
|
-
function flattenPath(path, tolerance = FLATNESS) {
|
|
1918
|
-
const out = [];
|
|
1919
|
-
let pts = [];
|
|
1920
|
-
let cx = 0;
|
|
1921
|
-
let cy = 0;
|
|
1922
|
-
let sx = 0;
|
|
1923
|
-
let sy = 0;
|
|
1924
|
-
const flush = () => {
|
|
1925
|
-
if (pts.length >= 6) out.push(Float64Array.from(pts));
|
|
1926
|
-
pts = [];
|
|
1927
|
-
};
|
|
1928
|
-
const steps = (dd, degree) => Math.max(1, Math.min(1024, Math.ceil(Math.sqrt(degree * (degree - 1) * dd / (8 * tolerance)))));
|
|
1929
|
-
for (const c of path) {
|
|
1930
|
-
switch (c.type) {
|
|
1931
|
-
case "M":
|
|
1932
|
-
flush();
|
|
1933
|
-
cx = sx = c.x;
|
|
1934
|
-
cy = sy = c.y;
|
|
1935
|
-
pts.push(cx, cy);
|
|
1936
|
-
break;
|
|
1937
|
-
case "L":
|
|
1938
|
-
if (!pts.length) pts.push(cx, cy);
|
|
1939
|
-
cx = c.x;
|
|
1940
|
-
cy = c.y;
|
|
1941
|
-
pts.push(cx, cy);
|
|
1942
|
-
break;
|
|
1943
|
-
case "Q": {
|
|
1944
|
-
if (!pts.length) pts.push(cx, cy);
|
|
1945
|
-
const n = steps(Math.hypot(cx - 2 * c.x1 + c.x, cy - 2 * c.y1 + c.y), 2);
|
|
1946
|
-
for (let k = 1; k <= n; k++) {
|
|
1947
|
-
const t = k / n;
|
|
1948
|
-
const u = 1 - t;
|
|
1949
|
-
pts.push(u * u * cx + 2 * u * t * c.x1 + t * t * c.x, u * u * cy + 2 * u * t * c.y1 + t * t * c.y);
|
|
1950
|
-
}
|
|
1951
|
-
cx = c.x;
|
|
1952
|
-
cy = c.y;
|
|
1953
|
-
break;
|
|
1954
|
-
}
|
|
1955
|
-
case "C": {
|
|
1956
|
-
if (!pts.length) pts.push(cx, cy);
|
|
1957
|
-
const dd = Math.max(Math.hypot(cx - 2 * c.x1 + c.x2, cy - 2 * c.y1 + c.y2), Math.hypot(c.x1 - 2 * c.x2 + c.x, c.y1 - 2 * c.y2 + c.y));
|
|
1958
|
-
const n = steps(dd, 3);
|
|
1959
|
-
for (let k = 1; k <= n; k++) {
|
|
1960
|
-
const t = k / n;
|
|
1961
|
-
const u = 1 - t;
|
|
1962
|
-
const a = u * u * u;
|
|
1963
|
-
const b = 3 * u * u * t;
|
|
1964
|
-
const d = 3 * u * t * t;
|
|
1965
|
-
const e = t * t * t;
|
|
1966
|
-
pts.push(a * cx + b * c.x1 + d * c.x2 + e * c.x, a * cy + b * c.y1 + d * c.y2 + e * c.y);
|
|
1967
|
-
}
|
|
1968
|
-
cx = c.x;
|
|
1969
|
-
cy = c.y;
|
|
1970
|
-
break;
|
|
1971
|
-
}
|
|
1972
|
-
case "Z":
|
|
1973
|
-
flush();
|
|
1974
|
-
cx = sx;
|
|
1975
|
-
cy = sy;
|
|
1976
|
-
break;
|
|
1977
|
-
}
|
|
1978
|
-
}
|
|
1979
|
-
flush();
|
|
1980
|
-
return out.filter((p) => p.every(Number.isFinite));
|
|
1981
|
-
}
|
|
1982
|
-
function flatBounds(flat) {
|
|
1983
|
-
let x0 = Infinity;
|
|
1984
|
-
let y0 = Infinity;
|
|
1985
|
-
let x1 = -Infinity;
|
|
1986
|
-
let y1 = -Infinity;
|
|
1987
|
-
for (const p of flat) {
|
|
1988
|
-
for (let i = 0; i < p.length; i += 2) {
|
|
1989
|
-
if (p[i] < x0) x0 = p[i];
|
|
1990
|
-
if (p[i] > x1) x1 = p[i];
|
|
1991
|
-
if (p[i + 1] < y0) y0 = p[i + 1];
|
|
1992
|
-
if (p[i + 1] > y1) y1 = p[i + 1];
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
if (x0 === Infinity) return null;
|
|
1996
|
-
const x = Math.floor(x0);
|
|
1997
|
-
const y = Math.floor(y0);
|
|
1998
|
-
return { x, y, width: Math.ceil(x1) - x, height: Math.ceil(y1) - y };
|
|
1999
|
-
}
|
|
2000
|
-
function drawLine(a, w, h, x0, y0, x1, y1) {
|
|
2001
|
-
if (y0 === y1) return;
|
|
2002
|
-
let dir = 1;
|
|
2003
|
-
if (y0 > y1) {
|
|
2004
|
-
dir = -1;
|
|
2005
|
-
let t = x0;
|
|
2006
|
-
x0 = x1;
|
|
2007
|
-
x1 = t;
|
|
2008
|
-
t = y0;
|
|
2009
|
-
y0 = y1;
|
|
2010
|
-
y1 = t;
|
|
2011
|
-
}
|
|
2012
|
-
if (y1 <= 0 || y0 >= h) return;
|
|
2013
|
-
const dxdy = (x1 - x0) / (y1 - y0);
|
|
2014
|
-
let x = x0;
|
|
2015
|
-
if (y0 < 0) x -= y0 * dxdy;
|
|
2016
|
-
const rowStart = Math.max(0, Math.floor(y0));
|
|
2017
|
-
const rowEnd = Math.min(h, Math.ceil(y1));
|
|
2018
|
-
for (let y = rowStart; y < rowEnd; y++) {
|
|
2019
|
-
const line = y * w;
|
|
2020
|
-
const dy = Math.min(y + 1, y1) - Math.max(y, y0);
|
|
2021
|
-
const xnext = x + dxdy * dy;
|
|
2022
|
-
const d = dy * dir;
|
|
2023
|
-
const xa = x < xnext ? x : xnext;
|
|
2024
|
-
const xb = x < xnext ? xnext : x;
|
|
2025
|
-
const xaFloor = Math.floor(xa);
|
|
2026
|
-
const xai = xaFloor;
|
|
2027
|
-
const xbCeil = Math.ceil(xb);
|
|
2028
|
-
const xbi = xbCeil;
|
|
2029
|
-
if (xbi <= xai + 1) {
|
|
2030
|
-
const xmf = 0.5 * (x + xnext) - xaFloor;
|
|
2031
|
-
a[line + xai] += d - d * xmf;
|
|
2032
|
-
a[line + xai + 1] += d * xmf;
|
|
2033
|
-
} else {
|
|
2034
|
-
const s = 1 / (xb - xa);
|
|
2035
|
-
const xaf = xa - xaFloor;
|
|
2036
|
-
const a0 = 0.5 * s * (1 - xaf) * (1 - xaf);
|
|
2037
|
-
const xbf = xb - xbCeil + 1;
|
|
2038
|
-
const am = 0.5 * s * xbf * xbf;
|
|
2039
|
-
a[line + xai] += d * a0;
|
|
2040
|
-
if (xbi === xai + 2) a[line + xai + 1] += d * (1 - a0 - am);
|
|
2041
|
-
else {
|
|
2042
|
-
const a1 = s * (1.5 - xaf);
|
|
2043
|
-
a[line + xai + 1] += d * (a1 - a0);
|
|
2044
|
-
for (let xi = xai + 2; xi < xbi - 1; xi++) a[line + xi] += d * s;
|
|
2045
|
-
const a2 = a1 + (xbi - xai - 3) * s;
|
|
2046
|
-
a[line + xbi - 1] += d * (1 - a2 - am);
|
|
2047
|
-
}
|
|
2048
|
-
a[line + xbi] += d * am;
|
|
2049
|
-
}
|
|
2050
|
-
x = xnext;
|
|
2051
|
-
}
|
|
2052
|
-
}
|
|
2053
|
-
function drawClippedLine(a, w, h, x0, y0, x1, y1) {
|
|
2054
|
-
if (y0 === y1) return;
|
|
2055
|
-
if (y0 <= 0 && y1 <= 0 || y0 >= h && y1 >= h) return;
|
|
2056
|
-
if (x0 >= 0 && x0 <= w && x1 >= 0 && x1 <= w) return drawLine(a, w, h, x0, y0, x1, y1);
|
|
2057
|
-
const ts = [0, 1];
|
|
2058
|
-
const dx = x1 - x0;
|
|
2059
|
-
if (dx !== 0) {
|
|
2060
|
-
for (const edge of [0, w]) {
|
|
2061
|
-
const t = (edge - x0) / dx;
|
|
2062
|
-
if (t > 0 && t < 1) ts.push(t);
|
|
2063
|
-
}
|
|
2064
|
-
}
|
|
2065
|
-
ts.sort((p, q2) => p - q2);
|
|
2066
|
-
const clamp4 = (v) => v < 0 ? 0 : v > w ? w : v;
|
|
2067
|
-
for (let i = 0; i + 1 < ts.length; i++) {
|
|
2068
|
-
const ta = ts[i];
|
|
2069
|
-
const tb = ts[i + 1];
|
|
2070
|
-
drawLine(a, w, h, clamp4(x0 + dx * ta), y0 + (y1 - y0) * ta, clamp4(x0 + dx * tb), y0 + (y1 - y0) * tb);
|
|
2071
|
-
}
|
|
2072
|
-
}
|
|
2073
|
-
function ruleCoverage(v, rule) {
|
|
2074
|
-
const m = v < 0 ? -v : v;
|
|
2075
|
-
if (rule === "nonzero") return m >= 1 ? 1 : m;
|
|
2076
|
-
const f = m % 2;
|
|
2077
|
-
return f > 1 ? 2 - f : f;
|
|
2078
|
-
}
|
|
2079
|
-
function rasterizeCoverage(flat, rect, rule = "nonzero") {
|
|
2080
|
-
const w = rect.width;
|
|
2081
|
-
const h = rect.height;
|
|
2082
|
-
if (w <= 0 || h <= 0 || !flat.length) return null;
|
|
2083
|
-
const a = new Float64Array(w * h + w + 4);
|
|
2084
|
-
const ox = rect.x;
|
|
2085
|
-
const oy = rect.y;
|
|
2086
|
-
let touched = false;
|
|
2087
|
-
for (const p of flat) {
|
|
2088
|
-
const n = p.length;
|
|
2089
|
-
for (let i = 0; i < n; i += 2) {
|
|
2090
|
-
const j = i + 2 < n ? i + 2 : 0;
|
|
2091
|
-
const ya = p[i + 1] - oy;
|
|
2092
|
-
const yb = p[j + 1] - oy;
|
|
2093
|
-
if (ya <= 0 && yb <= 0 || ya >= h && yb >= h || ya === yb) continue;
|
|
2094
|
-
drawClippedLine(a, w, h, p[i] - ox, ya, p[j] - ox, yb);
|
|
2095
|
-
touched = true;
|
|
2096
|
-
}
|
|
2097
|
-
}
|
|
2098
|
-
if (!touched) return null;
|
|
2099
|
-
const out = new Float32Array(w * h);
|
|
2100
|
-
let acc = 0;
|
|
2101
|
-
let any = false;
|
|
2102
|
-
for (let i = 0; i < out.length; i++) {
|
|
2103
|
-
acc += a[i];
|
|
2104
|
-
const c = ruleCoverage(acc, rule);
|
|
2105
|
-
if (c > 1e-6) {
|
|
2106
|
-
out[i] = c;
|
|
2107
|
-
any = true;
|
|
2108
|
-
}
|
|
2109
|
-
}
|
|
2110
|
-
return any ? out : null;
|
|
2111
|
-
}
|
|
2112
|
-
var SUB_ROWS = 16;
|
|
2113
|
-
function rasterizeCoverageSampled(flat, rect, rule = "nonzero") {
|
|
2114
|
-
const w = rect.width;
|
|
2115
|
-
const h = rect.height;
|
|
2116
|
-
if (w <= 0 || h <= 0 || !flat.length) return null;
|
|
2117
|
-
let n = 0;
|
|
2118
|
-
for (const p of flat) n += p.length >> 1;
|
|
2119
|
-
const ey0 = new Float64Array(n);
|
|
2120
|
-
const ey1 = new Float64Array(n);
|
|
2121
|
-
const ex0 = new Float64Array(n);
|
|
2122
|
-
const eslope = new Float64Array(n);
|
|
2123
|
-
const edir = new Int8Array(n);
|
|
2124
|
-
let count = 0;
|
|
2125
|
-
for (const p of flat) {
|
|
2126
|
-
const len = p.length;
|
|
2127
|
-
for (let i = 0; i < len; i += 2) {
|
|
2128
|
-
const j = i + 2 < len ? i + 2 : 0;
|
|
2129
|
-
let xa = p[i] - rect.x;
|
|
2130
|
-
let ya = p[i + 1] - rect.y;
|
|
2131
|
-
let xb = p[j] - rect.x;
|
|
2132
|
-
let yb = p[j + 1] - rect.y;
|
|
2133
|
-
if (ya === yb) continue;
|
|
2134
|
-
let dir = 1;
|
|
2135
|
-
if (ya > yb) {
|
|
2136
|
-
dir = -1;
|
|
2137
|
-
let t = xa;
|
|
2138
|
-
xa = xb;
|
|
2139
|
-
xb = t;
|
|
2140
|
-
t = ya;
|
|
2141
|
-
ya = yb;
|
|
2142
|
-
yb = t;
|
|
2143
|
-
}
|
|
2144
|
-
if (yb <= 0 || ya >= h) continue;
|
|
2145
|
-
ey0[count] = ya;
|
|
2146
|
-
ey1[count] = yb;
|
|
2147
|
-
ex0[count] = xa;
|
|
2148
|
-
eslope[count] = (xb - xa) / (yb - ya);
|
|
2149
|
-
edir[count] = dir;
|
|
2150
|
-
count++;
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
if (!count) return null;
|
|
2154
|
-
const order = Array.from({ length: count }, (_, i) => i).sort((a, b) => ey0[a] - ey0[b]);
|
|
2155
|
-
const out = new Float32Array(w * h);
|
|
2156
|
-
const diff = new Float32Array(w + 1);
|
|
2157
|
-
let active = [];
|
|
2158
|
-
let next = 0;
|
|
2159
|
-
const xs = [];
|
|
2160
|
-
const ds = [];
|
|
2161
|
-
const idx = [];
|
|
2162
|
-
const f = 1 / SUB_ROWS;
|
|
2163
|
-
let any = false;
|
|
2164
|
-
const firstRow = Math.max(0, Math.floor(ey0[order[0]]));
|
|
2165
|
-
for (let y = firstRow; y < h; y++) {
|
|
2166
|
-
if (next >= count && !active.length) break;
|
|
2167
|
-
const row = y * w;
|
|
2168
|
-
let rowTouched = false;
|
|
2169
|
-
for (let s = 0; s < SUB_ROWS; s++) {
|
|
2170
|
-
const sy = y + (s + 0.5) * f;
|
|
2171
|
-
while (next < count && ey0[order[next]] <= sy) active.push(order[next++]);
|
|
2172
|
-
if (!active.length) continue;
|
|
2173
|
-
active = active.filter((e) => ey1[e] > sy);
|
|
2174
|
-
xs.length = 0;
|
|
2175
|
-
ds.length = 0;
|
|
2176
|
-
idx.length = 0;
|
|
2177
|
-
for (const e of active) {
|
|
2178
|
-
if (ey0[e] > sy) continue;
|
|
2179
|
-
idx.push(xs.length);
|
|
2180
|
-
xs.push(ex0[e] + (sy - ey0[e]) * eslope[e]);
|
|
2181
|
-
ds.push(edir[e]);
|
|
2182
|
-
}
|
|
2183
|
-
if (xs.length < 2) continue;
|
|
2184
|
-
idx.sort((a, b) => xs[a] - xs[b]);
|
|
2185
|
-
let wind = 0;
|
|
2186
|
-
for (let k = 0; k + 1 < idx.length; k++) {
|
|
2187
|
-
wind += ds[idx[k]];
|
|
2188
|
-
const inside = rule === "nonzero" ? wind !== 0 : (wind & 1) !== 0;
|
|
2189
|
-
if (!inside) continue;
|
|
2190
|
-
let xa = xs[idx[k]];
|
|
2191
|
-
let xb = xs[idx[k + 1]];
|
|
2192
|
-
if (xb <= 0 || xa >= w || xb <= xa) continue;
|
|
2193
|
-
if (xa < 0) xa = 0;
|
|
2194
|
-
if (xb > w) xb = w;
|
|
2195
|
-
const ia = Math.floor(xa);
|
|
2196
|
-
const ib = Math.floor(xb);
|
|
2197
|
-
rowTouched = true;
|
|
2198
|
-
if (ia === ib) {
|
|
2199
|
-
out[row + ia] += (xb - xa) * f;
|
|
2200
|
-
continue;
|
|
2201
|
-
}
|
|
2202
|
-
out[row + ia] += (ia + 1 - xa) * f;
|
|
2203
|
-
diff[ia + 1] += f;
|
|
2204
|
-
diff[ib] -= f;
|
|
2205
|
-
if (ib < w) out[row + ib] += (xb - ib) * f;
|
|
2206
|
-
}
|
|
2207
|
-
}
|
|
2208
|
-
if (!rowTouched) continue;
|
|
2209
|
-
let run = 0;
|
|
2210
|
-
for (let x = 0; x < w; x++) {
|
|
2211
|
-
run += diff[x];
|
|
2212
|
-
diff[x] = 0;
|
|
2213
|
-
const v = out[row + x] + run;
|
|
2214
|
-
out[row + x] = v > 1 ? 1 : v < 1e-6 ? 0 : v;
|
|
2215
|
-
if (out[row + x] > 0) any = true;
|
|
2216
|
-
}
|
|
2217
|
-
diff[w] = 0;
|
|
2218
|
-
}
|
|
2219
|
-
return any ? out : null;
|
|
2220
|
-
}
|
|
2221
|
-
function combineCoverage(a, b, op, n) {
|
|
2222
|
-
if (op === "combine") {
|
|
2223
|
-
if (!a) return b;
|
|
2224
|
-
if (!b) return a;
|
|
2225
|
-
const out2 = new Float32Array(n);
|
|
2226
|
-
for (let i = 0; i < n; i++) out2[i] = a[i] + b[i] - a[i] * b[i];
|
|
2227
|
-
return out2;
|
|
2228
|
-
}
|
|
2229
|
-
if (op === "subtract") {
|
|
2230
|
-
if (!a || !b) return a;
|
|
2231
|
-
const out2 = new Float32Array(n);
|
|
2232
|
-
for (let i = 0; i < n; i++) out2[i] = a[i] * (1 - b[i]);
|
|
2233
|
-
return out2;
|
|
2234
|
-
}
|
|
2235
|
-
if (op === "intersect") {
|
|
2236
|
-
if (!a || !b) return null;
|
|
2237
|
-
const out2 = new Float32Array(n);
|
|
2238
|
-
for (let i = 0; i < n; i++) out2[i] = a[i] * b[i];
|
|
2239
|
-
return out2;
|
|
2240
|
-
}
|
|
2241
|
-
if (!a) return b;
|
|
2242
|
-
if (!b) return a;
|
|
2243
|
-
const out = new Float32Array(n);
|
|
2244
|
-
for (let i = 0; i < n; i++) out[i] = a[i] + b[i] - 2 * a[i] * b[i];
|
|
2245
|
-
return out;
|
|
2246
|
-
}
|
|
2247
|
-
|
|
2248
1922
|
// src/text/types.ts
|
|
2249
1923
|
var TEXT_ORIENTATIONS = ["horizontal", "vertical"];
|
|
2250
1924
|
var TEXT_ALIGNS = ["left", "center", "right", "justify"];
|
|
@@ -13322,8 +12996,6 @@ export {
|
|
|
13322
12996
|
applyBoxBlur,
|
|
13323
12997
|
applyDepthMask,
|
|
13324
12998
|
removeAlpha,
|
|
13325
|
-
flattenPath,
|
|
13326
|
-
rasterizeCoverage,
|
|
13327
12999
|
TEXT_ORIENTATIONS,
|
|
13328
13000
|
TEXT_ALIGNS,
|
|
13329
13001
|
MAX_EFFECT_ANIMATION_MS,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunkOKHKA43Lcjs = require('./chunk-OKHKA43L.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -37,7 +37,7 @@ var lerpP = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
|
37
37
|
var toP = (v) => [v.x, v.y];
|
|
38
38
|
var mapP = (m, p) => [m[0] * p[0] + m[2] * p[1] + m[4], m[1] * p[0] + m[3] * p[1] + m[5]];
|
|
39
39
|
var curvesOf = (c) => Math.max(0, (c.pts.length - 1) / 3) | 0;
|
|
40
|
-
function subpathToMorphContour(sp, m =
|
|
40
|
+
function subpathToMorphContour(sp, m = _chunkOKHKA43Lcjs.IDENTITY_MATRIX) {
|
|
41
41
|
const n = sp.anchors.length;
|
|
42
42
|
if (!n) return null;
|
|
43
43
|
const first = mapP(m, toP(sp.anchors[0]));
|
|
@@ -67,8 +67,8 @@ function isStraight(p0, p1, p2, p3) {
|
|
|
67
67
|
const u2 = along(p2);
|
|
68
68
|
return off(p1) < tol && off(p2) < tol && u1 >= -1e-9 && u1 <= 1 + 1e-9 && u2 >= -1e-9 && u2 <= 1 + 1e-9;
|
|
69
69
|
}
|
|
70
|
-
function morphContourToSubpath(c, m =
|
|
71
|
-
const pts =
|
|
70
|
+
function morphContourToSubpath(c, m = _chunkOKHKA43Lcjs.IDENTITY_MATRIX, closed = c.closed) {
|
|
71
|
+
const pts = _chunkOKHKA43Lcjs.isIdentityMatrix.call(void 0, m) ? c.pts : c.pts.map((p) => mapP(m, p));
|
|
72
72
|
const curves = curvesOf(c);
|
|
73
73
|
const dropLast = closed && c.closed && curves > 0;
|
|
74
74
|
const count = dropLast ? curves : curves + 1;
|
|
@@ -84,7 +84,7 @@ function morphContourToSubpath(c, m = _chunkXRXFVRGYcjs.IDENTITY_MATRIX, closed
|
|
|
84
84
|
anchors[(k + 1) % count].in = { x: p2[0], y: p2[1] };
|
|
85
85
|
}
|
|
86
86
|
for (const a of anchors) {
|
|
87
|
-
const type =
|
|
87
|
+
const type = _chunkOKHKA43Lcjs.inferAnchorType.call(void 0, a);
|
|
88
88
|
if (type !== "corner") a.type = type;
|
|
89
89
|
}
|
|
90
90
|
const isClosed = closed && curves > 0;
|
|
@@ -267,7 +267,7 @@ function bestStart(fixed, free, useShapeContext) {
|
|
|
267
267
|
return best;
|
|
268
268
|
}
|
|
269
269
|
function placeIn(c, from, to) {
|
|
270
|
-
const b =
|
|
270
|
+
const b = _chunkOKHKA43Lcjs.unionBounds.call(void 0, [boundsOfPoints(c.pts)]);
|
|
271
271
|
const p = b ? [b.x + b.width / 2, b.y + b.height / 2] : c.pts[0];
|
|
272
272
|
if (!from || !to) return p;
|
|
273
273
|
const fx = from.width > 0 ? (p[0] - from.x) / from.width : 0.5;
|
|
@@ -456,7 +456,7 @@ function interpolateVectorColor(a, b, t) {
|
|
|
456
456
|
}
|
|
457
457
|
function resampleGradientStops(g, offsets) {
|
|
458
458
|
return offsets.map((offset) => {
|
|
459
|
-
const s =
|
|
459
|
+
const s = _chunkOKHKA43Lcjs.sampleVectorGradient.call(void 0, g, offset);
|
|
460
460
|
return s.opacity < 1 ? { offset, color: s.color, opacity: Math.round(s.opacity * 1e4) / 1e4 } : { offset, color: s.color };
|
|
461
461
|
});
|
|
462
462
|
}
|
|
@@ -467,11 +467,11 @@ function lerpAngle(a, b, t) {
|
|
|
467
467
|
var lerpPoint = (a, b, t) => ({ x: lerpN(a.x, b.x, t), y: lerpN(a.y, b.y, t) });
|
|
468
468
|
var sameColourModel = (a, b) => (_nullishCoalesce(a.interpolation, () => ( "srgb"))) === (_nullishCoalesce(b.interpolation, () => ( "srgb"))) && (_nullishCoalesce(a.smoothness, () => ( 0))) === (_nullishCoalesce(b.smoothness, () => ( 0)));
|
|
469
469
|
function lerpStops(a, b, t) {
|
|
470
|
-
let stopsA =
|
|
471
|
-
let stopsB =
|
|
470
|
+
let stopsA = _chunkOKHKA43Lcjs.sortedVectorGradientStops.call(void 0, a);
|
|
471
|
+
let stopsB = _chunkOKHKA43Lcjs.sortedVectorGradientStops.call(void 0, b);
|
|
472
472
|
const resampled = stopsA.length !== stopsB.length || !sameColourModel(a, b);
|
|
473
473
|
if (resampled) {
|
|
474
|
-
const offs = [...
|
|
474
|
+
const offs = [..._chunkOKHKA43Lcjs.expandVectorGradientStops.call(void 0, a), ..._chunkOKHKA43Lcjs.expandVectorGradientStops.call(void 0, b), ...stopsA, ...stopsB].map((s) => s.offset).filter(Number.isFinite).sort((x, y) => x - y);
|
|
475
475
|
const common = offs.filter((o, i) => i === 0 || o - offs[i - 1] > 1e-4);
|
|
476
476
|
stopsA = resampleGradientStops(a, common);
|
|
477
477
|
stopsB = resampleGradientStops(b, common);
|
|
@@ -498,8 +498,8 @@ function lerpGradient(a, b, t) {
|
|
|
498
498
|
}
|
|
499
499
|
if (near.spread && near.spread !== "pad") out.spread = near.spread;
|
|
500
500
|
if (near.strokeMode && near.strokeMode !== "within") out.strokeMode = near.strokeMode;
|
|
501
|
-
const ea =
|
|
502
|
-
const eb =
|
|
501
|
+
const ea = _chunkOKHKA43Lcjs.hasExplicitGradientGeometry.call(void 0, a);
|
|
502
|
+
const eb = _chunkOKHKA43Lcjs.hasExplicitGradientGeometry.call(void 0, b);
|
|
503
503
|
if (!ea && !eb) {
|
|
504
504
|
if (a.angle !== void 0 || b.angle !== void 0 || a.type === "linear" || a.type === "reflected") {
|
|
505
505
|
const fallback = a.type === "linear" || a.type === "reflected" ? 180 : 90;
|
|
@@ -512,10 +512,10 @@ function lerpGradient(a, b, t) {
|
|
|
512
512
|
}
|
|
513
513
|
return out;
|
|
514
514
|
}
|
|
515
|
-
const pa =
|
|
516
|
-
const pb =
|
|
515
|
+
const pa = _chunkOKHKA43Lcjs.vectorGradientPoints.call(void 0, a);
|
|
516
|
+
const pb = _chunkOKHKA43Lcjs.vectorGradientPoints.call(void 0, b);
|
|
517
517
|
if (pa.units !== pb.units) {
|
|
518
|
-
const src =
|
|
518
|
+
const src = _chunkOKHKA43Lcjs.explicitVectorGradient.call(void 0, near);
|
|
519
519
|
return { ...src, stops: out.stops, ...out.interpolation ? { interpolation: out.interpolation } : {}, ...out.smoothness ? { smoothness: out.smoothness } : {} };
|
|
520
520
|
}
|
|
521
521
|
out.start = lerpPoint(pa.start, pb.start, t);
|
|
@@ -535,14 +535,14 @@ function solidLike(color, like) {
|
|
|
535
535
|
function interpolateVectorPaint(a, b, t) {
|
|
536
536
|
if (t <= 0) return a;
|
|
537
537
|
if (t >= 1) return b;
|
|
538
|
-
const pa =
|
|
539
|
-
const pb =
|
|
538
|
+
const pa = _chunkOKHKA43Lcjs.hasPaint.call(void 0, a);
|
|
539
|
+
const pb = _chunkOKHKA43Lcjs.hasPaint.call(void 0, b);
|
|
540
540
|
if (!pa && !pb) return t < 0.5 ? a : b;
|
|
541
541
|
if (typeof a === "string" && pa && typeof b === "string" && pb) return interpolateVectorColor(a, b, t);
|
|
542
542
|
if (!pa && typeof b === "string") return interpolateVectorColor("transparent", b, t);
|
|
543
543
|
if (!pb && typeof a === "string") return interpolateVectorColor(a, "transparent", t);
|
|
544
|
-
const ga = pa &&
|
|
545
|
-
const gb = pb &&
|
|
544
|
+
const ga = pa && _chunkOKHKA43Lcjs.isVectorGradient.call(void 0, a) ? a : null;
|
|
545
|
+
const gb = pb && _chunkOKHKA43Lcjs.isVectorGradient.call(void 0, b) ? b : null;
|
|
546
546
|
if (ga && gb) return _nullishCoalesce(lerpGradient(ga, gb, t), () => ( (t < 0.5 ? a : b)));
|
|
547
547
|
if (gb) return _nullishCoalesce(lerpGradient(solidLike(pa ? a : null, gb), gb, t), () => ( b));
|
|
548
548
|
if (ga) return _nullishCoalesce(lerpGradient(ga, solidLike(pb ? b : null, ga), t), () => ( a));
|
|
@@ -553,8 +553,8 @@ function interpolateWidthProfiles(a, b, t) {
|
|
|
553
553
|
const at = [..._nullishCoalesce(a, () => ( [])), ..._nullishCoalesce(b, () => ( [])), { t: 0 }, { t: 1 }].map((p) => p.t).sort((x, y) => x - y);
|
|
554
554
|
const ts = at.filter((v, i) => i === 0 || v - at[i - 1] > 1e-6);
|
|
555
555
|
return ts.map((pos) => {
|
|
556
|
-
const x =
|
|
557
|
-
const y =
|
|
556
|
+
const x = _chunkOKHKA43Lcjs.widthProfileAt.call(void 0, a, pos);
|
|
557
|
+
const y = _chunkOKHKA43Lcjs.widthProfileAt.call(void 0, b, pos);
|
|
558
558
|
return { t: pos, left: lerpN(x.left, y.left, t), right: lerpN(x.right, y.right, t) };
|
|
559
559
|
});
|
|
560
560
|
}
|
|
@@ -597,7 +597,7 @@ function reversedStyle(s) {
|
|
|
597
597
|
out.endArrow = s.startArrow;
|
|
598
598
|
out.startArrowScale = s.endArrowScale;
|
|
599
599
|
out.endArrowScale = s.startArrowScale;
|
|
600
|
-
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile =
|
|
600
|
+
if (_optionalChain([s, 'access', _6 => _6.strokeWidthProfile, 'optionalAccess', _7 => _7.length])) out.strokeWidthProfile = _chunkOKHKA43Lcjs.reverseWidthProfile.call(void 0, s.strokeWidthProfile);
|
|
601
601
|
for (const k of ["startArrow", "endArrow", "startArrowScale", "endArrowScale"]) if (out[k] === void 0) delete out[k];
|
|
602
602
|
return out;
|
|
603
603
|
}
|
|
@@ -623,19 +623,19 @@ function styleOf(n) {
|
|
|
623
623
|
return out;
|
|
624
624
|
}
|
|
625
625
|
function contoursOf(node, m) {
|
|
626
|
-
return
|
|
626
|
+
return _chunkOKHKA43Lcjs.expandVectorCorners.call(void 0, node.subpaths).map((sp) => subpathToMorphContour(sp, m)).filter((c) => !!c);
|
|
627
627
|
}
|
|
628
|
-
function preparePathMorph(a, b, options, ma =
|
|
628
|
+
function preparePathMorph(a, b, options, ma = _chunkOKHKA43Lcjs.nodeMatrix.call(void 0, a), mb = _chunkOKHKA43Lcjs.nodeMatrix.call(void 0, b)) {
|
|
629
629
|
const corr = correspondMorphContours(contoursOf(a, ma), contoursOf(b, mb), options);
|
|
630
630
|
const sim = procrustes(corr.a, corr.b);
|
|
631
631
|
const styleA = styleOf(a);
|
|
632
632
|
const styleB = corr.reversed ? reversedStyle(styleOf(b)) : styleOf(b);
|
|
633
|
-
const rigid = !
|
|
633
|
+
const rigid = !_chunkOKHKA43Lcjs.isIdentityMatrix.call(void 0, ma) || !_chunkOKHKA43Lcjs.isIdentityMatrix.call(void 0, mb);
|
|
634
634
|
const id = _nullishCoalesce(options.id, () => ( a.id));
|
|
635
635
|
return (t) => {
|
|
636
636
|
const contours = interpolateMorphContours(corr.a, corr.b, t, { linear: options.linear, rigidity: options.rigidity, similarity: sim });
|
|
637
|
-
const m = rigid ? interpolateRigidMatrix(ma, mb, t) :
|
|
638
|
-
const back = rigid ?
|
|
637
|
+
const m = rigid ? interpolateRigidMatrix(ma, mb, t) : _chunkOKHKA43Lcjs.IDENTITY_MATRIX;
|
|
638
|
+
const back = rigid ? _chunkOKHKA43Lcjs.invertMatrix.call(void 0, m) : _chunkOKHKA43Lcjs.IDENTITY_MATRIX;
|
|
639
639
|
const subpaths = contours.map((c, k) => {
|
|
640
640
|
const closed = t <= 0 ? corr.a[k].closed : t >= 1 ? corr.b[k].closed : corr.a[k].closed && corr.b[k].closed;
|
|
641
641
|
return morphContourToSubpath({ closed: corr.a[k].closed && corr.b[k].closed, pts: c.pts }, back, closed);
|
|
@@ -643,14 +643,14 @@ function preparePathMorph(a, b, options, ma = _chunkXRXFVRGYcjs.nodeMatrix.call(
|
|
|
643
643
|
const node = { id, type: "path", subpaths, ...interpolateVectorStyle(styleA, styleB, t) };
|
|
644
644
|
const opacity = lerpN(_nullishCoalesce(a.opacity, () => ( 1)), _nullishCoalesce(b.opacity, () => ( 1)), t);
|
|
645
645
|
if (opacity < 1) node.opacity = opacity;
|
|
646
|
-
if (rigid && !
|
|
646
|
+
if (rigid && !_chunkOKHKA43Lcjs.isIdentityMatrix.call(void 0, m)) node.transform = m;
|
|
647
647
|
return node;
|
|
648
648
|
};
|
|
649
649
|
}
|
|
650
|
-
function flattenPaths(node, parent =
|
|
651
|
-
const m =
|
|
650
|
+
function flattenPaths(node, parent = _chunkOKHKA43Lcjs.IDENTITY_MATRIX) {
|
|
651
|
+
const m = _chunkOKHKA43Lcjs.multiplyMatrices.call(void 0, _chunkOKHKA43Lcjs.nodeMatrix.call(void 0, node), parent);
|
|
652
652
|
if (node.type === "path") return [{ path: node, m, opacity: 1 }];
|
|
653
|
-
if (node.type === "text" || node.type === "instance") return flattenPaths(
|
|
653
|
+
if (node.type === "text" || node.type === "instance") return flattenPaths(_chunkOKHKA43Lcjs.expandVectorAppearance.call(void 0, node), parent);
|
|
654
654
|
const o = _nullishCoalesce(node.opacity, () => ( 1));
|
|
655
655
|
return node.children.filter((c) => c.visible !== false).flatMap((c) => flattenPaths(c, m)).map((e) => ({ ...e, opacity: e.opacity * o }));
|
|
656
656
|
}
|
|
@@ -672,8 +672,8 @@ function createVectorMorph(a, b, options = {}) {
|
|
|
672
672
|
}
|
|
673
673
|
const pa = flattenPaths(a);
|
|
674
674
|
const pb = flattenPaths(b);
|
|
675
|
-
const ba =
|
|
676
|
-
const bb =
|
|
675
|
+
const ba = _chunkOKHKA43Lcjs.unionBounds.call(void 0, pa.map((e) => placedBounds(e.path, e.m)));
|
|
676
|
+
const bb = _chunkOKHKA43Lcjs.unionBounds.call(void 0, pb.map((e) => placedBounds(e.path, e.m)));
|
|
677
677
|
const id = _nullishCoalesce(options.id, () => ( a.id));
|
|
678
678
|
const parts = [];
|
|
679
679
|
const opacities = [];
|
|
@@ -685,10 +685,10 @@ function createVectorMorph(a, b, options = {}) {
|
|
|
685
685
|
parts.push(preparePathMorph(x.path, y.path, sub, x.m, y.m));
|
|
686
686
|
opacities.push([x.opacity, y.opacity]);
|
|
687
687
|
} else if (x) {
|
|
688
|
-
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m,
|
|
688
|
+
parts.push(preparePathMorph(x.path, collapsedPath(x.path, x.m, ba, bb), sub, x.m, _chunkOKHKA43Lcjs.IDENTITY_MATRIX));
|
|
689
689
|
opacities.push([x.opacity, x.opacity]);
|
|
690
690
|
} else if (y) {
|
|
691
|
-
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub,
|
|
691
|
+
parts.push(preparePathMorph(collapsedPath(y.path, y.m, bb, ba), y.path, sub, _chunkOKHKA43Lcjs.IDENTITY_MATRIX, y.m));
|
|
692
692
|
opacities.push([y.opacity, y.opacity]);
|
|
693
693
|
}
|
|
694
694
|
}
|