@pixerate/editor 0.207.0 → 0.209.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/animation-editor/index.cjs +60 -59
- package/dist/animation-editor/index.js +6 -5
- package/dist/{brushstrokeRender-7LXCU7PD.js → brushstrokeRender-C3UU6GVC.js} +5 -4
- package/dist/{brushstrokeRender-VO4ZTWVA.cjs → brushstrokeRender-EAJNE6WP.cjs} +12 -11
- package/dist/canvas/index.cjs +8 -8
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-2N2QPO3H.js → chunk-2PBZBRP5.js} +9 -7
- package/dist/{chunk-7NW46N7I.cjs → chunk-3EHPLDFQ.cjs} +54 -52
- package/dist/{chunk-H367YTXI.js → chunk-42TWUPNJ.js} +13 -387
- package/dist/chunk-474IQG74.cjs +384 -0
- package/dist/{chunk-MLC7HUHO.js → chunk-BGOCAUXH.js} +1 -1
- package/dist/chunk-DWYQPL2A.js +2010 -0
- package/dist/{chunk-YXKLVD56.js → chunk-F7YA3MMC.js} +2 -2
- package/dist/{chunk-ZZGPYNS2.js → chunk-G4E6RUPC.js} +1 -1
- package/dist/chunk-HVVR5PZW.js +384 -0
- package/dist/{chunk-FR2Q2LVF.cjs → chunk-I7G3RSUJ.cjs} +35 -35
- package/dist/chunk-K6PXS6DO.cjs +102 -0
- package/dist/{chunk-ZIDUPSP4.js → chunk-KFIOEOCQ.js} +24 -761
- package/dist/{chunk-V7GWZIZK.cjs → chunk-KWNMBMKG.cjs} +23 -21
- package/dist/chunk-L3G23N5Y.js +763 -0
- package/dist/{chunk-GHCXLQ47.js → chunk-NDMXB4PR.js} +2 -2
- package/dist/{chunk-CWM3CUUX.cjs → chunk-OLNIPTB3.cjs} +39 -413
- package/dist/{chunk-EBDCRTZI.cjs → chunk-PQ3H2AAN.cjs} +92 -90
- package/dist/{chunk-BRKVNXDZ.cjs → chunk-QAUIZPYI.cjs} +7 -7
- package/dist/{chunk-UYXL6ZWQ.cjs → chunk-QE7D7TZR.cjs} +494 -1231
- package/dist/chunk-QYLWG22N.cjs +763 -0
- package/dist/{chunk-YQ5C5BVK.cjs → chunk-ROVK6AXX.cjs} +60 -60
- package/dist/{chunk-HGTDMKNE.cjs → chunk-UOGKSVRQ.cjs} +126 -221
- package/dist/{chunk-EL5PAHNP.js → chunk-USQCKRZG.js} +6 -4
- package/dist/{chunk-36OKQDCF.js → chunk-WJ2RBZMM.js} +5 -3
- package/dist/chunk-X4LUGTQX.cjs +2010 -0
- package/dist/{chunk-NQMP3CWF.js → chunk-YBJXCQTR.js} +15 -110
- package/dist/chunk-ZIF4UJJ6.js +102 -0
- package/dist/{chunk-WTW7QRTS.cjs → chunk-ZMHPQ6HP.cjs} +1 -1
- package/dist/image-editor/controller.d.cts +53 -5
- package/dist/image-editor/controller.d.ts +53 -5
- package/dist/image-editor/index.cjs +1806 -3356
- package/dist/image-editor/index.js +462 -2012
- package/dist/image-editor/selection/index.d.cts +1 -0
- package/dist/image-editor/selection/index.d.ts +1 -0
- package/dist/image-editor/selection/segment/focus.d.cts +2 -0
- package/dist/image-editor/selection/segment/focus.d.ts +2 -0
- package/dist/image-editor/selection/segment/grabcut.d.cts +4 -2
- package/dist/image-editor/selection/segment/grabcut.d.ts +4 -2
- package/dist/image-editor/selection/segment/sky.d.cts +2 -0
- package/dist/image-editor/selection/segment/sky.d.ts +2 -0
- package/dist/image-editor/selection/segment/subject.d.cts +2 -1
- package/dist/image-editor/selection/segment/subject.d.ts +2 -1
- package/dist/image-editor/selection/segment/work.d.cts +5 -0
- package/dist/image-editor/selection/segment/work.d.ts +5 -0
- package/dist/image-editor/selection/select-and-mask.d.cts +12 -2
- package/dist/image-editor/selection/select-and-mask.d.ts +12 -2
- package/dist/image-editor/selection/tool-options.d.cts +3 -1
- package/dist/image-editor/selection/tool-options.d.ts +3 -1
- package/dist/image-editor/selection/worker.d.cts +126 -0
- package/dist/image-editor/selection/worker.d.ts +126 -0
- package/dist/image-editor/selection-worker.cjs +14 -0
- package/dist/image-editor/selection-worker.d.cts +12 -0
- package/dist/image-editor/selection-worker.d.ts +12 -0
- package/dist/image-editor/selection-worker.js +14 -0
- package/dist/image-editor/types.d.cts +22 -0
- package/dist/image-editor/types.d.ts +22 -0
- package/dist/paint/index.cjs +6 -5
- package/dist/paint/index.js +5 -4
- package/dist/paint-editor/index.cjs +394 -390
- package/dist/paint-editor/index.js +18 -14
- package/dist/raster/index.cjs +22 -18
- package/dist/raster/index.js +29 -25
- package/dist/vector/index.cjs +986 -985
- package/dist/vector/index.js +6 -5
- package/package.json +11 -1
- package/skills/pixerate-image-editor/SKILL.md +1 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/raster/blur.ts
|
|
2
|
+
function gaussianKernel(sigma) {
|
|
3
|
+
const r = Math.ceil(sigma * 3);
|
|
4
|
+
const k = new Float32Array(2 * r + 1);
|
|
5
|
+
let s = 0;
|
|
6
|
+
for (let i = -r; i <= r; i++) {
|
|
7
|
+
const v = Math.exp(-(i * i) / (2 * sigma * sigma));
|
|
8
|
+
k[i + r] = v;
|
|
9
|
+
s += v;
|
|
10
|
+
}
|
|
11
|
+
for (let i = 0; i < k.length; i++) k[i] /= s;
|
|
12
|
+
return k;
|
|
13
|
+
}
|
|
14
|
+
var DIRECT_GAUSSIAN_MAX_SIGMA = 8;
|
|
15
|
+
function boxRadii(sigma) {
|
|
16
|
+
const n = 3;
|
|
17
|
+
const wIdeal = Math.sqrt(12 * sigma * sigma / n + 1);
|
|
18
|
+
let wl = Math.floor(wIdeal);
|
|
19
|
+
if (wl % 2 === 0) wl--;
|
|
20
|
+
const wu = wl + 2;
|
|
21
|
+
const mIdeal = (12 * sigma * sigma - n * wl * wl - 4 * n * wl - 3 * n) / (-4 * wl - 4);
|
|
22
|
+
const m = Math.round(mIdeal);
|
|
23
|
+
const sizes = [0, 1, 2].map((i) => i < m ? wl : wu);
|
|
24
|
+
return sizes.map((s) => (s - 1) / 2);
|
|
25
|
+
}
|
|
26
|
+
function convolveLine(src, off, stride, len, k, edge, dst) {
|
|
27
|
+
const r = (k.length - 1) / 2;
|
|
28
|
+
for (let i = 0; i < len; i++) {
|
|
29
|
+
let a = 0;
|
|
30
|
+
const lo = i - r;
|
|
31
|
+
for (let j = 0; j < k.length; j++) {
|
|
32
|
+
let x = lo + j;
|
|
33
|
+
if (x < 0 || x >= len) {
|
|
34
|
+
if (edge === "zero") continue;
|
|
35
|
+
x = x < 0 ? 0 : len - 1;
|
|
36
|
+
}
|
|
37
|
+
a += src[off + x * stride] * k[j];
|
|
38
|
+
}
|
|
39
|
+
dst[i] = a;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function boxesLine(src, off, stride, len, radii, edge, a, b, dst) {
|
|
43
|
+
const pad = radii.reduce((s, r) => s + r, 0);
|
|
44
|
+
const plen = len + 2 * pad;
|
|
45
|
+
for (let i = 0; i < plen; i++) {
|
|
46
|
+
const j = i - pad;
|
|
47
|
+
a[i] = j < 0 ? edge === "zero" ? 0 : src[off] : j >= len ? edge === "zero" ? 0 : src[off + (len - 1) * stride] : src[off + j * stride];
|
|
48
|
+
}
|
|
49
|
+
let from = a;
|
|
50
|
+
let to = b;
|
|
51
|
+
for (const r of radii) {
|
|
52
|
+
let sum = 0;
|
|
53
|
+
for (let i = 0; i <= Math.min(r, plen - 1); i++) sum += from[i];
|
|
54
|
+
const k = 2 * r + 1;
|
|
55
|
+
for (let i = 0; i < plen; i++) {
|
|
56
|
+
to[i] = sum / k;
|
|
57
|
+
const add = i + r + 1;
|
|
58
|
+
const drop = i - r;
|
|
59
|
+
if (add < plen) sum += from[add];
|
|
60
|
+
if (drop >= 0) sum -= from[drop];
|
|
61
|
+
}
|
|
62
|
+
const t = from;
|
|
63
|
+
from = to;
|
|
64
|
+
to = t;
|
|
65
|
+
}
|
|
66
|
+
for (let i = 0; i < len; i++) dst[i] = from[i + pad];
|
|
67
|
+
}
|
|
68
|
+
function gaussianBlur(src, w, h, sigma, edge = "zero") {
|
|
69
|
+
const out = Float32Array.from(src);
|
|
70
|
+
if (!(sigma >= 0.1) || w <= 0 || h <= 0) return out;
|
|
71
|
+
const s = Math.min(sigma, 4 * Math.max(w, h));
|
|
72
|
+
const line = new Float32Array(Math.max(w, h));
|
|
73
|
+
const passes = [];
|
|
74
|
+
if (s <= DIRECT_GAUSSIAN_MAX_SIGMA) {
|
|
75
|
+
const k = gaussianKernel(s);
|
|
76
|
+
passes.push((buf, off, stride, len) => convolveLine(buf, off, stride, len, k, edge, line));
|
|
77
|
+
} else {
|
|
78
|
+
const radii = boxRadii(s);
|
|
79
|
+
const plen = Math.max(w, h) + 2 * radii.reduce((a2, r) => a2 + r, 0);
|
|
80
|
+
const a = new Float32Array(plen);
|
|
81
|
+
const b = new Float32Array(plen);
|
|
82
|
+
passes.push((buf, off, stride, len) => boxesLine(buf, off, stride, len, radii, edge, a, b, line));
|
|
83
|
+
}
|
|
84
|
+
for (const pass of passes) {
|
|
85
|
+
for (let y = 0; y < h; y++) {
|
|
86
|
+
pass(out, y * w, 1, w);
|
|
87
|
+
out.set(line.subarray(0, w), y * w);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const pass of passes) {
|
|
91
|
+
for (let x = 0; x < w; x++) {
|
|
92
|
+
pass(out, x, w, h);
|
|
93
|
+
for (let y = 0; y < h; y++) out[y * w + x] = line[y];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
exports.DIRECT_GAUSSIAN_MAX_SIGMA = DIRECT_GAUSSIAN_MAX_SIGMA; exports.gaussianBlur = gaussianBlur;
|