@pixerate/editor 0.236.0 → 0.238.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/README.md +1 -1
- package/dist/agent/index.cjs +40 -39
- package/dist/agent/index.js +9 -8
- package/dist/animation/index.cjs +7 -6
- package/dist/animation/index.js +6 -5
- package/dist/animation-editor/index.cjs +66 -65
- package/dist/animation-editor/index.js +9 -8
- package/dist/{brushstrokeRender-WDTKD54B.cjs → brushstrokeRender-MPOM7BFW.cjs} +7 -5
- package/dist/{brushstrokeRender-MAHOXL7K.js → brushstrokeRender-WB67GMUP.js} +4 -2
- package/dist/canvas/index.cjs +55 -54
- package/dist/canvas/index.js +10 -9
- package/dist/chart/index.cjs +159 -158
- package/dist/chart/index.js +9 -8
- package/dist/{chunk-L6Y7TSQ4.js → chunk-36ZTV7WO.js} +1 -1
- package/dist/{chunk-JVNGCS26.js → chunk-3E36VDMJ.js} +1 -1
- package/dist/{chunk-WRZ6C4TU.cjs → chunk-3R5P3DVY.cjs} +6 -6
- package/dist/{chunk-RUONPPMC.cjs → chunk-44BMJJVA.cjs} +8 -8
- package/dist/{chunk-YBAPT7NL.js → chunk-6ADHGQ73.js} +4 -2
- package/dist/chunk-7AHBW2CQ.cjs +200 -0
- package/dist/{chunk-EUIDTZNQ.cjs → chunk-7PT4RJL5.cjs} +113 -111
- package/dist/{chunk-CU6ANS5L.js → chunk-7YGBSFC6.js} +2 -2
- package/dist/{chunk-ATKKG76G.cjs → chunk-AD7GA3TL.cjs} +23 -23
- package/dist/{chunk-FSLKBQU7.js → chunk-AIS56JOO.js} +3 -3
- package/dist/{chunk-5VQXSS2S.cjs → chunk-BBUE3UJL.cjs} +86 -86
- package/dist/{chunk-7272D3K2.js → chunk-BP6KSGVD.js} +6 -4
- package/dist/{chunk-F6R67I3A.js → chunk-CXXXAZ7H.js} +1 -1
- package/dist/{chunk-5DQPDXOM.cjs → chunk-D2SGV525.cjs} +76 -76
- package/dist/chunk-F67XMVDI.js +200 -0
- package/dist/{chunk-PHYOZK3B.js → chunk-FQVVO5YA.js} +85 -8
- package/dist/{chunk-UXETV2NC.cjs → chunk-GA4EU4P3.cjs} +4 -4
- package/dist/{chunk-UFEDHACQ.js → chunk-GXAK6Q5J.js} +2 -2
- package/dist/{chunk-MHLU6GRJ.js → chunk-JEGJP4OW.js} +7 -196
- package/dist/{chunk-GOBOCZZI.js → chunk-LEQKZGQI.js} +1 -1
- package/dist/{chunk-M5GLQQWG.cjs → chunk-LJZRHVZV.cjs} +2 -2
- package/dist/{chunk-N76AMOKE.cjs → chunk-MOW3JMNG.cjs} +42 -42
- package/dist/{chunk-WKMUBATU.js → chunk-N4DFDI73.js} +1 -1
- package/dist/{chunk-GNZI3KYK.cjs → chunk-NKTNLJUJ.cjs} +49 -9
- package/dist/{chunk-TQOL6CF7.js → chunk-PJYG6FCF.js} +49 -9
- package/dist/{chunk-V3L7U63N.cjs → chunk-PP6BXVRL.cjs} +1 -1
- package/dist/{chunk-TFF2GTGN.cjs → chunk-PPFJHTW5.cjs} +24 -22
- package/dist/{chunk-6ZZKRH7R.js → chunk-QARCM66V.js} +3 -3
- package/dist/{chunk-5UEFBM2M.cjs → chunk-RD7RX52G.cjs} +18 -207
- package/dist/{chunk-CDP2AKMA.js → chunk-RV5DKZHU.js} +1 -1
- package/dist/{chunk-HUAISCUX.cjs → chunk-T7KQEMAE.cjs} +18 -18
- package/dist/{chunk-BQE3Y6ZO.cjs → chunk-THXFU3JB.cjs} +5 -5
- package/dist/{chunk-4ZC5QJE2.cjs → chunk-UTI5IITZ.cjs} +3 -3
- package/dist/{chunk-XSVUNSDJ.js → chunk-UUBO6RB5.js} +1 -1
- package/dist/{chunk-WPWHT4Z6.cjs → chunk-UZU6DIZA.cjs} +221 -144
- package/dist/{chunk-M2TPMYJE.js → chunk-V6DT2CDH.js} +1 -1
- package/dist/{chunk-WV5WTOC6.cjs → chunk-W7GRGGBH.cjs} +16 -16
- package/dist/{chunk-23E5GI2U.js → chunk-WGN7AUKB.js} +2 -2
- package/dist/{chunk-YMREOA67.js → chunk-XK4SST43.js} +2 -2
- package/dist/{chunk-SOSBOS5T.cjs → chunk-XWOLPNBW.cjs} +22 -22
- package/dist/{chunk-ILP77UD6.js → chunk-YGQVCQTG.js} +1 -1
- package/dist/{chunk-GXLZZVR5.cjs → chunk-ZXNO3ZOX.cjs} +37 -37
- package/dist/color/index.cjs +6 -4
- package/dist/color/index.js +9 -7
- package/dist/export/index.cjs +8 -7
- package/dist/export/index.js +7 -6
- package/dist/extensions/index.cjs +13 -10
- package/dist/extensions/index.js +12 -9
- package/dist/extensions/loading-node.d.cts +45 -1
- package/dist/extensions/loading-node.d.ts +45 -1
- package/dist/gradient/index.cjs +29 -28
- package/dist/gradient/index.js +4 -3
- package/dist/image-editor/index.cjs +778 -777
- package/dist/image-editor/index.js +9 -8
- package/dist/index.cjs +19 -16
- package/dist/index.js +13 -10
- package/dist/paint-editor/controller.d.cts +31 -1
- package/dist/paint-editor/controller.d.ts +31 -1
- package/dist/paint-editor/index.cjs +403 -195
- package/dist/paint-editor/index.js +231 -23
- package/dist/paint-editor/sticker-tools.d.cts +1 -1
- package/dist/paint-editor/sticker-tools.d.ts +1 -1
- package/dist/paint-editor/stickers.d.cts +10 -3
- package/dist/paint-editor/stickers.d.ts +10 -3
- package/dist/paint-editor/ui.d.cts +10 -3
- package/dist/paint-editor/ui.d.ts +10 -3
- package/dist/tokens/index.cjs +4 -3
- package/dist/tokens/index.js +3 -2
- package/dist/typography/index.cjs +8 -7
- package/dist/typography/index.js +3 -2
- package/dist/vector/index.cjs +967 -966
- package/dist/vector/index.js +9 -8
- package/dist/video-editor/index.cjs +7 -6
- package/dist/video-editor/index.js +6 -5
- package/package.json +1 -1
- package/skills/pixerate-color/SKILL.md +3 -0
- package/skills/pixerate-image-editor/SKILL.md +1 -0
- package/skills/pixerate-paint-editor/SKILL.md +6 -2
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunk3R5P3DVYcjs = require('./chunk-3R5P3DVY.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
var _chunk55AKPTLMcjs = require('./chunk-55AKPTLM.cjs');
|
|
@@ -1239,7 +1239,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1239
1239
|
const { spec, theme, marks, measure, fs } = ctx;
|
|
1240
1240
|
const horizontal = spec.orientation === "horizontal";
|
|
1241
1241
|
const n = spec.categories.length;
|
|
1242
|
-
const types = new Map(visible.map((s) => [s.id,
|
|
1242
|
+
const types = new Map(visible.map((s) => [s.id, _chunk3R5P3DVYcjs.chartSeriesType.call(void 0, spec, s)]));
|
|
1243
1243
|
const stacked = spec.stacking !== "none";
|
|
1244
1244
|
const percent = spec.stacking === "percent";
|
|
1245
1245
|
const onSecondary = (s) => s.axis === "secondary";
|
|
@@ -1276,7 +1276,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1276
1276
|
const stack = stacks.get(s.id);
|
|
1277
1277
|
errors.set(
|
|
1278
1278
|
s.id,
|
|
1279
|
-
|
|
1279
|
+
_chunk3R5P3DVYcjs.chartErrorAmounts.call(void 0, s.errorBars, s.values).map((e, i) => {
|
|
1280
1280
|
const raw = s.values[i];
|
|
1281
1281
|
const seg = _optionalChain([stack, 'optionalAccess', _11 => _11.segments, 'access', _12 => _12[i]]);
|
|
1282
1282
|
if (!e || raw === null || stack && !seg) return null;
|
|
@@ -1346,7 +1346,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1346
1346
|
const drawOrder = [...visible].sort((a, b) => order(types.get(a.id)) - order(types.get(b.id)));
|
|
1347
1347
|
for (const s of drawOrder) {
|
|
1348
1348
|
const si = spec.series.indexOf(s);
|
|
1349
|
-
const color =
|
|
1349
|
+
const color = _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, si);
|
|
1350
1350
|
const type = types.get(s.id);
|
|
1351
1351
|
const stack = stacks.get(s.id);
|
|
1352
1352
|
const selSeries = ctx.seriesSelected(s.id);
|
|
@@ -1372,7 +1372,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1372
1372
|
const selected = ctx.isSelected(target);
|
|
1373
1373
|
const [x, y] = map({ c: c0, v: Math.min(a, b) });
|
|
1374
1374
|
const rect = horizontal ? { x: Math.min(a, b), y: c0, width: Math.abs(b - a), height: cw } : { x, y, width: cw, height: Math.abs(b - a) };
|
|
1375
|
-
const fill =
|
|
1375
|
+
const fill = _chunk3R5P3DVYcjs.chartPointColor.call(void 0, spec, si, i);
|
|
1376
1376
|
marks.push({
|
|
1377
1377
|
kind: "rect",
|
|
1378
1378
|
key: `bar-${s.id}-${i}`,
|
|
@@ -1451,7 +1451,7 @@ function layoutCartesian(ctx, area, visible) {
|
|
|
1451
1451
|
const target = { kind: "point", seriesId: s.id, index: i };
|
|
1452
1452
|
const selected = ctx.isSelected(target);
|
|
1453
1453
|
const r = type === "scatter" ? 4.5 : 3.5;
|
|
1454
|
-
const pointColor =
|
|
1454
|
+
const pointColor = _chunk3R5P3DVYcjs.chartPointColor.call(void 0, spec, si, i);
|
|
1455
1455
|
const fill = showDots ? type === "scatter" ? pointColor : theme.surface : "transparent";
|
|
1456
1456
|
marks.push(
|
|
1457
1457
|
pointMark({ key: `point-${s.id}-${i}`, target, selected: selected || selSeries, opacity: type === "scatter" ? 0.85 : void 0 }, showDots ? marker : "hit", cx, cy, showDots ? r : 6, fill, showDots ? pointColor : void 0, 2)
|
|
@@ -1525,8 +1525,8 @@ function layoutXy(ctx, area, visible) {
|
|
|
1525
1525
|
const yErrors = /* @__PURE__ */ new Map();
|
|
1526
1526
|
const xErrors = /* @__PURE__ */ new Map();
|
|
1527
1527
|
for (const { s } of all) {
|
|
1528
|
-
if (s.errorBars) yErrors.set(s.id,
|
|
1529
|
-
if (s.xErrorBars) xErrors.set(s.id,
|
|
1528
|
+
if (s.errorBars) yErrors.set(s.id, _chunk3R5P3DVYcjs.chartErrorAmounts.call(void 0, s.errorBars, s.values));
|
|
1529
|
+
if (s.xErrorBars) xErrors.set(s.id, _chunk3R5P3DVYcjs.chartErrorAmounts.call(void 0, s.xErrorBars, s.values.map((_, i) => _nullishCoalesce(_optionalChain([s, 'access', _29 => _29.x, 'optionalAccess', _30 => _30[i]]), () => ( (bubble || !s.x ? i + 1 : null))))));
|
|
1530
1530
|
}
|
|
1531
1531
|
let xlo = Infinity;
|
|
1532
1532
|
let xhi = -Infinity;
|
|
@@ -1609,8 +1609,8 @@ function layoutXy(ctx, area, visible) {
|
|
|
1609
1609
|
const trendLabels = [];
|
|
1610
1610
|
for (const { s, pts } of all) {
|
|
1611
1611
|
const si = spec.series.indexOf(s);
|
|
1612
|
-
const color =
|
|
1613
|
-
const type =
|
|
1612
|
+
const color = _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, si);
|
|
1613
|
+
const type = _chunk3R5P3DVYcjs.chartSeriesType.call(void 0, spec, s);
|
|
1614
1614
|
const selSeries = ctx.seriesSelected(s.id);
|
|
1615
1615
|
const seriesTarget = { kind: "series", seriesId: s.id };
|
|
1616
1616
|
if (type === "line" || type === "area") {
|
|
@@ -1635,7 +1635,7 @@ function layoutXy(ctx, area, visible) {
|
|
|
1635
1635
|
}
|
|
1636
1636
|
const target = { kind: "point", seriesId: s.id, index: p.i };
|
|
1637
1637
|
const selected = ctx.isSelected(target);
|
|
1638
|
-
const pointColor =
|
|
1638
|
+
const pointColor = _chunk3R5P3DVYcjs.chartPointColor.call(void 0, spec, si, p.i);
|
|
1639
1639
|
const r = bubble ? maxSize > 0 && p.size !== null && p.size > 0 ? Math.max(2, Math.sqrt(p.size / maxSize) * maxR) : 2 : 4.5;
|
|
1640
1640
|
if (bubble) marks.push({ kind: "circle", key: `point-${s.id}-${p.i}`, role: "point", cx, cy, r, fill: pointColor, stroke: pointColor, strokeWidth: 1, opacity: 0.6, target, selected: selected || selSeries });
|
|
1641
1641
|
else marks.push(pointMark({ key: `point-${s.id}-${p.i}`, target, selected: selected || selSeries, opacity: 0.85 }, marker === "none" ? "hit" : marker, cx, cy, marker === "none" ? 6 : r, marker === "none" ? "transparent" : pointColor, marker === "none" ? void 0 : pointColor, 2));
|
|
@@ -1749,7 +1749,7 @@ function layoutStreamgraph(ctx, area, visible) {
|
|
|
1749
1749
|
const layers = [];
|
|
1750
1750
|
for (let sIdx = 0; sIdx < visible.length; sIdx++) {
|
|
1751
1751
|
const s = visible[sIdx];
|
|
1752
|
-
const color =
|
|
1752
|
+
const color = _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
|
|
1753
1753
|
const selSeries = ctx.seriesSelected(s.id);
|
|
1754
1754
|
const bottomPts = [];
|
|
1755
1755
|
const topPts = [];
|
|
@@ -1899,7 +1899,7 @@ function chartMapBreaks(values, steps, thresholds) {
|
|
|
1899
1899
|
var chartMapClass = (value, breaks) => breaks.filter((b) => value >= b).length;
|
|
1900
1900
|
function chartMapRamp(base, count) {
|
|
1901
1901
|
if (count <= 1) return [base];
|
|
1902
|
-
return Array.from({ length: count }, (_, k) =>
|
|
1902
|
+
return Array.from({ length: count }, (_, k) => _chunk3R5P3DVYcjs.shadeChartColor.call(void 0, base, 0.82 - 1.17 * k / (count - 1)));
|
|
1903
1903
|
}
|
|
1904
1904
|
|
|
1905
1905
|
// src/chart/race.ts
|
|
@@ -1935,7 +1935,7 @@ function chartRaceRanking(spec, frame) {
|
|
|
1935
1935
|
}
|
|
1936
1936
|
|
|
1937
1937
|
// src/chart/layout-families.ts
|
|
1938
|
-
var sliceColor = (ctx, series, i) => _optionalChain([series, 'access', _45 => _45.pointColors, 'optionalAccess', _46 => _46[i]]) ||
|
|
1938
|
+
var sliceColor = (ctx, series, i) => _optionalChain([series, 'access', _45 => _45.pointColors, 'optionalAccess', _46 => _46[i]]) || _chunk3R5P3DVYcjs.chartSliceColor.call(void 0, ctx.spec, i);
|
|
1939
1939
|
function layoutPie(ctx, area, series) {
|
|
1940
1940
|
const { spec, theme, marks, fs, selection } = ctx;
|
|
1941
1941
|
const values = spec.categories.map((_, i) => {
|
|
@@ -2051,7 +2051,7 @@ function layoutRadar(ctx, area, visible) {
|
|
|
2051
2051
|
});
|
|
2052
2052
|
for (const s of visible) {
|
|
2053
2053
|
const si = spec.series.indexOf(s);
|
|
2054
|
-
const color =
|
|
2054
|
+
const color = _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, si);
|
|
2055
2055
|
const selSeries = ctx.seriesSelected(s.id);
|
|
2056
2056
|
const pts = s.values.map((v, i) => v !== null && Number.isFinite(v) ? at(i, rOf(v)) : null);
|
|
2057
2057
|
const present = pts.filter((p) => p !== null);
|
|
@@ -2101,7 +2101,7 @@ function layoutWaterfall(ctx, area, series) {
|
|
|
2101
2101
|
});
|
|
2102
2102
|
const { band, catCenter, map, value } = frame;
|
|
2103
2103
|
const w = band * (1 - spec.gapWidth);
|
|
2104
|
-
const color =
|
|
2104
|
+
const color = _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(series));
|
|
2105
2105
|
const format = _nullishCoalesce(series.format, () => ( spec.yAxis.format));
|
|
2106
2106
|
const labelsOn = _nullishCoalesce(series.dataLabels, () => ( spec.dataLabels));
|
|
2107
2107
|
let prevEnd = null;
|
|
@@ -2160,7 +2160,7 @@ function layoutHistogram(ctx, area, visible) {
|
|
|
2160
2160
|
const gap = k > 1 ? band * spec.gapWidth * 0.5 : 0;
|
|
2161
2161
|
const w = (band - gap) / k;
|
|
2162
2162
|
visible.forEach((s, si) => {
|
|
2163
|
-
const color =
|
|
2163
|
+
const color = _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
|
|
2164
2164
|
const target = { kind: "series", seriesId: s.id };
|
|
2165
2165
|
const selected = ctx.seriesSelected(s.id);
|
|
2166
2166
|
counts[si].forEach((c, b) => {
|
|
@@ -2191,7 +2191,7 @@ function layoutBox(ctx, area, visible) {
|
|
|
2191
2191
|
visible.forEach((s, i) => {
|
|
2192
2192
|
const st = stats[i];
|
|
2193
2193
|
if (!st) return;
|
|
2194
|
-
const color =
|
|
2194
|
+
const color = _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
|
|
2195
2195
|
const target = { kind: "series", seriesId: s.id };
|
|
2196
2196
|
const selected = ctx.seriesSelected(s.id);
|
|
2197
2197
|
const c = catCenter(i);
|
|
@@ -2410,7 +2410,7 @@ function layoutLikert(ctx, area, visible) {
|
|
|
2410
2410
|
if (x1 - x0 <= 0) return;
|
|
2411
2411
|
const target = { kind: "point", seriesId: s.id, index: i };
|
|
2412
2412
|
const selected = ctx.isSelected(target);
|
|
2413
|
-
const fill = _optionalChain([s, 'access', _48 => _48.pointColors, 'optionalAccess', _49 => _49[i]]) ||
|
|
2413
|
+
const fill = _optionalChain([s, 'access', _48 => _48.pointColors, 'optionalAccess', _49 => _49[i]]) || _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(s));
|
|
2414
2414
|
const rect = { x: x0, y, width: x1 - x0, height: barH };
|
|
2415
2415
|
marks.push({ kind: "rect", key, role: "bar", ...rect, fill, target, selected: selected || ctx.seriesSelected(s.id) || catSelected });
|
|
2416
2416
|
if (selected) ctx.outline(`${key}-selection`, { x: rect.x - 2, y: rect.y - 2, width: rect.width + 4, height: rect.height + 4 });
|
|
@@ -2509,8 +2509,8 @@ function layoutParliament(ctx, area, series) {
|
|
|
2509
2509
|
}
|
|
2510
2510
|
function treeColor(ctx, series, node, group, base, shade) {
|
|
2511
2511
|
if (node.color) return node.color;
|
|
2512
|
-
if (base === null) return _optionalChain([series, 'optionalAccess', _50 => _50.pointColors, 'optionalAccess', _51 => _51[group]]) ||
|
|
2513
|
-
return
|
|
2512
|
+
if (base === null) return _optionalChain([series, 'optionalAccess', _50 => _50.pointColors, 'optionalAccess', _51 => _51[group]]) || _chunk3R5P3DVYcjs.chartSliceColor.call(void 0, ctx.spec, group);
|
|
2513
|
+
return _chunk3R5P3DVYcjs.shadeChartColor.call(void 0, base, shade);
|
|
2514
2514
|
}
|
|
2515
2515
|
function layoutTreemapTree(ctx, area, series) {
|
|
2516
2516
|
const { spec, marks, theme, fs, measure } = ctx;
|
|
@@ -2518,7 +2518,7 @@ function layoutTreemapTree(ctx, area, series) {
|
|
|
2518
2518
|
const labelsOn = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _53 => _53.dataLabels]), () => ( true));
|
|
2519
2519
|
let unlabelled = 0;
|
|
2520
2520
|
const draw = (nodes, rect, key, group, base) => {
|
|
2521
|
-
const rects = chartSquarify(nodes.map(
|
|
2521
|
+
const rects = chartSquarify(nodes.map(_chunk3R5P3DVYcjs.chartTreeTotal), rect);
|
|
2522
2522
|
nodes.forEach((node, k) => {
|
|
2523
2523
|
const r = rects[k];
|
|
2524
2524
|
if (r.width <= 0.5 || r.height <= 0.5) return;
|
|
@@ -2553,10 +2553,10 @@ function layoutTreemapTree(ctx, area, series) {
|
|
|
2553
2553
|
}
|
|
2554
2554
|
function layoutSunburst(ctx, area, series) {
|
|
2555
2555
|
const { spec, marks, theme, fs, measure } = ctx;
|
|
2556
|
-
const tree = spec.tree.length ? spec.tree :
|
|
2556
|
+
const tree = spec.tree.length ? spec.tree : _chunk3R5P3DVYcjs.chartTreeFromSeries.call(void 0, spec.categories, _nullishCoalesce(_optionalChain([series, 'optionalAccess', _55 => _55.values]), () => ( [])));
|
|
2557
2557
|
const indexOf = new Map(spec.categories.map((c, i) => [c.trim() || `${i + 1}`, i]));
|
|
2558
|
-
const depth =
|
|
2559
|
-
const total = tree.reduce((t, n) => t +
|
|
2558
|
+
const depth = _chunk3R5P3DVYcjs.chartTreeDepth.call(void 0, tree);
|
|
2559
|
+
const total = tree.reduce((t, n) => t + _chunk3R5P3DVYcjs.chartTreeTotal.call(void 0, n), 0);
|
|
2560
2560
|
const cx = area.x + area.width / 2;
|
|
2561
2561
|
const cy = area.y + area.height / 2;
|
|
2562
2562
|
const outer = Math.max(8, Math.min(area.width, area.height) / 2 - 4);
|
|
@@ -2570,10 +2570,10 @@ function layoutSunburst(ctx, area, series) {
|
|
|
2570
2570
|
const format = _nullishCoalesce(_optionalChain([series, 'optionalAccess', _56 => _56.format]), () => ( spec.yAxis.format));
|
|
2571
2571
|
let unlabelled = 0;
|
|
2572
2572
|
const walk = (nodes, start, sweep, level, key, group, base) => {
|
|
2573
|
-
const sum = nodes.reduce((t, n) => t +
|
|
2573
|
+
const sum = nodes.reduce((t, n) => t + _chunk3R5P3DVYcjs.chartTreeTotal.call(void 0, n), 0);
|
|
2574
2574
|
let at = start;
|
|
2575
2575
|
nodes.forEach((node, k) => {
|
|
2576
|
-
const value =
|
|
2576
|
+
const value = _chunk3R5P3DVYcjs.chartTreeTotal.call(void 0, node);
|
|
2577
2577
|
if (!(value > 0) || !sum) return;
|
|
2578
2578
|
const a0 = at;
|
|
2579
2579
|
const a1 = at + sweep * value / sum;
|
|
@@ -2645,7 +2645,7 @@ function layoutSankey(ctx, area, series) {
|
|
|
2645
2645
|
y += value[i] * ky + pad;
|
|
2646
2646
|
}
|
|
2647
2647
|
}
|
|
2648
|
-
const color = (i) => _optionalChain([series, 'optionalAccess', _61 => _61.pointColors, 'optionalAccess', _62 => _62[i]]) ||
|
|
2648
|
+
const color = (i) => _optionalChain([series, 'optionalAccess', _61 => _61.pointColors, 'optionalAccess', _62 => _62[i]]) || _chunk3R5P3DVYcjs.chartSliceColor.call(void 0, spec, i);
|
|
2649
2649
|
const named = new Set(spec.highlight);
|
|
2650
2650
|
const lit = nodes.map((n) => named.has(n));
|
|
2651
2651
|
const dimLinks = lit.some(Boolean);
|
|
@@ -2730,7 +2730,7 @@ function layoutBarRace(ctx, area, frame) {
|
|
|
2730
2730
|
const target = { kind: "point", seriesId: e.seriesId, index };
|
|
2731
2731
|
const selected = ctx.isSelected(target) || ctx.seriesSelected(e.seriesId);
|
|
2732
2732
|
const width = Math.max(0, xOf(e.value) - plot.x);
|
|
2733
|
-
marks.push({ kind: "rect", key: `bar-${e.seriesId}`, role: "bar", x: plot.x, y, width, height: barH, fill:
|
|
2733
|
+
marks.push({ kind: "rect", key: `bar-${e.seriesId}`, role: "bar", x: plot.x, y, width, height: barH, fill: _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, si), radius: Math.min(3, barH / 4), target, selected, ...selected ? { stroke: theme.selection, strokeWidth: 1.5 } : {} });
|
|
2734
2734
|
marks.push({ kind: "text", key: `label-name-${e.seriesId}`, role: "tick-label", x: plot.x - 6, y: y + barH / 2, text: truncate(e.name, labelW - 8, fs, measure), anchor: "end", baseline: "middle", size: fs, fill: selected ? theme.selection : theme.text, target: { kind: "series", seriesId: e.seriesId } });
|
|
2735
2735
|
if (_nullishCoalesce(s.dataLabels, () => ( true))) marks.push({ kind: "text", key: `label-${e.seriesId}`, role: "data-label", x: plot.x + width + 5, y: y + barH / 2, text: formatChartNumber(e.value, _nullishCoalesce(s.format, () => ( format)), _nullishCoalesce((_nullishCoalesce(s.format, () => ( format))).decimals, () => ( (Math.abs(e.value) >= 100 ? 0 : void 0)))), anchor: "start", baseline: "middle", size: fs - 1, fill: theme.text, target });
|
|
2736
2736
|
}
|
|
@@ -2755,7 +2755,7 @@ function layoutChoropleth(ctx, area, series) {
|
|
|
2755
2755
|
};
|
|
2756
2756
|
const present = [...indexOf.values()].map(valueAt).filter((v) => v !== null);
|
|
2757
2757
|
const breaks = chartMapBreaks(present, spec.mapSteps, spec.mapThresholds);
|
|
2758
|
-
const ramp = chartMapRamp(_nullishCoalesce(series.color, () => (
|
|
2758
|
+
const ramp = chartMapRamp(_nullishCoalesce(series.color, () => ( _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(series)))), breaks.length + 1);
|
|
2759
2759
|
const format = _nullishCoalesce(series.format, () => ( spec.yAxis.format));
|
|
2760
2760
|
const legendH = fs * 2.2;
|
|
2761
2761
|
const s = Math.max(1e-6, Math.min(area.width / map.width, (area.height - legendH) / map.height));
|
|
@@ -2800,14 +2800,14 @@ function layoutChoropleth(ctx, area, series) {
|
|
|
2800
2800
|
|
|
2801
2801
|
// src/chart/layout.ts
|
|
2802
2802
|
function legendItems(spec, ctx) {
|
|
2803
|
-
const family =
|
|
2803
|
+
const family = _chunk3R5P3DVYcjs.chartFamily.call(void 0, spec);
|
|
2804
2804
|
if (spec.type === "funnel" || spec.type === "slope" || spec.type === "sankey" || spec.type === "barrace" || spec.type === "choropleth") return [];
|
|
2805
|
-
if (
|
|
2805
|
+
if (_chunk3R5P3DVYcjs.chartSpecColorsByCategory.call(void 0, spec)) {
|
|
2806
2806
|
const first = spec.series.find((s) => !s.hidden);
|
|
2807
2807
|
const seats = (i) => Math.max(0, Math.round(_nullishCoalesce(_optionalChain([first, 'optionalAccess', _68 => _68.values, 'access', _69 => _69[i]]), () => ( 0))));
|
|
2808
2808
|
return spec.categories.map((c, i) => ({
|
|
2809
2809
|
label: spec.type === "parliament" ? `${c} ${seats(i)}` : c,
|
|
2810
|
-
color: _optionalChain([first, 'optionalAccess', _70 => _70.pointColors, 'optionalAccess', _71 => _71[i]]) ||
|
|
2810
|
+
color: _optionalChain([first, 'optionalAccess', _70 => _70.pointColors, 'optionalAccess', _71 => _71[i]]) || _chunk3R5P3DVYcjs.chartSliceColor.call(void 0, spec, i),
|
|
2811
2811
|
target: { kind: "category", index: i },
|
|
2812
2812
|
faded: false,
|
|
2813
2813
|
selected: ctx.isSelected({ kind: "category", index: i }),
|
|
@@ -2821,17 +2821,17 @@ function legendItems(spec, ctx) {
|
|
|
2821
2821
|
return [
|
|
2822
2822
|
{ label: "Increase", color: ctx.theme.positive, target, faded: false, selected: false, shape: "square" },
|
|
2823
2823
|
{ label: "Decrease", color: ctx.theme.negative, target, faded: false, selected: false, shape: "square" },
|
|
2824
|
-
{ label: "Total", color:
|
|
2824
|
+
{ label: "Total", color: _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, spec.series.indexOf(first)), target, faded: false, selected: false, shape: "square" }
|
|
2825
2825
|
];
|
|
2826
2826
|
}
|
|
2827
2827
|
if (family === "box") return [];
|
|
2828
|
-
const trends = trendlineLegendItems(spec, (i) =>
|
|
2828
|
+
const trends = trendlineLegendItems(spec, (i) => _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, i));
|
|
2829
2829
|
const items = [];
|
|
2830
2830
|
spec.series.forEach((s, i) => {
|
|
2831
|
-
const type =
|
|
2831
|
+
const type = _chunk3R5P3DVYcjs.chartSeriesType.call(void 0, spec, s);
|
|
2832
2832
|
items.push({
|
|
2833
2833
|
label: s.name,
|
|
2834
|
-
color:
|
|
2834
|
+
color: _chunk3R5P3DVYcjs.chartSeriesColor.call(void 0, spec, i),
|
|
2835
2835
|
target: { kind: "series", seriesId: s.id },
|
|
2836
2836
|
faded: !!s.hidden,
|
|
2837
2837
|
selected: ctx.seriesSelected(s.id),
|
|
@@ -2844,7 +2844,7 @@ function legendItems(spec, ctx) {
|
|
|
2844
2844
|
function layoutChart(spec, options) {
|
|
2845
2845
|
const width = Math.max(1, Number.isFinite(options.width) ? options.width : 1);
|
|
2846
2846
|
const height = Math.max(1, Number.isFinite(options.height) ? options.height : 1);
|
|
2847
|
-
const theme = { ...
|
|
2847
|
+
const theme = { ..._chunk3R5P3DVYcjs.DEFAULT_CHART_THEME, ...options.theme };
|
|
2848
2848
|
const selection = _nullishCoalesce(options.selection, () => ( null));
|
|
2849
2849
|
const marks = [];
|
|
2850
2850
|
const warnings = [];
|
|
@@ -2883,17 +2883,17 @@ function layoutChart(spec, options) {
|
|
|
2883
2883
|
if (spec.title) titleMark("title", spec.title, theme.titleSize, 600, theme.text);
|
|
2884
2884
|
if (spec.subtitle) titleMark("subtitle", spec.subtitle, fs + 1, 400, theme.mutedText);
|
|
2885
2885
|
if (spec.title || spec.subtitle) top += 6;
|
|
2886
|
-
const family =
|
|
2886
|
+
const family = _chunk3R5P3DVYcjs.chartFamily.call(void 0, spec);
|
|
2887
2887
|
const visible = spec.series.filter((s) => !s.hidden);
|
|
2888
2888
|
const items = legendItems(spec, ctx);
|
|
2889
2889
|
let area = { x: pad, y: top, width: width - pad * 2, height: height - top - pad - noteHeight(spec, fs) };
|
|
2890
2890
|
const seriesLegend = family === "cartesian" || family === "xy" || family === "radar" || family === "histogram";
|
|
2891
2891
|
const hasTrend = items.some((i) => i.shape === "dash");
|
|
2892
|
-
const showLegend = spec.legend.show && items.length > 0 && (!seriesLegend ||
|
|
2892
|
+
const showLegend = spec.legend.show && items.length > 0 && (!seriesLegend || _chunk3R5P3DVYcjs.chartVariesColors.call(void 0, spec) || spec.series.length > 1 || spec.series.some((s) => s.hidden) || hasTrend);
|
|
2893
2893
|
if (showLegend) area = layoutLegend(items, spec.legend.position, area, ctx, ctx.isSelected({ kind: "legend" }));
|
|
2894
2894
|
const finish = (result) => {
|
|
2895
2895
|
if (result.plot.width > 0) {
|
|
2896
|
-
if (chartAnnotationFamily(
|
|
2896
|
+
if (chartAnnotationFamily(_chunk3R5P3DVYcjs.chartFamily.call(void 0, spec))) drawCallouts(ctx, result.plot);
|
|
2897
2897
|
else if (spec.referenceLines.length || spec.referenceBands.length || spec.series.some((s) => s.callouts))
|
|
2898
2898
|
ctx.warn("annotations-skipped", `Reference lines, bands and callouts are drawn on bar, line, area, scatter and bubble charts; this ${spec.type} chart leaves them out.`);
|
|
2899
2899
|
}
|
|
@@ -3074,7 +3074,7 @@ function addReadout(ctx, readout, plot) {
|
|
|
3074
3074
|
} else return;
|
|
3075
3075
|
const axis = series.axis === "secondary" ? spec.yAxis2 : spec.yAxis;
|
|
3076
3076
|
const x = _optionalChain([series, 'access', _77 => _77.x, 'optionalAccess', _78 => _78[readout.index]]);
|
|
3077
|
-
const text = x !== null && x !== void 0 &&
|
|
3077
|
+
const text = x !== null && x !== void 0 && _chunk3R5P3DVYcjs.chartFamily.call(void 0, spec) === "xy" ? `${formatChartNumber(x, spec.xAxis.format)}, ${formatChartNumber(value, axis.format)}` : `${_nullishCoalesce(spec.categories[readout.index], () => ( ""))}: ${formatChartNumber(value, _nullishCoalesce(series.format, () => ( axis.format)))}`;
|
|
3078
3078
|
const w = measure(text, fs, 600) + 10;
|
|
3079
3079
|
const h = fs + 8;
|
|
3080
3080
|
const bx = Math.max(plot.x, Math.min(plot.x + plot.width - w, ax - w / 2));
|
|
@@ -26,8 +26,15 @@ var _chunkPQ3H2AANcjs = require('./chunk-PQ3H2AAN.cjs');
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
|
+
|
|
29
30
|
var _chunk474IQG74cjs = require('./chunk-474IQG74.cjs');
|
|
30
31
|
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
var _chunk7AHBW2CQcjs = require('./chunk-7AHBW2CQ.cjs');
|
|
37
|
+
|
|
31
38
|
// src/paint-editor/effect-paint.ts
|
|
32
39
|
function effectPaintKey(p) {
|
|
33
40
|
return JSON.stringify({ type: "effect", effect: p.effect, provider: p.provider, values: p.values, time: p.time });
|
|
@@ -610,12 +617,23 @@ function drawSticker(medium, s) {
|
|
|
610
617
|
}
|
|
611
618
|
function jitterColor(hex, amount, seed, i) {
|
|
612
619
|
const [r, g, b] = hexRgb(hex);
|
|
613
|
-
const
|
|
614
|
-
const
|
|
615
|
-
const
|
|
616
|
-
const
|
|
617
|
-
const
|
|
618
|
-
|
|
620
|
+
const lch = _chunk7AHBW2CQcjs.oklabToOklch.call(void 0, _chunk7AHBW2CQcjs.rgbToOklab.call(void 0, { r, g, b, a: 1 }));
|
|
621
|
+
const l = Math.min(1, Math.max(0, lch.l + (_chunkPQ3H2AANcjs.rand01.call(void 0, seed, i, 61) - 0.5) * amount * 0.3));
|
|
622
|
+
const h = lch.h + (_chunkPQ3H2AANcjs.rand01.call(void 0, seed, i, 63) - 0.5) * amount * 80;
|
|
623
|
+
const at = (c) => _chunk7AHBW2CQcjs.oklabToRgb.call(void 0, _chunk7AHBW2CQcjs.oklchToOklab.call(void 0, { l, c, h, alpha: 1 }));
|
|
624
|
+
const inGamut = (o) => [o.r, o.g, o.b].every((v) => v >= -1e-4 && v <= 1 + 1e-4);
|
|
625
|
+
let out = at(lch.c);
|
|
626
|
+
if (!inGamut(out)) {
|
|
627
|
+
let lo = 0;
|
|
628
|
+
let hi = lch.c;
|
|
629
|
+
for (let k = 0; k < 12; k++) {
|
|
630
|
+
const mid = (lo + hi) / 2;
|
|
631
|
+
if (inGamut(at(mid))) lo = mid;
|
|
632
|
+
else hi = mid;
|
|
633
|
+
}
|
|
634
|
+
out = at(lo);
|
|
635
|
+
}
|
|
636
|
+
return "#" + [out.r, out.g, out.b].map((c) => Math.round(Math.min(1, Math.max(0, c)) * 255).toString(16).padStart(2, "0")).join("");
|
|
619
637
|
}
|
|
620
638
|
var StickerSpray = (_class4 = class {
|
|
621
639
|
constructor(init) {;_class4.prototype.__init18.call(this);_class4.prototype.__init19.call(this);_class4.prototype.__init20.call(this);_class4.prototype.__init21.call(this);
|
|
@@ -731,8 +749,10 @@ function normalizeStickerUpdate(u) {
|
|
|
731
749
|
}
|
|
732
750
|
return out;
|
|
733
751
|
}
|
|
734
|
-
function stickerSurface(stickers) {
|
|
752
|
+
function stickerSurface(stickers, base, dirty) {
|
|
753
|
+
const only = base && dirty ? new Set(dirty.flatMap((r) => _chunk474IQG74cjs.tilesInRect.call(void 0, r).map(({ tx, ty }) => _chunk474IQG74cjs.tileKey.call(void 0, tx, ty)))) : null;
|
|
735
754
|
const live = /* @__PURE__ */ new Map();
|
|
755
|
+
let scratch = null;
|
|
736
756
|
const target = {
|
|
737
757
|
offset: { x: 0, y: 0 },
|
|
738
758
|
lockTransparency: false,
|
|
@@ -740,19 +760,38 @@ function stickerSurface(stickers) {
|
|
|
740
760
|
readTile: (tx, ty) => _nullishCoalesce(live.get(_chunk474IQG74cjs.tileKey.call(void 0, tx, ty)), () => ( null)),
|
|
741
761
|
writeTile: (tx, ty) => {
|
|
742
762
|
const k = _chunk474IQG74cjs.tileKey.call(void 0, tx, ty);
|
|
763
|
+
if (only && !only.has(k)) return (scratch ??= new Uint8ClampedArray(_chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE * 4)).fill(0);
|
|
743
764
|
let t = live.get(k);
|
|
744
765
|
if (!t) live.set(k, t = new Uint8ClampedArray(_chunk474IQG74cjs.TILE * _chunk474IQG74cjs.TILE * 4));
|
|
745
766
|
return t;
|
|
746
767
|
}
|
|
747
768
|
};
|
|
748
|
-
|
|
769
|
+
const reaches = (s) => !only || _chunk474IQG74cjs.tilesInRect.call(void 0, stickerRect(s)).some(({ tx, ty }) => only.has(_chunk474IQG74cjs.tileKey.call(void 0, tx, ty)));
|
|
770
|
+
renderStickers(stickers.filter(reaches), target);
|
|
749
771
|
const tiles = /* @__PURE__ */ new Map();
|
|
772
|
+
if (only && base) {
|
|
773
|
+
for (const [k, t] of base.tiles) if (!only.has(k)) tiles.set(k, t);
|
|
774
|
+
}
|
|
750
775
|
for (const [k, d] of live) {
|
|
751
776
|
const t = _chunk474IQG74cjs.finishTile.call(void 0, d, 4, 0);
|
|
752
777
|
if (t) tiles.set(k, t);
|
|
753
778
|
}
|
|
754
779
|
return new (0, _chunk474IQG74cjs.TiledSurface)(4, tiles, 0);
|
|
755
780
|
}
|
|
781
|
+
function stickerAt(stickers, x, y) {
|
|
782
|
+
for (let i = stickers.length - 1; i >= 0; i--) {
|
|
783
|
+
const s = stickers[i];
|
|
784
|
+
const rad = s.size / 2;
|
|
785
|
+
const a = s.rotation * Math.PI / 180;
|
|
786
|
+
const dx = x - s.x;
|
|
787
|
+
const dy = y - s.y;
|
|
788
|
+
const u = (dx * Math.cos(a) + dy * Math.sin(a)) / rad;
|
|
789
|
+
const v = (-dx * Math.sin(a) + dy * Math.cos(a)) / rad;
|
|
790
|
+
if (Math.abs(u) > 1.05 || Math.abs(v) > 1.05) continue;
|
|
791
|
+
if (s.size < 16 || stampCoverage(s.stamp, u, v, s.seed) > 0.25) return s;
|
|
792
|
+
}
|
|
793
|
+
return null;
|
|
794
|
+
}
|
|
756
795
|
|
|
757
796
|
// src/paint-editor/procedural.ts
|
|
758
797
|
var STEP_PX = 1.5;
|
|
@@ -1917,4 +1956,5 @@ function parseBrushLibrary(raw, problems = []) {
|
|
|
1917
1956
|
|
|
1918
1957
|
|
|
1919
1958
|
|
|
1920
|
-
|
|
1959
|
+
|
|
1960
|
+
exports.effectPaintKey = effectPaintKey; exports.isPaintEffectPaint = isPaintEffectPaint; exports.readPaintEffectPaint = readPaintEffectPaint; exports.sampleEffectField = sampleEffectField; exports.sampleEffectAt = sampleEffectAt; exports.PAPER_FAMILIES = PAPER_FAMILIES; exports.PAPER_LIBRARY = PAPER_LIBRARY; exports.DEFAULT_PAPER = DEFAULT_PAPER; exports.paperPreset = paperPreset; exports.clonePaper = clonePaper; exports.normalizePaper = normalizePaper; exports.hexToRgb8 = hexToRgb8; exports.renderPaper = renderPaper; exports.penOrientation = penOrientation; exports.tiltToOrientation = tiltToOrientation; exports.PenSmoother = PenSmoother; exports.IDENTITY_COPY = IDENTITY_COPY; exports.PenDabWalker = PenDabWalker; exports.DryStroke = DryStroke; exports.mixerTip = mixerTip; exports.toStrokePoint = toStrokePoint; exports.STAMP_KINDS = STAMP_KINDS; exports.DEFAULT_STICKER = DEFAULT_STICKER; exports.normalizeStickerSettings = normalizeStickerSettings; exports.stampCoverage = stampCoverage; exports.stickerRect = stickerRect; exports.drawSticker = drawSticker; exports.StickerSpray = StickerSpray; exports.renderStickers = renderStickers; exports.normalizeStickerUpdate = normalizeStickerUpdate; exports.stickerSurface = stickerSurface; exports.stickerAt = stickerAt; exports.PARTICLE_KINDS = PARTICLE_KINDS; exports.PARTICLE_RENDERS = PARTICLE_RENDERS; exports.DEFAULT_PARTICLE = DEFAULT_PARTICLE; exports.normalizeParticle = normalizeParticle; exports.ParticleStroke = ParticleStroke; exports.DEFAULT_BRISTLE = DEFAULT_BRISTLE; exports.normalizeBristle = normalizeBristle; exports.BristleStroke = BristleStroke; exports.PAINT_BRUSH_ENGINES = PAINT_BRUSH_ENGINES; exports.PAINT_BRUSH_CATEGORIES = PAINT_BRUSH_CATEGORIES; exports.WET_TOOLS = WET_TOOLS; exports.WET_MEDIA = WET_MEDIA; exports.DEFAULT_WET_BRUSH = DEFAULT_WET_BRUSH; exports.normalizeWetBrush = normalizeWetBrush; exports.IMPASTO_TOOLS = IMPASTO_TOOLS; exports.DEFAULT_IMPASTO = DEFAULT_IMPASTO; exports.normalizeImpasto = normalizeImpasto; exports.MULTI_COLOR_MODES = MULTI_COLOR_MODES; exports.DEFAULT_MULTI_COLOR = DEFAULT_MULTI_COLOR; exports.DEFAULT_BEHAVIOR = DEFAULT_BEHAVIOR; exports.BRUSH_ROTATIONS = BRUSH_ROTATIONS; exports.DEFAULT_DYNAMICS = DEFAULT_DYNAMICS; exports.normalizeDynamics = normalizeDynamics; exports.BRUSH_ID = BRUSH_ID; exports.normalizeMultiColor = normalizeMultiColor; exports.normalizeBehavior = normalizeBehavior; exports.isWetCapable = isWetCapable; exports.isWetBrush = isWetBrush; exports.usesPaintExchange = usesPaintExchange; exports.brushTakesPaint = brushTakesPaint; exports.paintToMultiColor = paintToMultiColor; exports.multiColorToPaint = multiColorToPaint; exports.normalizePaintBrush = normalizePaintBrush; exports.BUILTIN_BRUSHES = BUILTIN_BRUSHES; exports.DEFAULT_BRUSH_ID = DEFAULT_BRUSH_ID; exports.brushToJSON = brushToJSON; exports.parseBrushLibrary = parseBrushLibrary;
|
|
@@ -25,8 +25,15 @@ import {
|
|
|
25
25
|
TILE,
|
|
26
26
|
TiledSurface,
|
|
27
27
|
finishTile,
|
|
28
|
-
tileKey
|
|
28
|
+
tileKey,
|
|
29
|
+
tilesInRect
|
|
29
30
|
} from "./chunk-HVVR5PZW.js";
|
|
31
|
+
import {
|
|
32
|
+
oklabToOklch,
|
|
33
|
+
oklabToRgb,
|
|
34
|
+
oklchToOklab,
|
|
35
|
+
rgbToOklab
|
|
36
|
+
} from "./chunk-F67XMVDI.js";
|
|
30
37
|
|
|
31
38
|
// src/paint-editor/effect-paint.ts
|
|
32
39
|
function effectPaintKey(p) {
|
|
@@ -610,12 +617,23 @@ function drawSticker(medium, s) {
|
|
|
610
617
|
}
|
|
611
618
|
function jitterColor(hex, amount, seed, i) {
|
|
612
619
|
const [r, g, b] = hexRgb(hex);
|
|
613
|
-
const
|
|
614
|
-
const
|
|
615
|
-
const
|
|
616
|
-
const
|
|
617
|
-
const
|
|
618
|
-
|
|
620
|
+
const lch = oklabToOklch(rgbToOklab({ r, g, b, a: 1 }));
|
|
621
|
+
const l = Math.min(1, Math.max(0, lch.l + (rand01(seed, i, 61) - 0.5) * amount * 0.3));
|
|
622
|
+
const h = lch.h + (rand01(seed, i, 63) - 0.5) * amount * 80;
|
|
623
|
+
const at = (c) => oklabToRgb(oklchToOklab({ l, c, h, alpha: 1 }));
|
|
624
|
+
const inGamut = (o) => [o.r, o.g, o.b].every((v) => v >= -1e-4 && v <= 1 + 1e-4);
|
|
625
|
+
let out = at(lch.c);
|
|
626
|
+
if (!inGamut(out)) {
|
|
627
|
+
let lo = 0;
|
|
628
|
+
let hi = lch.c;
|
|
629
|
+
for (let k = 0; k < 12; k++) {
|
|
630
|
+
const mid = (lo + hi) / 2;
|
|
631
|
+
if (inGamut(at(mid))) lo = mid;
|
|
632
|
+
else hi = mid;
|
|
633
|
+
}
|
|
634
|
+
out = at(lo);
|
|
635
|
+
}
|
|
636
|
+
return "#" + [out.r, out.g, out.b].map((c) => Math.round(Math.min(1, Math.max(0, c)) * 255).toString(16).padStart(2, "0")).join("");
|
|
619
637
|
}
|
|
620
638
|
var StickerSpray = class {
|
|
621
639
|
constructor(init) {
|
|
@@ -731,8 +749,10 @@ function normalizeStickerUpdate(u) {
|
|
|
731
749
|
}
|
|
732
750
|
return out;
|
|
733
751
|
}
|
|
734
|
-
function stickerSurface(stickers) {
|
|
752
|
+
function stickerSurface(stickers, base, dirty) {
|
|
753
|
+
const only = base && dirty ? new Set(dirty.flatMap((r) => tilesInRect(r).map(({ tx, ty }) => tileKey(tx, ty)))) : null;
|
|
735
754
|
const live = /* @__PURE__ */ new Map();
|
|
755
|
+
let scratch = null;
|
|
736
756
|
const target = {
|
|
737
757
|
offset: { x: 0, y: 0 },
|
|
738
758
|
lockTransparency: false,
|
|
@@ -740,19 +760,38 @@ function stickerSurface(stickers) {
|
|
|
740
760
|
readTile: (tx, ty) => live.get(tileKey(tx, ty)) ?? null,
|
|
741
761
|
writeTile: (tx, ty) => {
|
|
742
762
|
const k = tileKey(tx, ty);
|
|
763
|
+
if (only && !only.has(k)) return (scratch ??= new Uint8ClampedArray(TILE * TILE * 4)).fill(0);
|
|
743
764
|
let t = live.get(k);
|
|
744
765
|
if (!t) live.set(k, t = new Uint8ClampedArray(TILE * TILE * 4));
|
|
745
766
|
return t;
|
|
746
767
|
}
|
|
747
768
|
};
|
|
748
|
-
|
|
769
|
+
const reaches = (s) => !only || tilesInRect(stickerRect(s)).some(({ tx, ty }) => only.has(tileKey(tx, ty)));
|
|
770
|
+
renderStickers(stickers.filter(reaches), target);
|
|
749
771
|
const tiles = /* @__PURE__ */ new Map();
|
|
772
|
+
if (only && base) {
|
|
773
|
+
for (const [k, t] of base.tiles) if (!only.has(k)) tiles.set(k, t);
|
|
774
|
+
}
|
|
750
775
|
for (const [k, d] of live) {
|
|
751
776
|
const t = finishTile(d, 4, 0);
|
|
752
777
|
if (t) tiles.set(k, t);
|
|
753
778
|
}
|
|
754
779
|
return new TiledSurface(4, tiles, 0);
|
|
755
780
|
}
|
|
781
|
+
function stickerAt(stickers, x, y) {
|
|
782
|
+
for (let i = stickers.length - 1; i >= 0; i--) {
|
|
783
|
+
const s = stickers[i];
|
|
784
|
+
const rad = s.size / 2;
|
|
785
|
+
const a = s.rotation * Math.PI / 180;
|
|
786
|
+
const dx = x - s.x;
|
|
787
|
+
const dy = y - s.y;
|
|
788
|
+
const u = (dx * Math.cos(a) + dy * Math.sin(a)) / rad;
|
|
789
|
+
const v = (-dx * Math.sin(a) + dy * Math.cos(a)) / rad;
|
|
790
|
+
if (Math.abs(u) > 1.05 || Math.abs(v) > 1.05) continue;
|
|
791
|
+
if (s.size < 16 || stampCoverage(s.stamp, u, v, s.seed) > 0.25) return s;
|
|
792
|
+
}
|
|
793
|
+
return null;
|
|
794
|
+
}
|
|
756
795
|
|
|
757
796
|
// src/paint-editor/procedural.ts
|
|
758
797
|
var STEP_PX = 1.5;
|
|
@@ -1880,6 +1919,7 @@ export {
|
|
|
1880
1919
|
renderStickers,
|
|
1881
1920
|
normalizeStickerUpdate,
|
|
1882
1921
|
stickerSurface,
|
|
1922
|
+
stickerAt,
|
|
1883
1923
|
PARTICLE_KINDS,
|
|
1884
1924
|
PARTICLE_RENDERS,
|
|
1885
1925
|
DEFAULT_PARTICLE,
|
|
@@ -74,7 +74,7 @@ function profileAlongPolyline(points, values, count = 32) {
|
|
|
74
74
|
var round3 = (v) => Math.round(v * 1e3) / 1e3;
|
|
75
75
|
var loading = null;
|
|
76
76
|
function loadCanvasBrushstrokeRenderer() {
|
|
77
|
-
loading ??= Promise.resolve().then(() => _interopRequireWildcard(require("./brushstrokeRender-
|
|
77
|
+
loading ??= Promise.resolve().then(() => _interopRequireWildcard(require("./brushstrokeRender-MPOM7BFW.cjs"))).catch((error) => {
|
|
78
78
|
loading = null;
|
|
79
79
|
throw error;
|
|
80
80
|
});
|