@field/cascade 0.11.0 → 0.13.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/AGENTS.md +8 -5
- package/ARCHITECTURE.md +5 -4
- package/CHANGELOG.md +245 -0
- package/README.md +1 -1
- package/dist/assets/AgentPanel-1JugFjE4.css +1 -0
- package/dist/assets/AgentPanel-BDL5MddA.js +5 -0
- package/dist/assets/{CodeEditor-4O7FQ__R.js → CodeEditor-C-xYG-Wn.js} +120 -120
- package/dist/assets/CodePanel-CtXd50m6.js +2 -0
- package/dist/assets/CookInfoPanel-B3NMhKJF.css +1 -0
- package/dist/assets/CookInfoPanel-DG4_TRsX.js +2 -0
- package/dist/assets/CustomNodeDialog-CHfZUs-r.js +1 -0
- package/dist/assets/DefinitionNode-CaRTXQ_b.js +1 -0
- package/dist/assets/DefinitionPanel-C3CxZY9r.js +1 -0
- package/dist/assets/DefinitionPanel-VNLnAiQD.css +1 -0
- package/dist/assets/OpenGraphDialog-BLdr6k_q.js +1 -0
- package/dist/assets/ProjectSettings-ZnvmIAir.js +2 -0
- package/dist/assets/{SettingsDialog-Bz8JxISH.js → SettingsDialog-CBX3Wa87.js} +1 -1
- package/dist/assets/TimelinePanel-CDeR0arY.css +1 -0
- package/dist/assets/TimelinePanel-CWgnFH1e.js +1 -0
- package/dist/assets/{VersionHistoryDialog-D5Z0nJ5-.js → VersionHistoryDialog-BOSoW1R-.js} +1 -1
- package/dist/assets/assert-BO2_erPD.js +1 -0
- package/dist/assets/assert-hvykGCnP.js +1 -0
- package/dist/assets/builder-BmBKcDix.js +1 -0
- package/dist/assets/camera-DFF7YA3F.js +1 -0
- package/dist/assets/checks-DAvyO9Gf.js +1 -0
- package/dist/assets/contactSheet-N1NcaWxw.js +2 -0
- package/dist/assets/{core-Yqi0Ni61.js → core-DB-MkGjj.js} +3 -4
- package/dist/assets/coreTypes-DtnDATZ7.js +1 -0
- package/dist/assets/{cssMode-CxUzc4vp.js → cssMode-DPVckSOc.js} +1 -1
- package/dist/assets/definitions-B227e7f_.js +1 -0
- package/dist/assets/definitions-D0WOUJd7.js +1 -0
- package/dist/assets/{editor.api-BNFb25CX.js → editor.api-Dkutg_Z1.js} +1 -1
- package/dist/assets/expressions-X-Z-GrgW.js +5 -0
- package/dist/assets/file-DAL6IfjV.js +1 -0
- package/dist/assets/filters-D3k1LRMa.js +1 -0
- package/dist/assets/{freemarker2-0ZDnWxeM.js → freemarker2-CLiLKk3B.js} +1 -1
- package/dist/assets/generators-BhDxRAFC.js +1 -0
- package/dist/assets/geo-BsMImJIJ.js +1 -0
- package/dist/assets/geo-C4YngDob.js +2 -0
- package/dist/assets/{handlebars-Cy18MoaD.js → handlebars-CcD3aMeL.js} +1 -1
- package/dist/assets/{html-B-2Dx7nq.js → html-DvZWGfqb.js} +1 -1
- package/dist/assets/{htmlMode-DUAc9B_d.js → htmlMode-DUD3VaoN.js} +1 -1
- package/dist/assets/image-0SfH-snh.js +1 -0
- package/dist/assets/image-Ck-RdGU4.js +2 -0
- package/dist/assets/index-BWnrmIB9.js +137 -0
- package/dist/assets/index-DIaxEONI.css +1 -0
- package/dist/assets/io-BGmt2g0D.js +1 -0
- package/dist/assets/{javascript-DeQsDqP5.js → javascript-Cap2ahgh.js} +1 -1
- package/dist/assets/{jsonMode-BiFwJVSk.js → jsonMode-B0uLjp9C.js} +1 -1
- package/dist/assets/{liquid-BLoHH68a.js → liquid-CnxwhfLn.js} +1 -1
- package/dist/assets/{lspLanguageFeatures-CNFgm1Kv.js → lspLanguageFeatures-Dn9hlKX6.js} +1 -1
- package/dist/assets/math-GeULS-sk.js +1 -0
- package/dist/assets/{mdx-CFXQVNfs.js → mdx-BV3jbrVa.js} +1 -1
- package/dist/assets/pop-KMF_qloi.js +1 -0
- package/dist/assets/preload-helper-Czpn1I53.js +1 -0
- package/dist/assets/{python-Cf7S7p2E.js → python-CGyFk4XK.js} +1 -1
- package/dist/assets/{razor-CMHBcG-g.js → razor-CQfzX3-N.js} +1 -1
- package/dist/assets/remap-5SjXQU-q.js +1 -0
- package/dist/assets/renderMarkdown-ork0Oir7.js +67 -0
- package/dist/assets/studioImages-CAyH-0Pl.js +1 -0
- package/dist/assets/text-ZpX7qNkx.js +2 -0
- package/dist/assets/time-P_OiBhcf.js +1 -0
- package/dist/assets/{tsMode-BEih0GDj.js → tsMode-BOeXzO9H.js} +1 -1
- package/dist/assets/{typescript-COEKYD_a.js → typescript-J1SnE_Tu.js} +1 -1
- package/dist/assets/{workers-BNhAhMNn.js → workers-CYwwTiVF.js} +1 -1
- package/dist/assets/{xml-CPiMpnPl.js → xml-DnPRNzK9.js} +1 -1
- package/dist/assets/{yaml-Bgp1ITLR.js → yaml-BmmYBNa9.js} +1 -1
- package/dist/cli/DefinitionNode-P7AA4TAU.js +15 -0
- package/dist/cli/{Graph-ZJJTRQTM.js → Graph-OB6EWSGL.js} +12 -12
- package/dist/cli/assert-GROGQNCQ.js +25 -0
- package/dist/cli/checks-3WB44XBL.js +189 -0
- package/dist/cli/{chunk-3JTJHF7V.js → chunk-2L34ERS2.js} +4 -4
- package/dist/cli/chunk-53LGFPWX.js +138 -0
- package/dist/cli/chunk-5ORUQ6ES.js +267 -0
- package/dist/cli/{chunk-YAT5Y25U.js → chunk-7QE2ZNSN.js} +3 -3
- package/dist/cli/{chunk-SGJAET2L.js → chunk-BPODRH52.js} +8 -4
- package/dist/cli/{chunk-XWDSKG7N.js → chunk-BZ63XQ3I.js} +2 -2
- package/dist/cli/{chunk-FCDXJ6EK.js → chunk-CTPLRSWF.js} +2 -13
- package/dist/cli/{chunk-WIH4TEIS.js → chunk-EZRWJ4G2.js} +1 -1
- package/dist/cli/{chunk-BIJO5OFS.js → chunk-FWMSGKEH.js} +1 -1
- package/dist/cli/{chunk-POMMNKZZ.js → chunk-G23A2BZZ.js} +38 -5
- package/dist/cli/{chunk-35D343DC.js → chunk-GRIN2DDP.js} +19 -1
- package/dist/cli/{chunk-WKURDVYP.js → chunk-JEW5MPGI.js} +28 -331
- package/dist/cli/chunk-JVOCK5W4.js +83 -0
- package/dist/cli/chunk-KBGUO27Q.js +15 -0
- package/dist/cli/{chunk-GFS6W3C5.js → chunk-L6B6FUQP.js} +54 -32
- package/dist/cli/chunk-LTXWBXOM.js +438 -0
- package/dist/cli/chunk-MI5JLQYA.js +220 -0
- package/dist/cli/{chunk-A4OAMOZH.js → chunk-NJFMDXHR.js} +13 -3
- package/dist/cli/{chunk-DUIUFVU2.js → chunk-OBZAP3GG.js} +49 -23
- package/dist/cli/chunk-QAGATJGE.js +336 -0
- package/dist/cli/{chunk-EUIAC3U3.js → chunk-QKL7CCRS.js} +966 -132
- package/dist/cli/{chunk-RLCAJBVR.js → chunk-TJW67QSI.js} +8 -7
- package/dist/cli/{chunk-RQZ4SX5R.js → chunk-W5PJ5RMP.js} +156 -84
- package/dist/cli/chunk-W7OUAT7J.js +122 -0
- package/dist/cli/chunk-WGKPJZDY.js +364 -0
- package/dist/cli/{chunk-D6BUOHUG.js → chunk-X4WKAOQP.js} +4 -4
- package/dist/cli/{chunk-VVGSLVSF.js → chunk-X566FWBV.js} +6 -1
- package/dist/cli/chunk-YH637PDL.js +317 -0
- package/dist/cli/chunk-ZSCUZE6I.js +112 -0
- package/dist/cli/{cliCommands-UQSFGEHF.js → cliCommands-XVFRD7CF.js} +23 -17
- package/dist/cli/{commands-Q23M26QM.js → commands-M2XLTPTZ.js} +129 -47
- package/dist/cli/contactSheet-2PQVRUFW.js +11 -0
- package/dist/cli/{definitions-HF2FTHYU.js → definitions-BPOPW52L.js} +7 -7
- package/dist/cli/{doctorCommand-B7BPQMN6.js → doctorCommand-RAEI7GVY.js} +36 -6
- package/dist/cli/{edit-JHCPTQFT.js → edit-S5KEQ5RA.js} +3 -3
- package/dist/cli/editorCommands-5BBG4S6V.js +41 -0
- package/dist/cli/{encode-HAUZTYPT.js → encode-ICPEPMH5.js} +2 -2
- package/dist/cli/file-3HTQHPYQ.js +41 -0
- package/dist/cli/filters-6ODFWYK4.js +379 -0
- package/dist/cli/generators-YU7GB4MD.js +210 -0
- package/dist/cli/{geo-4RNK3QVN.js → geo-6ZPGKZRU.js} +7 -7
- package/dist/cli/{graphCommands-6BMAKGQE.js → graphCommands-MULQ7VD2.js} +4 -4
- package/dist/cli/{graphFile-VPSQ6OF7.js → graphFile-CITF36ZM.js} +25 -19
- package/dist/cli/{headlessCanvas-5XLDZT7M.js → headlessCanvas-ENRHC7GS.js} +3 -2
- package/dist/cli/{helpCommand-3VRE3KVO.js → helpCommand-X2QDANM3.js} +9 -7
- package/dist/cli/image-TXELZZK5.js +55 -0
- package/dist/cli/index.js +14 -14
- package/dist/cli/{math-ZRMLKU2D.js → math-RSYRQ3C6.js} +5 -5
- package/dist/cli/{mcp-ZLEEMYGF.js → mcp-YRIGRLYQ.js} +4 -4
- package/dist/cli/{parity-KINARCP2.js → parity-3N3HTKWX.js} +42 -36
- package/dist/cli/{pop-USDFXB7H.js → pop-B7SIIYKN.js} +5 -5
- package/dist/cli/project-SJF5ZF3F.js +12 -0
- package/dist/cli/{projectDefinition-DMTZN2NE.js → projectDefinition-F3D7UIHJ.js} +8 -8
- package/dist/cli/{projectRuntime-Z5PJOH47.js → projectRuntime-NY4XMDFH.js} +19 -12
- package/dist/cli/registerStandardNodes-BXJCB6E4.js +744 -0
- package/dist/cli/{render-YURAPPUI.js → render-Y23W6MY6.js} +29 -22
- package/dist/cli/{runCommand-PI764LEG.js → runCommand-XOG7AVC5.js} +3 -3
- package/dist/cli/runner-DNJO5WO2.js +43 -0
- package/dist/cli/runtime/image.ts +27 -2
- package/dist/cli/runtime/io.ts +78 -0
- package/dist/cli/share-B7HTCOJX.js +166 -0
- package/dist/cli/stageCache-TY2BFZJR.js +15 -0
- package/dist/cli/{stageRunner-KUNIMQKJ.js → stageRunner-KY2EJP7X.js} +2 -2
- package/dist/cli/text-MB3EKR4H.js +126 -0
- package/dist/cli/{verbs-RCE3K4VQ.js → verbs-PI2JH5FI.js} +2 -2
- package/dist/cli/webBuild-2K4COCGY.js +44 -0
- package/dist/contracts/capabilities.d.ts +39 -1
- package/dist/contracts/color.d.ts +8 -0
- package/dist/contracts/color.js +23 -0
- package/dist/contracts/definition.d.ts +10 -0
- package/dist/contracts/schema.d.ts +1 -1
- package/dist/contracts/schema.js +1 -0
- package/dist/contracts/validate.js +11 -1
- package/dist/contracts/values.d.ts +24 -0
- package/dist/image.d.ts +15 -0
- package/dist/image.js +36 -2
- package/dist/index.html +8 -2
- package/dist/io.d.ts +29 -0
- package/dist/io.js +40 -0
- package/dist/player/app.js +11 -7
- package/dist/player/editor.js +3 -2
- package/dist/player/editorEngine.js +3 -2
- package/dist/player/embed.js +2 -0
- package/dist/player/types.d.ts +6 -0
- package/dist/runtime/builtins/assert/checks.d.ts +18 -0
- package/dist/runtime/builtins/assert/checks.js +207 -0
- package/dist/runtime/builtins/assert/definitions.d.ts +130 -0
- package/dist/runtime/builtins/assert/definitions.js +54 -0
- package/dist/runtime/builtins/assert/index.d.ts +152 -0
- package/dist/runtime/builtins/assert/index.js +36 -0
- package/dist/runtime/builtins/image/contactSheet.d.ts +3 -165
- package/dist/runtime/builtins/image/contactSheet.js +0 -49
- package/dist/runtime/builtins/image/definitions.d.ts +950 -0
- package/dist/runtime/builtins/image/definitions.js +343 -0
- package/dist/runtime/builtins/image/file.d.ts +8 -0
- package/dist/runtime/builtins/image/file.js +37 -0
- package/dist/runtime/builtins/image/filters.d.ts +8 -0
- package/dist/runtime/builtins/image/filters.js +394 -0
- package/dist/runtime/builtins/image/generators.d.ts +7 -0
- package/dist/runtime/builtins/image/generators.js +144 -0
- package/dist/runtime/builtins/image/index.d.ts +947 -4
- package/dist/runtime/builtins/image/index.js +41 -6
- package/dist/runtime/builtins/image/io.d.ts +100 -0
- package/dist/runtime/builtins/image/io.js +142 -0
- package/dist/runtime/builtins/image/planar.d.ts +55 -0
- package/dist/runtime/builtins/image/planar.js +274 -0
- package/dist/runtime/builtins/image/simplex.d.ts +22 -0
- package/dist/runtime/builtins/image/simplex.js +92 -0
- package/dist/runtime/builtins/image/text.d.ts +4 -0
- package/dist/runtime/builtins/image/text.js +141 -0
- package/dist/runtime/builtins/index.d.ts +3 -0
- package/dist/runtime/builtins/index.js +7 -0
- package/dist/runtime/definition/architecture.js +89 -0
- package/dist/runtime/gpu.d.ts +25 -0
- package/dist/runtime/gpu.js +40 -0
- package/dist/runtime/runtime.d.ts +2 -0
- package/dist/runtime/runtime.js +268 -44
- package/dist/runtime/types.d.ts +30 -0
- package/doc/CLI_REFERENCE.md +21 -3
- package/doc/EDITOR_EXPORT.md +26 -0
- package/doc/MCP.md +2 -1
- package/doc/NODE_REFERENCE.md +286 -14
- package/doc/PROJECT_AUTHORING.md +158 -4
- package/doc/WEB_PLAYER.md +9 -1
- package/package.json +4 -1
- package/dist/assets/CodePanel-BU-autmq.js +0 -2
- package/dist/assets/CustomNodeDialog-BRpDfOV5.js +0 -1
- package/dist/assets/OpenGraphDialog-BwbRlC0X.js +0 -1
- package/dist/assets/ProjectSettings-DLOXLxcA.js +0 -2
- package/dist/assets/definitions-GreEMXLV.js +0 -1
- package/dist/assets/geo-u0n_jOsD.js +0 -1
- package/dist/assets/image-cAa-Nu9O.js +0 -2062
- package/dist/assets/index-5ZtDAuy2.js +0 -220
- package/dist/assets/index-7vae6YFC.css +0 -1
- package/dist/assets/math-DioIQOPJ.js +0 -1
- package/dist/assets/pop-DC_TQG9t.js +0 -1
- package/dist/cli/chunk-36P5K3SD.js +0 -631
- package/dist/cli/chunk-4UDFYF5G.js +0 -132
- package/dist/cli/chunk-53NMBJAO.js +0 -35
- package/dist/cli/chunk-MIIEFUGG.js +0 -623
- package/dist/cli/chunk-QBBKRNGY.js +0 -90
- package/dist/cli/chunk-WPUDGEFY.js +0 -20
- package/dist/cli/editorCommands-UIF5YLUZ.js +0 -33
- package/dist/cli/project-K3QIPGBB.js +0 -12
- package/dist/cli/registerStandardNodes-S2VLMF6J.js +0 -3081
- package/dist/cli/runner-RA6UKEPD.js +0 -37
- package/dist/cli/webBuild-GT4PZT5D.js +0 -37
- package/dist/runtime/builtins/headless.d.ts +0 -19
- package/dist/runtime/builtins/headless.js +0 -25
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Planar,
|
|
3
|
+
output,
|
|
4
|
+
readPlanar,
|
|
5
|
+
resample,
|
|
6
|
+
resizeToFit,
|
|
7
|
+
resolveOutputSize
|
|
8
|
+
} from "./chunk-WGKPJZDY.js";
|
|
9
|
+
|
|
10
|
+
// packages/runtime/src/builtins/image/filters.ts
|
|
11
|
+
function boxesForGauss(sigma, n) {
|
|
12
|
+
const wIdeal = Math.sqrt(12 * sigma * sigma / n + 1);
|
|
13
|
+
let wl = Math.floor(wIdeal);
|
|
14
|
+
if (wl % 2 === 0) wl--;
|
|
15
|
+
const wu = wl + 2;
|
|
16
|
+
const mIdeal = (12 * sigma * sigma - n * wl * wl - 4 * n * wl - 3 * n) / (-4 * wl - 4);
|
|
17
|
+
const m = Math.round(mIdeal);
|
|
18
|
+
const sizes = [];
|
|
19
|
+
for (let i = 0; i < n; i++) sizes.push(i < m ? wl : wu);
|
|
20
|
+
return sizes.map((s) => (s - 1) / 2);
|
|
21
|
+
}
|
|
22
|
+
function boxBlurPass(data, w, h, r, wrap) {
|
|
23
|
+
if (r < 1) return;
|
|
24
|
+
const temp = new Float32Array(w * h);
|
|
25
|
+
const ri = Math.floor(r);
|
|
26
|
+
const invDiameter = 1 / (ri * 2 + 1);
|
|
27
|
+
for (let y = 0; y < h; y++) {
|
|
28
|
+
const row = y * w;
|
|
29
|
+
let sum = 0;
|
|
30
|
+
for (let i = -ri; i <= ri; i++) {
|
|
31
|
+
const px = wrap ? (i % w + w) % w : Math.max(0, Math.min(w - 1, i));
|
|
32
|
+
sum += data[row + px];
|
|
33
|
+
}
|
|
34
|
+
temp[row] = sum * invDiameter;
|
|
35
|
+
for (let x = 1; x < w; x++) {
|
|
36
|
+
const removeX = wrap ? ((x - ri - 1) % w + w) % w : Math.max(0, x - ri - 1);
|
|
37
|
+
const addX = wrap ? ((x + ri) % w + w) % w : Math.min(w - 1, x + ri);
|
|
38
|
+
sum -= data[row + removeX];
|
|
39
|
+
sum += data[row + addX];
|
|
40
|
+
temp[row + x] = sum * invDiameter;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
for (let x = 0; x < w; x++) {
|
|
44
|
+
let sum = 0;
|
|
45
|
+
for (let i = -ri; i <= ri; i++) {
|
|
46
|
+
const py = wrap ? (i % h + h) % h : Math.max(0, Math.min(h - 1, i));
|
|
47
|
+
sum += temp[py * w + x];
|
|
48
|
+
}
|
|
49
|
+
data[x] = sum * invDiameter;
|
|
50
|
+
for (let y = 1; y < h; y++) {
|
|
51
|
+
const removeY = wrap ? ((y - ri - 1) % h + h) % h : Math.max(0, y - ri - 1);
|
|
52
|
+
const addY = wrap ? ((y + ri) % h + h) % h : Math.min(h - 1, y + ri);
|
|
53
|
+
sum -= temp[removeY * w + x];
|
|
54
|
+
sum += temp[addY * w + x];
|
|
55
|
+
data[y * w + x] = sum * invDiameter;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function boxBlur(source, radius, wrapEdges) {
|
|
60
|
+
if (radius <= 0) return source.clone();
|
|
61
|
+
const boxes = boxesForGauss(radius, 3);
|
|
62
|
+
const result = source.emptyClone();
|
|
63
|
+
for (let c = 0; c < source.channelCount; c++) {
|
|
64
|
+
const channel = new Float32Array(source.channels[c]);
|
|
65
|
+
for (const box of boxes) boxBlurPass(channel, source.width, source.height, box, wrapEdges);
|
|
66
|
+
result.channels[c].set(channel);
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
function gaussianBlur(source, radius, wrapEdges) {
|
|
71
|
+
if (radius <= 0) return source.clone();
|
|
72
|
+
const { width, height } = source;
|
|
73
|
+
const result = source.emptyClone();
|
|
74
|
+
const kernelSize = Math.ceil(radius * 3) * 2 + 1;
|
|
75
|
+
const kernel = new Float32Array(kernelSize);
|
|
76
|
+
const sigma = radius / 3;
|
|
77
|
+
const twoSigmaSq = 2 * sigma * sigma;
|
|
78
|
+
const half = kernelSize - 1 >> 1;
|
|
79
|
+
let sum = 0;
|
|
80
|
+
for (let i = 0; i < kernelSize; i++) {
|
|
81
|
+
const x = i - half;
|
|
82
|
+
const value = Math.exp(-(x * x) / twoSigmaSq);
|
|
83
|
+
kernel[i] = value;
|
|
84
|
+
sum += value;
|
|
85
|
+
}
|
|
86
|
+
const invSum = 1 / sum;
|
|
87
|
+
for (let i = 0; i < kernelSize; i++) kernel[i] *= invSum;
|
|
88
|
+
const wrapX = wrapEdges ? (coord) => (coord % width + width) % width : (coord) => coord < 0 ? 0 : coord >= width ? width - 1 : coord;
|
|
89
|
+
const wrapY = wrapEdges ? (coord) => (coord % height + height) % height : (coord) => coord < 0 ? 0 : coord >= height ? height - 1 : coord;
|
|
90
|
+
for (let c = 0; c < source.channelCount; c++) {
|
|
91
|
+
const src = source.channels[c];
|
|
92
|
+
const dst = result.channels[c];
|
|
93
|
+
const temp = new Float32Array(width * height);
|
|
94
|
+
for (let y = 0; y < height; y++) {
|
|
95
|
+
const row = y * width;
|
|
96
|
+
for (let x = 0; x < width; x++) {
|
|
97
|
+
let acc = 0;
|
|
98
|
+
for (let k = 0; k < kernelSize; k++) acc += src[row + wrapX(x + k - half)] * kernel[k];
|
|
99
|
+
temp[row + x] = acc;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
for (let x = 0; x < width; x++) {
|
|
103
|
+
for (let y = 0; y < height; y++) {
|
|
104
|
+
let acc = 0;
|
|
105
|
+
for (let k = 0; k < kernelSize; k++) acc += temp[wrapY(y + k - half) * width + x] * kernel[k];
|
|
106
|
+
dst[y * width + x] = acc;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
async function executeBlur(context) {
|
|
113
|
+
const source = await readPlanar(context, context.inputs.image);
|
|
114
|
+
if (!source) return;
|
|
115
|
+
const { method, radius, wrapEdges } = context.props;
|
|
116
|
+
await output(context, method === "gaussian" ? gaussianBlur(source, radius, wrapEdges) : boxBlur(source, radius, wrapEdges));
|
|
117
|
+
}
|
|
118
|
+
async function executeNormalMap(context) {
|
|
119
|
+
const source = await readPlanar(context, context.inputs.image);
|
|
120
|
+
if (!source) return;
|
|
121
|
+
const { scale, flipX, flipY } = context.props;
|
|
122
|
+
const { width, height } = source;
|
|
123
|
+
const result = Planar.rgba(width, height);
|
|
124
|
+
const heightMap = source.channels[0];
|
|
125
|
+
const [rOut, gOut, bOut, aOut] = result.channels;
|
|
126
|
+
for (let y = 0; y < height; y++) {
|
|
127
|
+
for (let x = 0; x < width; x++) {
|
|
128
|
+
const idx = y * width + x;
|
|
129
|
+
const h00 = heightMap[idx];
|
|
130
|
+
const h10 = heightMap[Math.min(x + 1, width - 1) + y * width];
|
|
131
|
+
const h01 = heightMap[x + Math.min(y + 1, height - 1) * width];
|
|
132
|
+
const dx = (h10 - h00) * scale;
|
|
133
|
+
const dy = (h01 - h00) * scale;
|
|
134
|
+
const nx = -(flipX ? -dx : dx);
|
|
135
|
+
const ny = -(flipY ? -dy : dy);
|
|
136
|
+
const nz = 1;
|
|
137
|
+
const length = Math.sqrt(nx * nx + ny * ny + nz * nz);
|
|
138
|
+
rOut[idx] = nx / length * 0.5 + 0.5;
|
|
139
|
+
gOut[idx] = ny / length * 0.5 + 0.5;
|
|
140
|
+
bOut[idx] = nz / length * 0.5 + 0.5;
|
|
141
|
+
aOut[idx] = 1;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
await output(context, result);
|
|
145
|
+
}
|
|
146
|
+
async function executeResize(context) {
|
|
147
|
+
const source = await readPlanar(context, context.inputs.image);
|
|
148
|
+
if (!source) return;
|
|
149
|
+
const { props } = context;
|
|
150
|
+
const scaled = props.mode === "scale";
|
|
151
|
+
const width = scaled ? Math.round(source.width * props.scale) : props.width;
|
|
152
|
+
const height = scaled ? Math.round(source.height * props.scale) : props.height;
|
|
153
|
+
await output(context, resample(source, width, height));
|
|
154
|
+
}
|
|
155
|
+
function pivotPoint(pivot, custom, width, height) {
|
|
156
|
+
switch (pivot) {
|
|
157
|
+
case "top-left":
|
|
158
|
+
return [0, 0];
|
|
159
|
+
case "top-right":
|
|
160
|
+
return [width, 0];
|
|
161
|
+
case "bottom-left":
|
|
162
|
+
return [0, height];
|
|
163
|
+
case "bottom-right":
|
|
164
|
+
return [width, height];
|
|
165
|
+
case "custom":
|
|
166
|
+
return [custom[0] * width, custom[1] * height];
|
|
167
|
+
default:
|
|
168
|
+
return [width / 2, height / 2];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function wrapCoord(coord, size, mode) {
|
|
172
|
+
if (mode === "clamp") return Math.max(0, Math.min(size - 1, coord));
|
|
173
|
+
if (mode === "repeat") {
|
|
174
|
+
coord = coord % size;
|
|
175
|
+
if (coord < 0) coord += size;
|
|
176
|
+
return coord;
|
|
177
|
+
}
|
|
178
|
+
if (mode === "mirror") {
|
|
179
|
+
const period = size * 2;
|
|
180
|
+
coord = Math.abs(coord % period);
|
|
181
|
+
if (coord >= size) coord = period - coord - 1;
|
|
182
|
+
return Math.max(0, Math.min(size - 1, coord));
|
|
183
|
+
}
|
|
184
|
+
return coord;
|
|
185
|
+
}
|
|
186
|
+
async function executeTransform(context) {
|
|
187
|
+
const input = await readPlanar(context, context.inputs.image);
|
|
188
|
+
if (!input) return;
|
|
189
|
+
const { props } = context;
|
|
190
|
+
const { width, height } = input;
|
|
191
|
+
const [tx, ty] = props.translate;
|
|
192
|
+
const rotation = props.rotation * Math.PI / 180;
|
|
193
|
+
const sx = props.scale[0];
|
|
194
|
+
const sy = props.uniformScale ? sx : props.scale[1];
|
|
195
|
+
const [pivotX, pivotY] = pivotPoint(props.pivot, props.customPivot, width, height);
|
|
196
|
+
const cosR = Math.cos(-rotation);
|
|
197
|
+
const sinR = Math.sin(-rotation);
|
|
198
|
+
const invSx = 1 / sx;
|
|
199
|
+
const invSy = 1 / sy;
|
|
200
|
+
const buffer = Planar.rgba(width, height);
|
|
201
|
+
const channelCount = Math.min(input.channelCount, 4);
|
|
202
|
+
const nearest = props.filter === "nearest";
|
|
203
|
+
const wrap = props.wrap;
|
|
204
|
+
for (let y = 0; y < height; y++) {
|
|
205
|
+
for (let x = 0; x < width; x++) {
|
|
206
|
+
const idx = y * width + x;
|
|
207
|
+
const dx = x - pivotX - tx;
|
|
208
|
+
const dy = y - pivotY - ty;
|
|
209
|
+
const srcX = (dx * cosR - dy * sinR) * invSx + pivotX;
|
|
210
|
+
const srcY = (dx * sinR + dy * cosR) * invSy + pivotY;
|
|
211
|
+
if (wrap === "transparent" && (srcX < 0 || srcX >= width || srcY < 0 || srcY >= height)) {
|
|
212
|
+
for (let c = 0; c < 4; c++) buffer.channels[c][idx] = 0;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (nearest) {
|
|
216
|
+
const srcIdx = wrapCoord(Math.round(srcY), height, wrap) * width + wrapCoord(Math.round(srcX), width, wrap);
|
|
217
|
+
for (let c = 0; c < channelCount; c++) buffer.channels[c][idx] = input.channels[c][srcIdx];
|
|
218
|
+
} else {
|
|
219
|
+
const x0 = Math.floor(srcX);
|
|
220
|
+
const y0 = Math.floor(srcY);
|
|
221
|
+
const fx = srcX - x0;
|
|
222
|
+
const fy = srcY - y0;
|
|
223
|
+
const wx0 = wrapCoord(x0, width, wrap);
|
|
224
|
+
const wx1 = wrapCoord(x0 + 1, width, wrap);
|
|
225
|
+
const wy0 = wrapCoord(y0, height, wrap);
|
|
226
|
+
const wy1 = wrapCoord(y0 + 1, height, wrap);
|
|
227
|
+
for (let c = 0; c < channelCount; c++) {
|
|
228
|
+
const channel = input.channels[c];
|
|
229
|
+
const v00 = channel[wy0 * width + wx0];
|
|
230
|
+
const v10 = channel[wy0 * width + wx1];
|
|
231
|
+
const v01 = channel[wy1 * width + wx0];
|
|
232
|
+
const v11 = channel[wy1 * width + wx1];
|
|
233
|
+
const v0 = v00 + (v10 - v00) * fx;
|
|
234
|
+
const v1 = v01 + (v11 - v01) * fx;
|
|
235
|
+
buffer.channels[c][idx] = v0 + (v1 - v0) * fy;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (channelCount < 4) buffer.channels[3][idx] = 1;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
await output(context, buffer);
|
|
242
|
+
}
|
|
243
|
+
function blend(base, layer, mode, opacity) {
|
|
244
|
+
const { width, height } = base;
|
|
245
|
+
const result = Planar.rgba(width, height);
|
|
246
|
+
const [r1, g1, b1, a1] = (base.channelCount >= 4 ? base : base.toRGBA()).channels;
|
|
247
|
+
const [r2, g2, b2, a2] = (layer.channelCount >= 4 ? layer : layer.toRGBA()).channels;
|
|
248
|
+
const [rOut, gOut, bOut, aOut] = result.channels;
|
|
249
|
+
for (let i = 0; i < width * height; i++) {
|
|
250
|
+
const baseR = r1[i], baseG = g1[i], baseB = b1[i], baseA = a1[i];
|
|
251
|
+
const blendR = r2[i], blendG = g2[i], blendB = b2[i], blendA = a2[i];
|
|
252
|
+
let r, g, b;
|
|
253
|
+
switch (mode) {
|
|
254
|
+
case "normal":
|
|
255
|
+
r = blendR;
|
|
256
|
+
g = blendG;
|
|
257
|
+
b = blendB;
|
|
258
|
+
break;
|
|
259
|
+
case "multiply":
|
|
260
|
+
r = baseR * blendR;
|
|
261
|
+
g = baseG * blendG;
|
|
262
|
+
b = baseB * blendB;
|
|
263
|
+
break;
|
|
264
|
+
case "screen":
|
|
265
|
+
r = 1 - (1 - baseR) * (1 - blendR);
|
|
266
|
+
g = 1 - (1 - baseG) * (1 - blendG);
|
|
267
|
+
b = 1 - (1 - baseB) * (1 - blendB);
|
|
268
|
+
break;
|
|
269
|
+
case "overlay":
|
|
270
|
+
r = baseR < 0.5 ? 2 * baseR * blendR : 1 - 2 * (1 - baseR) * (1 - blendR);
|
|
271
|
+
g = baseG < 0.5 ? 2 * baseG * blendG : 1 - 2 * (1 - baseG) * (1 - blendG);
|
|
272
|
+
b = baseB < 0.5 ? 2 * baseB * blendB : 1 - 2 * (1 - baseB) * (1 - blendB);
|
|
273
|
+
break;
|
|
274
|
+
case "darken":
|
|
275
|
+
r = Math.min(baseR, blendR);
|
|
276
|
+
g = Math.min(baseG, blendG);
|
|
277
|
+
b = Math.min(baseB, blendB);
|
|
278
|
+
break;
|
|
279
|
+
case "lighten":
|
|
280
|
+
r = Math.max(baseR, blendR);
|
|
281
|
+
g = Math.max(baseG, blendG);
|
|
282
|
+
b = Math.max(baseB, blendB);
|
|
283
|
+
break;
|
|
284
|
+
case "color-dodge":
|
|
285
|
+
r = blendR === 1 ? 1 : Math.min(1, baseR / (1 - blendR));
|
|
286
|
+
g = blendG === 1 ? 1 : Math.min(1, baseG / (1 - blendG));
|
|
287
|
+
b = blendB === 1 ? 1 : Math.min(1, baseB / (1 - blendB));
|
|
288
|
+
break;
|
|
289
|
+
case "color-burn":
|
|
290
|
+
r = blendR === 0 ? 0 : Math.max(0, 1 - (1 - baseR) / blendR);
|
|
291
|
+
g = blendG === 0 ? 0 : Math.max(0, 1 - (1 - baseG) / blendG);
|
|
292
|
+
b = blendB === 0 ? 0 : Math.max(0, 1 - (1 - baseB) / blendB);
|
|
293
|
+
break;
|
|
294
|
+
case "hard-light":
|
|
295
|
+
r = blendR < 0.5 ? 2 * baseR * blendR : 1 - 2 * (1 - baseR) * (1 - blendR);
|
|
296
|
+
g = blendG < 0.5 ? 2 * baseG * blendG : 1 - 2 * (1 - baseG) * (1 - blendG);
|
|
297
|
+
b = blendB < 0.5 ? 2 * baseB * blendB : 1 - 2 * (1 - baseB) * (1 - blendB);
|
|
298
|
+
break;
|
|
299
|
+
case "soft-light":
|
|
300
|
+
r = blendR < 0.5 ? baseR - (1 - 2 * blendR) * baseR * (1 - baseR) : baseR + (2 * blendR - 1) * (Math.sqrt(baseR) - baseR);
|
|
301
|
+
g = blendG < 0.5 ? baseG - (1 - 2 * blendG) * baseG * (1 - baseG) : baseG + (2 * blendG - 1) * (Math.sqrt(baseG) - baseG);
|
|
302
|
+
b = blendB < 0.5 ? baseB - (1 - 2 * blendB) * baseB * (1 - baseB) : baseB + (2 * blendB - 1) * (Math.sqrt(baseB) - baseB);
|
|
303
|
+
break;
|
|
304
|
+
case "difference":
|
|
305
|
+
r = Math.abs(baseR - blendR);
|
|
306
|
+
g = Math.abs(baseG - blendG);
|
|
307
|
+
b = Math.abs(baseB - blendB);
|
|
308
|
+
break;
|
|
309
|
+
case "exclusion":
|
|
310
|
+
r = baseR + blendR - 2 * baseR * blendR;
|
|
311
|
+
g = baseG + blendG - 2 * baseG * blendG;
|
|
312
|
+
b = baseB + blendB - 2 * baseB * blendB;
|
|
313
|
+
break;
|
|
314
|
+
case "add":
|
|
315
|
+
case "linear-dodge":
|
|
316
|
+
r = Math.min(1, baseR + blendR);
|
|
317
|
+
g = Math.min(1, baseG + blendG);
|
|
318
|
+
b = Math.min(1, baseB + blendB);
|
|
319
|
+
break;
|
|
320
|
+
case "subtract":
|
|
321
|
+
r = Math.max(0, baseR - blendR);
|
|
322
|
+
g = Math.max(0, baseG - blendG);
|
|
323
|
+
b = Math.max(0, baseB - blendB);
|
|
324
|
+
break;
|
|
325
|
+
case "divide":
|
|
326
|
+
r = blendR === 0 ? 1 : Math.min(1, baseR / blendR);
|
|
327
|
+
g = blendG === 0 ? 1 : Math.min(1, baseG / blendG);
|
|
328
|
+
b = blendB === 0 ? 1 : Math.min(1, baseB / blendB);
|
|
329
|
+
break;
|
|
330
|
+
case "pin-light":
|
|
331
|
+
r = blendR < 0.5 ? Math.min(baseR, 2 * blendR) : Math.max(baseR, 2 * (blendR - 0.5));
|
|
332
|
+
g = blendG < 0.5 ? Math.min(baseG, 2 * blendG) : Math.max(baseG, 2 * (blendG - 0.5));
|
|
333
|
+
b = blendB < 0.5 ? Math.min(baseB, 2 * blendB) : Math.max(baseB, 2 * (blendB - 0.5));
|
|
334
|
+
break;
|
|
335
|
+
case "vivid-light":
|
|
336
|
+
r = blendR < 0.5 ? blendR === 0 ? 0 : 1 - (1 - baseR) / (2 * blendR) : blendR === 1 ? 1 : baseR / (2 * (1 - blendR));
|
|
337
|
+
g = blendG < 0.5 ? blendG === 0 ? 0 : 1 - (1 - baseG) / (2 * blendG) : blendG === 1 ? 1 : baseG / (2 * (1 - blendG));
|
|
338
|
+
b = blendB < 0.5 ? blendB === 0 ? 0 : 1 - (1 - baseB) / (2 * blendB) : blendB === 1 ? 1 : baseB / (2 * (1 - blendB));
|
|
339
|
+
break;
|
|
340
|
+
case "linear-burn":
|
|
341
|
+
r = Math.max(0, baseR + blendR - 1);
|
|
342
|
+
g = Math.max(0, baseG + blendG - 1);
|
|
343
|
+
b = Math.max(0, baseB + blendB - 1);
|
|
344
|
+
break;
|
|
345
|
+
default:
|
|
346
|
+
r = blendR;
|
|
347
|
+
g = blendG;
|
|
348
|
+
b = blendB;
|
|
349
|
+
}
|
|
350
|
+
rOut[i] = baseR + (r - baseR) * opacity * blendA;
|
|
351
|
+
gOut[i] = baseG + (g - baseG) * opacity * blendA;
|
|
352
|
+
bOut[i] = baseB + (b - baseB) * opacity * blendA;
|
|
353
|
+
aOut[i] = baseA + (blendA - baseA) * opacity;
|
|
354
|
+
}
|
|
355
|
+
return result;
|
|
356
|
+
}
|
|
357
|
+
async function executeComposite(context) {
|
|
358
|
+
const { props } = context;
|
|
359
|
+
const inputs = [await readPlanar(context, context.inputs.image1), await readPlanar(context, context.inputs.image2)];
|
|
360
|
+
const { width, height } = resolveOutputSize(
|
|
361
|
+
props.outputResolution,
|
|
362
|
+
inputs,
|
|
363
|
+
props.customResolution
|
|
364
|
+
);
|
|
365
|
+
const [base, layer] = inputs.map((buffer) => {
|
|
366
|
+
if (!buffer || buffer.width === width && buffer.height === height) return buffer;
|
|
367
|
+
return resizeToFit(buffer, width, height, props.fitMode);
|
|
368
|
+
});
|
|
369
|
+
if (!base || !layer) return;
|
|
370
|
+
await output(context, blend(base, layer, props.blendMode, props.opacity));
|
|
371
|
+
}
|
|
372
|
+
export {
|
|
373
|
+
executeBlur,
|
|
374
|
+
executeComposite,
|
|
375
|
+
executeNormalMap,
|
|
376
|
+
executeResize,
|
|
377
|
+
executeTransform
|
|
378
|
+
};
|
|
379
|
+
//# sourceMappingURL=filters-6ODFWYK4.js.map
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Planar,
|
|
3
|
+
normalizeColor,
|
|
4
|
+
output
|
|
5
|
+
} from "./chunk-WGKPJZDY.js";
|
|
6
|
+
|
|
7
|
+
// packages/runtime/src/builtins/image/simplex.ts
|
|
8
|
+
var SQRT3 = Math.sqrt(3);
|
|
9
|
+
var F2 = 0.5 * (SQRT3 - 1);
|
|
10
|
+
var G2 = (3 - SQRT3) / 6;
|
|
11
|
+
var fastFloor = (x) => Math.floor(x) | 0;
|
|
12
|
+
var grad2 = new Float64Array([1, 1, -1, 1, 1, -1, -1, -1, 1, 0, -1, 0, 1, 0, -1, 0, 0, 1, 0, -1, 0, 1, 0, -1]);
|
|
13
|
+
function buildPermutationTable(random) {
|
|
14
|
+
const tableSize = 512;
|
|
15
|
+
const p = new Uint8Array(tableSize);
|
|
16
|
+
for (let i = 0; i < tableSize / 2; i++) p[i] = i;
|
|
17
|
+
for (let i = 0; i < tableSize / 2 - 1; i++) {
|
|
18
|
+
const r = i + ~~(random() * (256 - i));
|
|
19
|
+
const aux = p[i];
|
|
20
|
+
p[i] = p[r];
|
|
21
|
+
p[r] = aux;
|
|
22
|
+
}
|
|
23
|
+
for (let i = 256; i < tableSize; i++) p[i] = p[i - 256];
|
|
24
|
+
return p;
|
|
25
|
+
}
|
|
26
|
+
function createNoise2D(random) {
|
|
27
|
+
const perm = buildPermutationTable(random);
|
|
28
|
+
const permGrad2x = new Float64Array(perm).map((v) => grad2[v % 12 * 2]);
|
|
29
|
+
const permGrad2y = new Float64Array(perm).map((v) => grad2[v % 12 * 2 + 1]);
|
|
30
|
+
return function noise2D(x, y) {
|
|
31
|
+
let n0 = 0;
|
|
32
|
+
let n1 = 0;
|
|
33
|
+
let n2 = 0;
|
|
34
|
+
const s = (x + y) * F2;
|
|
35
|
+
const i = fastFloor(x + s);
|
|
36
|
+
const j = fastFloor(y + s);
|
|
37
|
+
const t = (i + j) * G2;
|
|
38
|
+
const X0 = i - t;
|
|
39
|
+
const Y0 = j - t;
|
|
40
|
+
const x0 = x - X0;
|
|
41
|
+
const y0 = y - Y0;
|
|
42
|
+
let i1, j1;
|
|
43
|
+
if (x0 > y0) {
|
|
44
|
+
i1 = 1;
|
|
45
|
+
j1 = 0;
|
|
46
|
+
} else {
|
|
47
|
+
i1 = 0;
|
|
48
|
+
j1 = 1;
|
|
49
|
+
}
|
|
50
|
+
const x1 = x0 - i1 + G2;
|
|
51
|
+
const y1 = y0 - j1 + G2;
|
|
52
|
+
const x2 = x0 - 1 + 2 * G2;
|
|
53
|
+
const y2 = y0 - 1 + 2 * G2;
|
|
54
|
+
const ii = i & 255;
|
|
55
|
+
const jj = j & 255;
|
|
56
|
+
let t0 = 0.5 - x0 * x0 - y0 * y0;
|
|
57
|
+
if (t0 >= 0) {
|
|
58
|
+
const gi0 = ii + perm[jj];
|
|
59
|
+
t0 *= t0;
|
|
60
|
+
n0 = t0 * t0 * (permGrad2x[gi0] * x0 + permGrad2y[gi0] * y0);
|
|
61
|
+
}
|
|
62
|
+
let t1 = 0.5 - x1 * x1 - y1 * y1;
|
|
63
|
+
if (t1 >= 0) {
|
|
64
|
+
const gi1 = ii + i1 + perm[jj + j1];
|
|
65
|
+
t1 *= t1;
|
|
66
|
+
n1 = t1 * t1 * (permGrad2x[gi1] * x1 + permGrad2y[gi1] * y1);
|
|
67
|
+
}
|
|
68
|
+
let t2 = 0.5 - x2 * x2 - y2 * y2;
|
|
69
|
+
if (t2 >= 0) {
|
|
70
|
+
const gi2 = ii + 1 + perm[jj + 1];
|
|
71
|
+
t2 *= t2;
|
|
72
|
+
n2 = t2 * t2 * (permGrad2x[gi2] * x2 + permGrad2y[gi2] * y2);
|
|
73
|
+
}
|
|
74
|
+
return 70 * (n0 + n1 + n2);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// packages/runtime/src/builtins/image/generators.ts
|
|
79
|
+
function size(resolution) {
|
|
80
|
+
return [resolution[0], resolution[1]];
|
|
81
|
+
}
|
|
82
|
+
async function executeColor(context) {
|
|
83
|
+
const [width, height] = size(context.props.resolution);
|
|
84
|
+
await output(context, Planar.solid(width, height, normalizeColor(context.props.color)));
|
|
85
|
+
}
|
|
86
|
+
async function executeCheckers(context) {
|
|
87
|
+
const { props } = context;
|
|
88
|
+
const [width, height] = size(props.resolution);
|
|
89
|
+
const color1 = normalizeColor(props.color1);
|
|
90
|
+
const color2 = normalizeColor(props.color2);
|
|
91
|
+
const checkerSize = props.mode === "size" ? props.size : width / props.divisions;
|
|
92
|
+
let offsetX = 0;
|
|
93
|
+
let offsetY = 0;
|
|
94
|
+
if (props.centered) {
|
|
95
|
+
offsetX = width / 2 % checkerSize - checkerSize / 2;
|
|
96
|
+
offsetY = height / 2 % checkerSize - checkerSize / 2;
|
|
97
|
+
}
|
|
98
|
+
const buffer = Planar.rgba(width, height);
|
|
99
|
+
const [r, g, b, a] = buffer.channels;
|
|
100
|
+
for (let y = 0; y < height; y++) {
|
|
101
|
+
for (let x = 0; x < width; x++) {
|
|
102
|
+
const idx = y * width + x;
|
|
103
|
+
const even = (Math.floor((x - offsetX) / checkerSize) + Math.floor((y - offsetY) / checkerSize)) % 2 === 0;
|
|
104
|
+
const color = even ? color1 : color2;
|
|
105
|
+
r[idx] = color.r;
|
|
106
|
+
g[idx] = color.g;
|
|
107
|
+
b[idx] = color.b;
|
|
108
|
+
a[idx] = color.a;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
await output(context, buffer);
|
|
112
|
+
}
|
|
113
|
+
async function executeNoise(context) {
|
|
114
|
+
const { props } = context;
|
|
115
|
+
const [width, height] = size(props.resolution);
|
|
116
|
+
let rng = props.seed;
|
|
117
|
+
const noise2D = createNoise2D(() => {
|
|
118
|
+
rng = (rng * 9301 + 49297) % 233280;
|
|
119
|
+
return rng / 233280;
|
|
120
|
+
});
|
|
121
|
+
const buffer = Planar.grayscale(width, height);
|
|
122
|
+
const gray = buffer.channels[0];
|
|
123
|
+
for (let y = 0; y < height; y++) {
|
|
124
|
+
for (let x = 0; x < width; x++) {
|
|
125
|
+
let value = 0;
|
|
126
|
+
let amplitude = 1;
|
|
127
|
+
let frequency = props.scale;
|
|
128
|
+
let maxValue = 0;
|
|
129
|
+
for (let i = 0; i < props.iterations; i++) {
|
|
130
|
+
value += noise2D(x * frequency, y * frequency) * amplitude;
|
|
131
|
+
maxValue += amplitude;
|
|
132
|
+
amplitude *= 0.5;
|
|
133
|
+
frequency *= 2;
|
|
134
|
+
}
|
|
135
|
+
gray[y * width + x] = (value / maxValue + 1) * 0.5;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
await output(context, buffer);
|
|
139
|
+
}
|
|
140
|
+
function interpolateColor(color1, color2, t, interpolation) {
|
|
141
|
+
if (interpolation === "constant") return t < 0.5 ? color1 : color2;
|
|
142
|
+
if (interpolation === "smooth") t = t * t * (3 - 2 * t);
|
|
143
|
+
return {
|
|
144
|
+
r: color1.r + (color2.r - color1.r) * t,
|
|
145
|
+
g: color1.g + (color2.g - color1.g) * t,
|
|
146
|
+
b: color1.b + (color2.b - color1.b) * t,
|
|
147
|
+
a: (color1.a ?? 1) + ((color2.a ?? 1) - (color1.a ?? 1)) * t
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function colorAt(points, position) {
|
|
151
|
+
const sorted = [...points].sort((a, b) => a.position - b.position);
|
|
152
|
+
position = Math.max(0, Math.min(1, position));
|
|
153
|
+
let before = null;
|
|
154
|
+
let after = null;
|
|
155
|
+
for (const point of sorted) {
|
|
156
|
+
if (point.position <= position) before = point;
|
|
157
|
+
if (point.position >= position && !after) {
|
|
158
|
+
after = point;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (!before && after) return normalizeColor(after.color);
|
|
163
|
+
if (before && !after) return normalizeColor(before.color);
|
|
164
|
+
if (!before || !after) return { r: 0, g: 0, b: 0, a: 1 };
|
|
165
|
+
if (before.position === position) return normalizeColor(before.color);
|
|
166
|
+
if (after.position === position) return normalizeColor(after.color);
|
|
167
|
+
const t = (position - before.position) / (after.position - before.position);
|
|
168
|
+
return interpolateColor(normalizeColor(before.color), normalizeColor(after.color), t, after.interpolation || "linear");
|
|
169
|
+
}
|
|
170
|
+
async function executeRamp(context) {
|
|
171
|
+
const { props } = context;
|
|
172
|
+
const [width, height] = size(props.resolution);
|
|
173
|
+
const points = props.points ?? [];
|
|
174
|
+
if (points.length === 0) return;
|
|
175
|
+
const buffer = Planar.rgba(width, height);
|
|
176
|
+
const [r, g, b, a] = buffer.channels;
|
|
177
|
+
const centerX = width / 2;
|
|
178
|
+
const centerY = height / 2;
|
|
179
|
+
const maxDist = Math.sqrt(centerX * centerX + centerY * centerY);
|
|
180
|
+
for (let y = 0; y < height; y++) {
|
|
181
|
+
for (let x = 0; x < width; x++) {
|
|
182
|
+
let position = 0;
|
|
183
|
+
if (props.type === "horizontal") {
|
|
184
|
+
position = x / width;
|
|
185
|
+
} else if (props.type === "vertical") {
|
|
186
|
+
position = y / height;
|
|
187
|
+
} else if (props.type === "radial") {
|
|
188
|
+
position = (Math.atan2(y - centerY, x - centerX) + Math.PI) / (2 * Math.PI);
|
|
189
|
+
} else if (props.type === "concentric") {
|
|
190
|
+
const dx = x - centerX;
|
|
191
|
+
const dy = y - centerY;
|
|
192
|
+
position = Math.sqrt(dx * dx + dy * dy) / maxDist;
|
|
193
|
+
}
|
|
194
|
+
const color = colorAt(points, position);
|
|
195
|
+
const idx = y * width + x;
|
|
196
|
+
r[idx] = color.r;
|
|
197
|
+
g[idx] = color.g;
|
|
198
|
+
b[idx] = color.b;
|
|
199
|
+
a[idx] = color.a ?? 1;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
await output(context, buffer);
|
|
203
|
+
}
|
|
204
|
+
export {
|
|
205
|
+
executeCheckers,
|
|
206
|
+
executeColor,
|
|
207
|
+
executeNoise,
|
|
208
|
+
executeRamp
|
|
209
|
+
};
|
|
210
|
+
//# sourceMappingURL=generators-YU7GB4MD.js.map
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
browserAssetCapability
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZSCUZE6I.js";
|
|
4
4
|
import {
|
|
5
5
|
registerDefinitionNodes
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-BPODRH52.js";
|
|
7
|
+
import "./chunk-CTPLRSWF.js";
|
|
8
8
|
import "./chunk-RUU3YWXU.js";
|
|
9
9
|
import {
|
|
10
10
|
geoNodeDefinitions,
|
|
11
11
|
geoNodeRegistrations
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GRIN2DDP.js";
|
|
13
13
|
import "./chunk-DEQSEFFH.js";
|
|
14
14
|
import "./chunk-HSNOBIVT.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-L6B6FUQP.js";
|
|
16
16
|
import "./chunk-HFHWYL55.js";
|
|
17
17
|
import "./chunk-CO22XHNG.js";
|
|
18
18
|
import "./chunk-J7VK7MNF.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-FWMSGKEH.js";
|
|
20
20
|
|
|
21
21
|
// src/nodes/geo/library.ts
|
|
22
22
|
var geoLibrary = {
|
|
@@ -40,4 +40,4 @@ registerDefinitionNodes(geoNodeRegistrations, { assets: browserAssetCapability }
|
|
|
40
40
|
export {
|
|
41
41
|
geoLibrary
|
|
42
42
|
};
|
|
43
|
-
//# sourceMappingURL=geo-
|
|
43
|
+
//# sourceMappingURL=geo-6ZPGKZRU.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
VERBS,
|
|
3
3
|
graphOptions
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-G23A2BZZ.js";
|
|
5
5
|
|
|
6
6
|
// src/cli/graphCommands.ts
|
|
7
7
|
import fs from "node:fs/promises";
|
|
8
8
|
import path from "node:path";
|
|
9
|
-
var loadGraphFile = async () => (await import("./graphFile-
|
|
9
|
+
var loadGraphFile = async () => (await import("./graphFile-CITF36ZM.js")).GraphFile;
|
|
10
10
|
async function runGraphCommand(args, options) {
|
|
11
11
|
const parsed = parseArguments(args);
|
|
12
12
|
const [command, ...rest] = parsed.positional;
|
|
@@ -21,7 +21,7 @@ async function runGraphCommand(args, options) {
|
|
|
21
21
|
}
|
|
22
22
|
if (sub === "read") {
|
|
23
23
|
const graph = await (await loadGraphFile()).open(required(file2, "cascade graph read <graph>"));
|
|
24
|
-
const { readGraph } = await import("./edit-
|
|
24
|
+
const { readGraph } = await import("./edit-S5KEQ5RA.js");
|
|
25
25
|
const read = readGraph(graph.document, optional(parsed.values.in, "in"));
|
|
26
26
|
if (!options.json) printGraph(read);
|
|
27
27
|
return { file: graph.file, ...read };
|
|
@@ -181,4 +181,4 @@ export {
|
|
|
181
181
|
applyEdits,
|
|
182
182
|
runGraphCommand
|
|
183
183
|
};
|
|
184
|
-
//# sourceMappingURL=graphCommands-
|
|
184
|
+
//# sourceMappingURL=graphCommands-MULQ7VD2.js.map
|