@nexart/codemode-sdk 1.8.1 → 1.8.2
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/CHANGELOG.md +46 -0
- package/LICENSE.md +5 -5
- package/README.md +72 -11
- package/dist/sdk/codemode/core-index.d.ts +6 -4
- package/dist/sdk/codemode/core-index.d.ts.map +1 -1
- package/dist/sdk/codemode/core-index.js +6 -4
- package/dist/{entry → sdk/codemode/entry}/browser.d.ts +5 -2
- package/dist/sdk/codemode/entry/browser.d.ts.map +1 -0
- package/dist/{entry → sdk/codemode/entry}/browser.js +10 -4
- package/dist/{entry → sdk/codemode/entry}/node.d.ts +2 -1
- package/dist/sdk/codemode/entry/node.d.ts.map +1 -0
- package/dist/{entry → sdk/codemode/entry}/node.js +2 -1
- package/dist/{runtime.d.ts → sdk/codemode/runtime.d.ts} +2 -2
- package/dist/sdk/codemode/runtime.d.ts.map +1 -0
- package/dist/{runtime.js → sdk/codemode/runtime.js} +3 -2
- package/dist/sdk/codemode/static-engine.d.ts.map +1 -1
- package/dist/sdk/codemode/static-engine.js +24 -11
- package/dist/sdk/codemode/version.d.ts +18 -0
- package/dist/sdk/codemode/version.d.ts.map +1 -0
- package/dist/sdk/codemode/version.js +17 -0
- package/examples/agent-quickstart.ts +159 -0
- package/examples/preflight-test.ts +1 -1
- package/package.json +2 -1
- package/dist/builder-manifest.d.ts +0 -79
- package/dist/builder-manifest.d.ts.map +0 -1
- package/dist/builder-manifest.js +0 -97
- package/dist/core-index.d.ts +0 -21
- package/dist/core-index.d.ts.map +0 -1
- package/dist/core-index.js +0 -26
- package/dist/engine.d.ts +0 -24
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js +0 -67
- package/dist/entry/browser.d.ts.map +0 -1
- package/dist/entry/node.d.ts.map +0 -1
- package/dist/execute.d.ts +0 -46
- package/dist/execute.d.ts.map +0 -1
- package/dist/execute.js +0 -283
- package/dist/execution-sandbox.d.ts +0 -107
- package/dist/execution-sandbox.d.ts.map +0 -1
- package/dist/execution-sandbox.js +0 -207
- package/dist/index.d.ts +0 -31
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -63
- package/dist/loop-engine.d.ts +0 -22
- package/dist/loop-engine.d.ts.map +0 -1
- package/dist/loop-engine.js +0 -229
- package/dist/noise-bridge.d.ts +0 -44
- package/dist/noise-bridge.d.ts.map +0 -1
- package/dist/noise-bridge.js +0 -68
- package/dist/noise-engine.d.ts +0 -74
- package/dist/noise-engine.d.ts.map +0 -1
- package/dist/noise-engine.js +0 -132
- package/dist/noise-sketches/fractalNoise.d.ts +0 -11
- package/dist/noise-sketches/fractalNoise.d.ts.map +0 -1
- package/dist/noise-sketches/fractalNoise.js +0 -121
- package/dist/noise-sketches/index.d.ts +0 -21
- package/dist/noise-sketches/index.d.ts.map +0 -1
- package/dist/noise-sketches/index.js +0 -28
- package/dist/p5-runtime.d.ts +0 -75
- package/dist/p5-runtime.d.ts.map +0 -1
- package/dist/p5-runtime.js +0 -1031
- package/dist/runtime.d.ts.map +0 -1
- package/dist/sdk/codemode/index.d.ts +0 -31
- package/dist/sdk/codemode/index.d.ts.map +0 -1
- package/dist/sdk/codemode/index.js +0 -63
- package/dist/sdk/codemode/noise-bridge.d.ts +0 -44
- package/dist/sdk/codemode/noise-bridge.d.ts.map +0 -1
- package/dist/sdk/codemode/noise-bridge.js +0 -68
- package/dist/sdk/codemode/noise-engine.d.ts +0 -74
- package/dist/sdk/codemode/noise-engine.d.ts.map +0 -1
- package/dist/sdk/codemode/noise-engine.js +0 -132
- package/dist/sdk/codemode/noise-sketches/fractalNoise.d.ts +0 -11
- package/dist/sdk/codemode/noise-sketches/fractalNoise.d.ts.map +0 -1
- package/dist/sdk/codemode/noise-sketches/fractalNoise.js +0 -121
- package/dist/sdk/codemode/noise-sketches/index.d.ts +0 -21
- package/dist/sdk/codemode/noise-sketches/index.d.ts.map +0 -1
- package/dist/sdk/codemode/noise-sketches/index.js +0 -28
- package/dist/shared/noiseSnapshot.d.ts +0 -59
- package/dist/shared/noiseSnapshot.d.ts.map +0 -1
- package/dist/shared/noiseSnapshot.js +0 -72
- package/dist/sound-bridge.d.ts +0 -89
- package/dist/sound-bridge.d.ts.map +0 -1
- package/dist/sound-bridge.js +0 -128
- package/dist/soundart-engine.d.ts +0 -87
- package/dist/soundart-engine.d.ts.map +0 -1
- package/dist/soundart-engine.js +0 -173
- package/dist/soundart-sketches/chladniBloom.d.ts +0 -3
- package/dist/soundart-sketches/chladniBloom.d.ts.map +0 -1
- package/dist/soundart-sketches/chladniBloom.js +0 -53
- package/dist/soundart-sketches/dualVortex.d.ts +0 -3
- package/dist/soundart-sketches/dualVortex.d.ts.map +0 -1
- package/dist/soundart-sketches/dualVortex.js +0 -67
- package/dist/soundart-sketches/geometryIllusion.d.ts +0 -3
- package/dist/soundart-sketches/geometryIllusion.d.ts.map +0 -1
- package/dist/soundart-sketches/geometryIllusion.js +0 -89
- package/dist/soundart-sketches/index.d.ts +0 -39
- package/dist/soundart-sketches/index.d.ts.map +0 -1
- package/dist/soundart-sketches/index.js +0 -72
- package/dist/soundart-sketches/isoflow.d.ts +0 -3
- package/dist/soundart-sketches/isoflow.d.ts.map +0 -1
- package/dist/soundart-sketches/isoflow.js +0 -60
- package/dist/soundart-sketches/loomWeave.d.ts +0 -3
- package/dist/soundart-sketches/loomWeave.d.ts.map +0 -1
- package/dist/soundart-sketches/loomWeave.js +0 -59
- package/dist/soundart-sketches/noiseTerraces.d.ts +0 -3
- package/dist/soundart-sketches/noiseTerraces.d.ts.map +0 -1
- package/dist/soundart-sketches/noiseTerraces.js +0 -53
- package/dist/soundart-sketches/orb.d.ts +0 -3
- package/dist/soundart-sketches/orb.d.ts.map +0 -1
- package/dist/soundart-sketches/orb.js +0 -50
- package/dist/soundart-sketches/pixelGlyphs.d.ts +0 -3
- package/dist/soundart-sketches/pixelGlyphs.d.ts.map +0 -1
- package/dist/soundart-sketches/pixelGlyphs.js +0 -72
- package/dist/soundart-sketches/prismFlowFields.d.ts +0 -3
- package/dist/soundart-sketches/prismFlowFields.d.ts.map +0 -1
- package/dist/soundart-sketches/prismFlowFields.js +0 -51
- package/dist/soundart-sketches/radialBurst.d.ts +0 -3
- package/dist/soundart-sketches/radialBurst.d.ts.map +0 -1
- package/dist/soundart-sketches/radialBurst.js +0 -60
- package/dist/soundart-sketches/resonantSoundBodies.d.ts +0 -3
- package/dist/soundart-sketches/resonantSoundBodies.d.ts.map +0 -1
- package/dist/soundart-sketches/resonantSoundBodies.js +0 -89
- package/dist/soundart-sketches/rings.d.ts +0 -11
- package/dist/soundart-sketches/rings.d.ts.map +0 -1
- package/dist/soundart-sketches/rings.js +0 -89
- package/dist/soundart-sketches/squares.d.ts +0 -3
- package/dist/soundart-sketches/squares.d.ts.map +0 -1
- package/dist/soundart-sketches/squares.js +0 -52
- package/dist/soundart-sketches/waveStripes.d.ts +0 -3
- package/dist/soundart-sketches/waveStripes.d.ts.map +0 -1
- package/dist/soundart-sketches/waveStripes.js +0 -44
- package/dist/static-engine.d.ts +0 -20
- package/dist/static-engine.d.ts.map +0 -1
- package/dist/static-engine.js +0 -157
- package/dist/types.d.ts +0 -191
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -32
package/dist/runtime.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,IAAI,MAAM,CAAC;IACjB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5C,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9C,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjD,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IACvB,MAAM,IAAI,MAAM,CAAC;IACjB,QAAQ,IAAI,YAAY,CAAC;IACzB,OAAO,IAAI,MAAM,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAqGD,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CAuHpE;AAED,eAAO,MAAM,aAAa;;;CAGzB,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NexArt Code Mode Runtime SDK - App Integration Layer
|
|
3
|
-
*
|
|
4
|
-
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
5
|
-
* ║ LOCAL SDK WRAPPER ║
|
|
6
|
-
* ║ ║
|
|
7
|
-
* ║ This file re-exports the core runtime from @nexart/codemode-sdk (npm) ║
|
|
8
|
-
* ║ and adds app-specific integrations (SoundArt, Noise, etc.) ║
|
|
9
|
-
* ║ ║
|
|
10
|
-
* ║ For core Code Mode: import from '@nexart/codemode-sdk' ║
|
|
11
|
-
* ║ For app integrations: import from 'sdk/codemode' ║
|
|
12
|
-
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
13
|
-
*/
|
|
14
|
-
export { executeCodeMode, validateCodeModeSource, DEFAULT_CONFIG, PROTOCOL_IDENTITY, } from '@nexart/codemode-sdk';
|
|
15
|
-
export type { ExecuteCodeModeInput, ExecuteCodeModeResult, ProtocolMetadata, RenderResult, TimeVariables, } from '@nexart/codemode-sdk';
|
|
16
|
-
export { createP5Runtime, injectTimeVariables, injectProtocolVariables, createProtocolVAR } from './p5-runtime';
|
|
17
|
-
export type { P5Runtime, P5RuntimeConfig } from './p5-runtime';
|
|
18
|
-
export { createEngine } from './engine';
|
|
19
|
-
export type { Engine, EngineConfig, RunOptions, ProgressInfo, RenderMode, } from './types';
|
|
20
|
-
export { DEFAULT_CONFIG as LOCAL_DEFAULT_CONFIG } from './types';
|
|
21
|
-
export { renderSoundArtViaCodeMode, canRenderViaCodeMode, getCodeModeAvailableStyles, type SoundArtEngineConfig, type SoundArtRenderOptions, type SoundArtRenderResult, type SoundArtMetadata, } from './soundart-engine';
|
|
22
|
-
export { type SoundSnapshot, type SoundFeatures, createSoundSnapshot, createEmptySoundSnapshot, freezeSoundSnapshot, } from '../../shared/soundSnapshot';
|
|
23
|
-
export { injectSoundGlobals, createSoundGlobals, createEmptySoundGlobals, generateSoundPalette, inferGenreProfile, createSoundHelpers, type SoundGlobals, type GenreProfile, } from './sound-bridge';
|
|
24
|
-
export { getSoundArtSketch, getAvailableSoundArtSketches, isSoundArtSketchAvailable, type SoundArtSketchName, } from './soundart-sketches';
|
|
25
|
-
export { renderNoiseViaCodeMode, compileNoiseSystem, canRenderNoiseViaCodeMode, type NoiseEngineConfig, type NoiseRenderOptions, type NoiseRenderResult, type NoiseMetadata, } from './noise-engine';
|
|
26
|
-
export { type NoiseSnapshot, type NoiseParams, type NoiseBlendMode, createNoiseSnapshot, validateNoiseSnapshot, } from '../../shared/noiseSnapshot';
|
|
27
|
-
export { createNoiseGlobals, injectNoiseGlobals, type NoiseGlobals, } from './noise-bridge';
|
|
28
|
-
export { getNoiseSketch, getAvailableNoiseSketchNames, isValidNoiseSketch, type NoiseSketchName, } from './noise-sketches';
|
|
29
|
-
export { registerBuilderManifest } from './builder-manifest';
|
|
30
|
-
export type { NexArtBuilderManifest } from './types';
|
|
31
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,aAAa,GACd,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAChH,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EACV,MAAM,EACN,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAGjE,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iBAAiB,EACjB,4BAA4B,EAC5B,yBAAyB,EACzB,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,kBAAkB,EAClB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC;AAkB1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NexArt Code Mode Runtime SDK - App Integration Layer
|
|
3
|
-
*
|
|
4
|
-
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
5
|
-
* ║ LOCAL SDK WRAPPER ║
|
|
6
|
-
* ║ ║
|
|
7
|
-
* ║ This file re-exports the core runtime from @nexart/codemode-sdk (npm) ║
|
|
8
|
-
* ║ and adds app-specific integrations (SoundArt, Noise, etc.) ║
|
|
9
|
-
* ║ ║
|
|
10
|
-
* ║ For core Code Mode: import from '@nexart/codemode-sdk' ║
|
|
11
|
-
* ║ For app integrations: import from 'sdk/codemode' ║
|
|
12
|
-
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
13
|
-
*/
|
|
14
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
15
|
-
// CORE RUNTIME - Re-exported from @nexart/codemode-sdk (npm package)
|
|
16
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
17
|
-
export { executeCodeMode, validateCodeModeSource, DEFAULT_CONFIG, PROTOCOL_IDENTITY, } from '@nexart/codemode-sdk';
|
|
18
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
19
|
-
// LOCAL P5 RUNTIME - Used by app integrations (SoundArt, Noise)
|
|
20
|
-
// The npm package also exports createP5Runtime, but we keep local for
|
|
21
|
-
// app-specific extensions that need tighter integration
|
|
22
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
23
|
-
export { createP5Runtime, injectTimeVariables, injectProtocolVariables, createProtocolVAR } from './p5-runtime';
|
|
24
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
25
|
-
// LEGACY ENGINE API (kept for backwards compatibility)
|
|
26
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
27
|
-
export { createEngine } from './engine';
|
|
28
|
-
export { DEFAULT_CONFIG as LOCAL_DEFAULT_CONFIG } from './types';
|
|
29
|
-
// SoundArt → Code Mode integration
|
|
30
|
-
export { renderSoundArtViaCodeMode, canRenderViaCodeMode, getCodeModeAvailableStyles, } from './soundart-engine';
|
|
31
|
-
export { createSoundSnapshot, createEmptySoundSnapshot, freezeSoundSnapshot, } from '../../shared/soundSnapshot';
|
|
32
|
-
export { injectSoundGlobals, createSoundGlobals, createEmptySoundGlobals, generateSoundPalette, inferGenreProfile, createSoundHelpers, } from './sound-bridge';
|
|
33
|
-
export { getSoundArtSketch, getAvailableSoundArtSketches, isSoundArtSketchAvailable, } from './soundart-sketches';
|
|
34
|
-
// Noise → Code Mode integration
|
|
35
|
-
export { renderNoiseViaCodeMode, compileNoiseSystem, canRenderNoiseViaCodeMode, } from './noise-engine';
|
|
36
|
-
export { createNoiseSnapshot, validateNoiseSnapshot, } from '../../shared/noiseSnapshot';
|
|
37
|
-
export { createNoiseGlobals, injectNoiseGlobals, } from './noise-bridge';
|
|
38
|
-
export { getNoiseSketch, getAvailableNoiseSketchNames, isValidNoiseSketch, } from './noise-sketches';
|
|
39
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
40
|
-
// BUILDER MANIFEST (v1.6.0) — Passive Attribution
|
|
41
|
-
//
|
|
42
|
-
// The Builder Manifest is a declaration of intent, not a capability.
|
|
43
|
-
// The SDK does not expose any API to read or inspect manifests.
|
|
44
|
-
//
|
|
45
|
-
// This is:
|
|
46
|
-
// - Declarative (write-only)
|
|
47
|
-
// - Optional (no errors if missing)
|
|
48
|
-
// - Non-enforced (no validation)
|
|
49
|
-
// - Non-rewarding (no incentives)
|
|
50
|
-
//
|
|
51
|
-
// There is NO SDK API to read manifests, NO validation, NO attribution
|
|
52
|
-
// logic, and NO tracking. Execution behavior is identical with or without
|
|
53
|
-
// a manifest registered.
|
|
54
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
55
|
-
export { registerBuilderManifest } from './builder-manifest';
|
|
56
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
57
|
-
// EXECUTION BOUNDARY (Internal — Not Exported)
|
|
58
|
-
//
|
|
59
|
-
// The execution sandbox blocks all external entropy sources at runtime.
|
|
60
|
-
// See EXECUTION_BOUNDARY.md for details.
|
|
61
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
62
|
-
// Note: FORBIDDEN_APIS and createSafeMath are NOT exported.
|
|
63
|
-
// They are internal implementation details used by the engines.
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Noise Bridge - Injects N.* globals into Code Mode runtime
|
|
3
|
-
*
|
|
4
|
-
* This is the bridge between NoiseSnapshot data and the Code Mode p5-runtime.
|
|
5
|
-
* It creates frozen N.* globals that noise sketches can access deterministically.
|
|
6
|
-
*
|
|
7
|
-
* Similar to sound-bridge.ts for SoundArt, but for Noise parameters.
|
|
8
|
-
*/
|
|
9
|
-
import type { NoiseSnapshot, NoiseBlendMode } from '../../shared/noiseSnapshot';
|
|
10
|
-
/**
|
|
11
|
-
* The N.* global object type for noise sketches
|
|
12
|
-
*/
|
|
13
|
-
export interface NoiseGlobals {
|
|
14
|
-
scale: number;
|
|
15
|
-
octaves: number;
|
|
16
|
-
persistence: number;
|
|
17
|
-
lacunarity: number;
|
|
18
|
-
cellDensity: number;
|
|
19
|
-
cellDistortion: number;
|
|
20
|
-
blendMode: NoiseBlendMode;
|
|
21
|
-
isPerlinOnly: boolean;
|
|
22
|
-
isBlend: boolean;
|
|
23
|
-
isWarp: boolean;
|
|
24
|
-
isInterleave: boolean;
|
|
25
|
-
bgR: number;
|
|
26
|
-
bgG: number;
|
|
27
|
-
bgB: number;
|
|
28
|
-
noiseR: number;
|
|
29
|
-
noiseG: number;
|
|
30
|
-
noiseB: number;
|
|
31
|
-
seed: number;
|
|
32
|
-
zoom: number;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create N.* globals from a NoiseSnapshot
|
|
36
|
-
*/
|
|
37
|
-
export declare function createNoiseGlobals(snapshot: NoiseSnapshot): NoiseGlobals;
|
|
38
|
-
/**
|
|
39
|
-
* Inject N.* globals into code string
|
|
40
|
-
*
|
|
41
|
-
* This wraps the sketch code with N.* variable declarations
|
|
42
|
-
*/
|
|
43
|
-
export declare function injectNoiseGlobals(sketchCode: string, globals: NoiseGlobals): string;
|
|
44
|
-
//# sourceMappingURL=noise-bridge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"noise-bridge.d.ts","sourceRoot":"","sources":["../../../noise-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,YAAY;IAE3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IAGnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IAGvB,SAAS,EAAE,cAAc,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IAGtB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IAGf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,GAAG,YAAY,CAsBxE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CA6BpF"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Noise Bridge - Injects N.* globals into Code Mode runtime
|
|
3
|
-
*
|
|
4
|
-
* This is the bridge between NoiseSnapshot data and the Code Mode p5-runtime.
|
|
5
|
-
* It creates frozen N.* globals that noise sketches can access deterministically.
|
|
6
|
-
*
|
|
7
|
-
* Similar to sound-bridge.ts for SoundArt, but for Noise parameters.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Create N.* globals from a NoiseSnapshot
|
|
11
|
-
*/
|
|
12
|
-
export function createNoiseGlobals(snapshot) {
|
|
13
|
-
return Object.freeze({
|
|
14
|
-
scale: snapshot.scale,
|
|
15
|
-
octaves: snapshot.octaves,
|
|
16
|
-
persistence: snapshot.persistence,
|
|
17
|
-
lacunarity: snapshot.lacunarity,
|
|
18
|
-
cellDensity: snapshot.cellDensity,
|
|
19
|
-
cellDistortion: snapshot.cellDistortion,
|
|
20
|
-
blendMode: snapshot.blendMode,
|
|
21
|
-
isPerlinOnly: snapshot.blendMode === 'perlin_only',
|
|
22
|
-
isBlend: snapshot.blendMode === 'blend',
|
|
23
|
-
isWarp: snapshot.blendMode === 'warp',
|
|
24
|
-
isInterleave: snapshot.blendMode === 'interleave',
|
|
25
|
-
bgR: snapshot.bgR,
|
|
26
|
-
bgG: snapshot.bgG,
|
|
27
|
-
bgB: snapshot.bgB,
|
|
28
|
-
noiseR: snapshot.noiseR,
|
|
29
|
-
noiseG: snapshot.noiseG,
|
|
30
|
-
noiseB: snapshot.noiseB,
|
|
31
|
-
seed: snapshot.seed,
|
|
32
|
-
zoom: snapshot.zoomLevel,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Inject N.* globals into code string
|
|
37
|
-
*
|
|
38
|
-
* This wraps the sketch code with N.* variable declarations
|
|
39
|
-
*/
|
|
40
|
-
export function injectNoiseGlobals(sketchCode, globals) {
|
|
41
|
-
const injection = `
|
|
42
|
-
// === Injected Noise Globals (N.*) ===
|
|
43
|
-
const N = Object.freeze({
|
|
44
|
-
scale: ${globals.scale},
|
|
45
|
-
octaves: ${globals.octaves},
|
|
46
|
-
persistence: ${globals.persistence},
|
|
47
|
-
lacunarity: ${globals.lacunarity},
|
|
48
|
-
cellDensity: ${globals.cellDensity},
|
|
49
|
-
cellDistortion: ${globals.cellDistortion},
|
|
50
|
-
blendMode: '${globals.blendMode}',
|
|
51
|
-
isPerlinOnly: ${globals.isPerlinOnly},
|
|
52
|
-
isBlend: ${globals.isBlend},
|
|
53
|
-
isWarp: ${globals.isWarp},
|
|
54
|
-
isInterleave: ${globals.isInterleave},
|
|
55
|
-
bgR: ${globals.bgR},
|
|
56
|
-
bgG: ${globals.bgG},
|
|
57
|
-
bgB: ${globals.bgB},
|
|
58
|
-
noiseR: ${globals.noiseR},
|
|
59
|
-
noiseG: ${globals.noiseG},
|
|
60
|
-
noiseB: ${globals.noiseB},
|
|
61
|
-
seed: ${globals.seed},
|
|
62
|
-
zoom: ${globals.zoom}
|
|
63
|
-
});
|
|
64
|
-
// === End Injected Globals ===
|
|
65
|
-
|
|
66
|
-
`;
|
|
67
|
-
return injection + sketchCode;
|
|
68
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Noise → Code Mode Engine
|
|
3
|
-
*
|
|
4
|
-
* This is the orchestrator that runs Noise rendering through the Code Mode engine.
|
|
5
|
-
* It replaces the legacy p5.js-based NoiseCanvas with a protocol-compliant pipeline.
|
|
6
|
-
*
|
|
7
|
-
* Architecture:
|
|
8
|
-
* 1. NoiseParams from UI state
|
|
9
|
-
* 2. NoiseParams → NoiseSnapshot conversion
|
|
10
|
-
* 3. NoiseSnapshot injected as N.* globals into Code Mode
|
|
11
|
-
* 4. Noise sketch executed via Code Mode runtime
|
|
12
|
-
* 5. Result: PNG output (deterministic)
|
|
13
|
-
*/
|
|
14
|
-
import type { NoiseSnapshot, NoiseParams } from '../../shared/noiseSnapshot';
|
|
15
|
-
export interface NoiseEngineConfig {
|
|
16
|
-
width: number;
|
|
17
|
-
height: number;
|
|
18
|
-
seed: number;
|
|
19
|
-
}
|
|
20
|
-
export interface NoiseRenderOptions {
|
|
21
|
-
params: NoiseParams;
|
|
22
|
-
canvas: HTMLCanvasElement;
|
|
23
|
-
config: NoiseEngineConfig;
|
|
24
|
-
onProgress?: (progress: number) => void;
|
|
25
|
-
}
|
|
26
|
-
export interface NoiseRenderResult {
|
|
27
|
-
mode: 'noise';
|
|
28
|
-
snapshot: NoiseSnapshot;
|
|
29
|
-
metadata: NoiseMetadata;
|
|
30
|
-
}
|
|
31
|
-
export interface NoiseMetadata {
|
|
32
|
-
mode: 'Noise';
|
|
33
|
-
timestamp: string;
|
|
34
|
-
enforcement: 'hard';
|
|
35
|
-
renderedVia: 'codemode';
|
|
36
|
-
noiseParams: {
|
|
37
|
-
scale: number;
|
|
38
|
-
octaves: number;
|
|
39
|
-
persistence: number;
|
|
40
|
-
lacunarity: number;
|
|
41
|
-
cellDensity: number;
|
|
42
|
-
cellDistortion: number;
|
|
43
|
-
blendMode: string;
|
|
44
|
-
};
|
|
45
|
-
generationParams: {
|
|
46
|
-
seed: number;
|
|
47
|
-
canvasSize: {
|
|
48
|
-
width: number;
|
|
49
|
-
height: number;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Render noise via Code Mode runtime
|
|
55
|
-
*
|
|
56
|
-
* This is the main entry point for protocol-compliant noise rendering.
|
|
57
|
-
* All rendering goes through the Code Mode runtime for determinism.
|
|
58
|
-
*/
|
|
59
|
-
export declare function renderNoiseViaCodeMode(options: NoiseRenderOptions): Promise<NoiseRenderResult>;
|
|
60
|
-
/**
|
|
61
|
-
* Compile noise params to a Code Mode system
|
|
62
|
-
* This produces a reproducible system definition
|
|
63
|
-
*/
|
|
64
|
-
export declare function compileNoiseSystem(params: NoiseParams): {
|
|
65
|
-
sketchCode: string;
|
|
66
|
-
snapshot: NoiseSnapshot;
|
|
67
|
-
seed: number;
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Check if noise can be rendered via Code Mode
|
|
71
|
-
* (Always true - no legacy fallback)
|
|
72
|
-
*/
|
|
73
|
-
export declare function canRenderNoiseViaCodeMode(): boolean;
|
|
74
|
-
//# sourceMappingURL=noise-engine.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"noise-engine.d.ts","sourceRoot":"","sources":["../../../noise-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAM7E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;IACxB,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,gBAAgB,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/C,CAAC;CACH;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAsF5B;AAwBD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd,CAUA;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,OAAO,CAEnD"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Noise → Code Mode Engine
|
|
3
|
-
*
|
|
4
|
-
* This is the orchestrator that runs Noise rendering through the Code Mode engine.
|
|
5
|
-
* It replaces the legacy p5.js-based NoiseCanvas with a protocol-compliant pipeline.
|
|
6
|
-
*
|
|
7
|
-
* Architecture:
|
|
8
|
-
* 1. NoiseParams from UI state
|
|
9
|
-
* 2. NoiseParams → NoiseSnapshot conversion
|
|
10
|
-
* 3. NoiseSnapshot injected as N.* globals into Code Mode
|
|
11
|
-
* 4. Noise sketch executed via Code Mode runtime
|
|
12
|
-
* 5. Result: PNG output (deterministic)
|
|
13
|
-
*/
|
|
14
|
-
import { createNoiseSnapshot, validateNoiseSnapshot } from '../../shared/noiseSnapshot';
|
|
15
|
-
import { createP5Runtime } from './p5-runtime';
|
|
16
|
-
import { createNoiseGlobals, injectNoiseGlobals } from './noise-bridge';
|
|
17
|
-
import { getNoiseSketch } from './noise-sketches';
|
|
18
|
-
/**
|
|
19
|
-
* Render noise via Code Mode runtime
|
|
20
|
-
*
|
|
21
|
-
* This is the main entry point for protocol-compliant noise rendering.
|
|
22
|
-
* All rendering goes through the Code Mode runtime for determinism.
|
|
23
|
-
*/
|
|
24
|
-
export async function renderNoiseViaCodeMode(options) {
|
|
25
|
-
const { params, canvas, config, onProgress } = options;
|
|
26
|
-
// Protocol enforcement logging
|
|
27
|
-
console.log('[Noise] Protocol enforcement: HARD | renderedVia: codemode');
|
|
28
|
-
onProgress?.(0.1);
|
|
29
|
-
// Create and validate snapshot
|
|
30
|
-
const rawSnapshot = createNoiseSnapshot(params);
|
|
31
|
-
const snapshot = validateNoiseSnapshot(rawSnapshot);
|
|
32
|
-
onProgress?.(0.2);
|
|
33
|
-
// Create N.* globals
|
|
34
|
-
const noiseGlobals = createNoiseGlobals(snapshot);
|
|
35
|
-
// Get the noise sketch
|
|
36
|
-
const sketchName = 'fractalNoise';
|
|
37
|
-
const sketchCode = getNoiseSketch(sketchName);
|
|
38
|
-
// Inject N.* globals into sketch
|
|
39
|
-
const injectedCode = injectNoiseGlobals(sketchCode, noiseGlobals);
|
|
40
|
-
onProgress?.(0.3);
|
|
41
|
-
// Set canvas dimensions
|
|
42
|
-
canvas.width = config.width;
|
|
43
|
-
canvas.height = config.height;
|
|
44
|
-
// Create P5 runtime with correct signature
|
|
45
|
-
const runtimeConfig = {
|
|
46
|
-
seed: config.seed,
|
|
47
|
-
};
|
|
48
|
-
const runtime = createP5Runtime(canvas, config.width, config.height, runtimeConfig);
|
|
49
|
-
onProgress?.(0.5);
|
|
50
|
-
// Build globals with all runtime functions and noise globals
|
|
51
|
-
const globals = {
|
|
52
|
-
...runtime,
|
|
53
|
-
width: config.width,
|
|
54
|
-
height: config.height,
|
|
55
|
-
};
|
|
56
|
-
// Execute the sketch
|
|
57
|
-
try {
|
|
58
|
-
executeNoiseSketch(injectedCode, globals);
|
|
59
|
-
onProgress?.(0.9);
|
|
60
|
-
console.log('[Noise] Rendered via Code Mode runtime');
|
|
61
|
-
// Build metadata
|
|
62
|
-
const metadata = {
|
|
63
|
-
mode: 'Noise',
|
|
64
|
-
timestamp: new Date().toISOString(),
|
|
65
|
-
enforcement: 'hard',
|
|
66
|
-
renderedVia: 'codemode',
|
|
67
|
-
noiseParams: {
|
|
68
|
-
scale: snapshot.scale,
|
|
69
|
-
octaves: snapshot.octaves,
|
|
70
|
-
persistence: snapshot.persistence,
|
|
71
|
-
lacunarity: snapshot.lacunarity,
|
|
72
|
-
cellDensity: snapshot.cellDensity,
|
|
73
|
-
cellDistortion: snapshot.cellDistortion,
|
|
74
|
-
blendMode: snapshot.blendMode,
|
|
75
|
-
},
|
|
76
|
-
generationParams: {
|
|
77
|
-
seed: config.seed,
|
|
78
|
-
canvasSize: { width: config.width, height: config.height },
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
onProgress?.(1.0);
|
|
82
|
-
return {
|
|
83
|
-
mode: 'noise',
|
|
84
|
-
snapshot,
|
|
85
|
-
metadata,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
89
|
-
console.error('[Noise] Code Mode execution failed:', error);
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Execute a noise sketch string in the context of the runtime globals
|
|
95
|
-
*/
|
|
96
|
-
function executeNoiseSketch(code, globals) {
|
|
97
|
-
const globalNames = Object.keys(globals);
|
|
98
|
-
const globalValues = Object.values(globals);
|
|
99
|
-
// Wrap the sketch code to call setup()
|
|
100
|
-
const wrappedCode = `
|
|
101
|
-
${code}
|
|
102
|
-
|
|
103
|
-
// Execute setup (noise is static - single frame)
|
|
104
|
-
if (typeof setup === 'function') {
|
|
105
|
-
setup();
|
|
106
|
-
}
|
|
107
|
-
`;
|
|
108
|
-
// Create and execute the function
|
|
109
|
-
const sketchFunction = new Function(...globalNames, wrappedCode);
|
|
110
|
-
sketchFunction(...globalValues);
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Compile noise params to a Code Mode system
|
|
114
|
-
* This produces a reproducible system definition
|
|
115
|
-
*/
|
|
116
|
-
export function compileNoiseSystem(params) {
|
|
117
|
-
const snapshot = validateNoiseSnapshot(createNoiseSnapshot(params));
|
|
118
|
-
const noiseGlobals = createNoiseGlobals(snapshot);
|
|
119
|
-
const sketchCode = injectNoiseGlobals(getNoiseSketch('fractalNoise'), noiseGlobals);
|
|
120
|
-
return {
|
|
121
|
-
sketchCode,
|
|
122
|
-
snapshot,
|
|
123
|
-
seed: params.seed,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Check if noise can be rendered via Code Mode
|
|
128
|
-
* (Always true - no legacy fallback)
|
|
129
|
-
*/
|
|
130
|
-
export function canRenderNoiseViaCodeMode() {
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fractal Noise - Code Mode Sketch
|
|
3
|
-
*
|
|
4
|
-
* This sketch implements Perlin FBM and Cellular noise rendering
|
|
5
|
-
* through the Code Mode p5-runtime. Uses N.* globals for all parameters.
|
|
6
|
-
*
|
|
7
|
-
* Original: client/src/components/noise-canvas-simple.tsx
|
|
8
|
-
*/
|
|
9
|
-
export declare const FRACTAL_NOISE_SKETCH = "\n// Fractal Noise - Code Mode Sketch\n// Uses N.* noise globals and standard p5-like functions\n\nfunction setup() {\n // Set seeded random for reproducibility\n randomSeed(N.seed);\n noiseSeed(N.seed);\n \n // Set background color\n background(N.bgR, N.bgG, N.bgB);\n \n // Noise rendering parameters\n const adjustedScale = N.scale * (1 / N.zoom) * 0.05;\n const cellSize = 4; // Fixed for quality\n \n // Generate cellular points if needed\n const numPoints = Math.floor(20 + N.cellDensity * 180);\n const cellPoints = [];\n for (let i = 0; i < numPoints; i++) {\n cellPoints.push([random(0, width), random(0, height)]);\n }\n \n // Helper: Perlin FBM (Fractional Brownian Motion)\n function perlinFBM(x, y, scale) {\n let value = 0;\n let amplitude = 1;\n let frequency = 1;\n let maxValue = 0;\n \n const oct = Math.min(N.octaves, 6); // Cap for performance\n \n for (let i = 0; i < oct; i++) {\n value += noise(x * scale * frequency, y * scale * frequency) * amplitude;\n maxValue += amplitude;\n amplitude *= N.persistence;\n frequency *= N.lacunarity;\n }\n \n return value / maxValue;\n }\n \n // Helper: Cellular noise (Worley)\n function cellularNoise(x, y, points) {\n let sampleX = x;\n let sampleY = y;\n \n // Warp distortion if using warp mode\n if (N.isWarp && N.cellDistortion > 0) {\n const distortionAmount = N.cellDistortion * 100;\n sampleX += noise(x * 0.01, y * 0.01) * distortionAmount;\n sampleY += noise(y * 0.01, x * 0.01) * distortionAmount;\n }\n \n // Find distances to closest points\n let minDist = 999999;\n let secondMinDist = 999999;\n \n for (let i = 0; i < points.length; i++) {\n const px = points[i][0];\n const py = points[i][1];\n const dx = sampleX - px;\n const dy = sampleY - py;\n const dist = Math.sqrt(dx * dx + dy * dy);\n \n if (dist < minDist) {\n secondMinDist = minDist;\n minDist = dist;\n } else if (dist < secondMinDist) {\n secondMinDist = dist;\n }\n }\n \n // Normalize distance\n return Math.min(1.0, (secondMinDist - minDist) / 50);\n }\n \n // Render the noise grid\n noStroke();\n \n for (let y = 0; y < height; y += cellSize) {\n for (let x = 0; x < width; x += cellSize) {\n // Calculate Perlin value\n const perlinValue = perlinFBM(x, y, adjustedScale);\n \n // Calculate final value based on blend mode\n let finalValue = perlinValue;\n \n if (!N.isPerlinOnly) {\n const cellValue = cellularNoise(x, y, cellPoints);\n \n if (N.isBlend) {\n finalValue = perlinValue * cellValue;\n } else if (N.isWarp) {\n finalValue = (perlinValue + cellValue) / 2;\n } else if (N.isInterleave) {\n finalValue = (Math.floor(x / 20) + Math.floor(y / 20)) % 2 === 0\n ? perlinValue\n : cellValue;\n }\n }\n \n // Set opacity based on noise value\n const alpha = map(finalValue, 0, 1, 0, 255);\n \n // Fill with noise color and calculated alpha\n fill(N.noiseR, N.noiseG, N.noiseB, alpha);\n rect(x, y, cellSize, cellSize);\n }\n }\n}\n";
|
|
10
|
-
export default FRACTAL_NOISE_SKETCH;
|
|
11
|
-
//# sourceMappingURL=fractalNoise.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fractalNoise.d.ts","sourceRoot":"","sources":["../../../../noise-sketches/fractalNoise.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,oBAAoB,4sGA+GhC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fractal Noise - Code Mode Sketch
|
|
3
|
-
*
|
|
4
|
-
* This sketch implements Perlin FBM and Cellular noise rendering
|
|
5
|
-
* through the Code Mode p5-runtime. Uses N.* globals for all parameters.
|
|
6
|
-
*
|
|
7
|
-
* Original: client/src/components/noise-canvas-simple.tsx
|
|
8
|
-
*/
|
|
9
|
-
export const FRACTAL_NOISE_SKETCH = `
|
|
10
|
-
// Fractal Noise - Code Mode Sketch
|
|
11
|
-
// Uses N.* noise globals and standard p5-like functions
|
|
12
|
-
|
|
13
|
-
function setup() {
|
|
14
|
-
// Set seeded random for reproducibility
|
|
15
|
-
randomSeed(N.seed);
|
|
16
|
-
noiseSeed(N.seed);
|
|
17
|
-
|
|
18
|
-
// Set background color
|
|
19
|
-
background(N.bgR, N.bgG, N.bgB);
|
|
20
|
-
|
|
21
|
-
// Noise rendering parameters
|
|
22
|
-
const adjustedScale = N.scale * (1 / N.zoom) * 0.05;
|
|
23
|
-
const cellSize = 4; // Fixed for quality
|
|
24
|
-
|
|
25
|
-
// Generate cellular points if needed
|
|
26
|
-
const numPoints = Math.floor(20 + N.cellDensity * 180);
|
|
27
|
-
const cellPoints = [];
|
|
28
|
-
for (let i = 0; i < numPoints; i++) {
|
|
29
|
-
cellPoints.push([random(0, width), random(0, height)]);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Helper: Perlin FBM (Fractional Brownian Motion)
|
|
33
|
-
function perlinFBM(x, y, scale) {
|
|
34
|
-
let value = 0;
|
|
35
|
-
let amplitude = 1;
|
|
36
|
-
let frequency = 1;
|
|
37
|
-
let maxValue = 0;
|
|
38
|
-
|
|
39
|
-
const oct = Math.min(N.octaves, 6); // Cap for performance
|
|
40
|
-
|
|
41
|
-
for (let i = 0; i < oct; i++) {
|
|
42
|
-
value += noise(x * scale * frequency, y * scale * frequency) * amplitude;
|
|
43
|
-
maxValue += amplitude;
|
|
44
|
-
amplitude *= N.persistence;
|
|
45
|
-
frequency *= N.lacunarity;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return value / maxValue;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Helper: Cellular noise (Worley)
|
|
52
|
-
function cellularNoise(x, y, points) {
|
|
53
|
-
let sampleX = x;
|
|
54
|
-
let sampleY = y;
|
|
55
|
-
|
|
56
|
-
// Warp distortion if using warp mode
|
|
57
|
-
if (N.isWarp && N.cellDistortion > 0) {
|
|
58
|
-
const distortionAmount = N.cellDistortion * 100;
|
|
59
|
-
sampleX += noise(x * 0.01, y * 0.01) * distortionAmount;
|
|
60
|
-
sampleY += noise(y * 0.01, x * 0.01) * distortionAmount;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Find distances to closest points
|
|
64
|
-
let minDist = 999999;
|
|
65
|
-
let secondMinDist = 999999;
|
|
66
|
-
|
|
67
|
-
for (let i = 0; i < points.length; i++) {
|
|
68
|
-
const px = points[i][0];
|
|
69
|
-
const py = points[i][1];
|
|
70
|
-
const dx = sampleX - px;
|
|
71
|
-
const dy = sampleY - py;
|
|
72
|
-
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
73
|
-
|
|
74
|
-
if (dist < minDist) {
|
|
75
|
-
secondMinDist = minDist;
|
|
76
|
-
minDist = dist;
|
|
77
|
-
} else if (dist < secondMinDist) {
|
|
78
|
-
secondMinDist = dist;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Normalize distance
|
|
83
|
-
return Math.min(1.0, (secondMinDist - minDist) / 50);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Render the noise grid
|
|
87
|
-
noStroke();
|
|
88
|
-
|
|
89
|
-
for (let y = 0; y < height; y += cellSize) {
|
|
90
|
-
for (let x = 0; x < width; x += cellSize) {
|
|
91
|
-
// Calculate Perlin value
|
|
92
|
-
const perlinValue = perlinFBM(x, y, adjustedScale);
|
|
93
|
-
|
|
94
|
-
// Calculate final value based on blend mode
|
|
95
|
-
let finalValue = perlinValue;
|
|
96
|
-
|
|
97
|
-
if (!N.isPerlinOnly) {
|
|
98
|
-
const cellValue = cellularNoise(x, y, cellPoints);
|
|
99
|
-
|
|
100
|
-
if (N.isBlend) {
|
|
101
|
-
finalValue = perlinValue * cellValue;
|
|
102
|
-
} else if (N.isWarp) {
|
|
103
|
-
finalValue = (perlinValue + cellValue) / 2;
|
|
104
|
-
} else if (N.isInterleave) {
|
|
105
|
-
finalValue = (Math.floor(x / 20) + Math.floor(y / 20)) % 2 === 0
|
|
106
|
-
? perlinValue
|
|
107
|
-
: cellValue;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Set opacity based on noise value
|
|
112
|
-
const alpha = map(finalValue, 0, 1, 0, 255);
|
|
113
|
-
|
|
114
|
-
// Fill with noise color and calculated alpha
|
|
115
|
-
fill(N.noiseR, N.noiseG, N.noiseB, alpha);
|
|
116
|
-
rect(x, y, cellSize, cellSize);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
`;
|
|
121
|
-
export default FRACTAL_NOISE_SKETCH;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Noise Sketches Index
|
|
3
|
-
*
|
|
4
|
-
* Exports all available noise sketch generators for the Code Mode runtime.
|
|
5
|
-
*/
|
|
6
|
-
import FRACTAL_NOISE_SKETCH from './fractalNoise';
|
|
7
|
-
export type NoiseSketchName = 'fractalNoise';
|
|
8
|
-
/**
|
|
9
|
-
* Get a noise sketch by name
|
|
10
|
-
*/
|
|
11
|
-
export declare function getNoiseSketch(name: NoiseSketchName): string;
|
|
12
|
-
/**
|
|
13
|
-
* Check if a sketch name is valid
|
|
14
|
-
*/
|
|
15
|
-
export declare function isValidNoiseSketch(name: string): name is NoiseSketchName;
|
|
16
|
-
/**
|
|
17
|
-
* Get list of all available noise sketch names
|
|
18
|
-
*/
|
|
19
|
-
export declare function getAvailableNoiseSketchNames(): NoiseSketchName[];
|
|
20
|
-
export { FRACTAL_NOISE_SKETCH };
|
|
21
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../noise-sketches/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,oBAAoB,MAAM,gBAAgB,CAAC;AAElD,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC;AAM7C;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAE5D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,eAAe,CAExE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,eAAe,EAAE,CAEhE;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Noise Sketches Index
|
|
3
|
-
*
|
|
4
|
-
* Exports all available noise sketch generators for the Code Mode runtime.
|
|
5
|
-
*/
|
|
6
|
-
import FRACTAL_NOISE_SKETCH from './fractalNoise';
|
|
7
|
-
const NOISE_SKETCHES = {
|
|
8
|
-
fractalNoise: FRACTAL_NOISE_SKETCH,
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Get a noise sketch by name
|
|
12
|
-
*/
|
|
13
|
-
export function getNoiseSketch(name) {
|
|
14
|
-
return NOISE_SKETCHES[name];
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Check if a sketch name is valid
|
|
18
|
-
*/
|
|
19
|
-
export function isValidNoiseSketch(name) {
|
|
20
|
-
return name in NOISE_SKETCHES;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Get list of all available noise sketch names
|
|
24
|
-
*/
|
|
25
|
-
export function getAvailableNoiseSketchNames() {
|
|
26
|
-
return Object.keys(NOISE_SKETCHES);
|
|
27
|
-
}
|
|
28
|
-
export { FRACTAL_NOISE_SKETCH };
|