@nexart/ui-renderer 0.2.1 → 0.3.1

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.
Files changed (38) hide show
  1. package/README.md +78 -4
  2. package/dist/compiler.d.ts +18 -2
  3. package/dist/compiler.d.ts.map +1 -1
  4. package/dist/compiler.js +25 -11
  5. package/dist/index.d.ts +19 -8
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +18 -7
  8. package/dist/presets/backgrounds.d.ts +14 -0
  9. package/dist/presets/backgrounds.d.ts.map +1 -0
  10. package/dist/presets/backgrounds.js +222 -0
  11. package/dist/presets/index.d.ts +7 -0
  12. package/dist/presets/index.d.ts.map +1 -0
  13. package/dist/presets/index.js +6 -0
  14. package/dist/presets/primitives.d.ts +16 -0
  15. package/dist/presets/primitives.d.ts.map +1 -0
  16. package/dist/presets/primitives.js +282 -0
  17. package/dist/presets/sketch-wrapper.d.ts +14 -0
  18. package/dist/presets/sketch-wrapper.d.ts.map +1 -0
  19. package/dist/presets/sketch-wrapper.js +70 -0
  20. package/dist/preview/code-renderer.d.ts +25 -0
  21. package/dist/preview/code-renderer.d.ts.map +1 -0
  22. package/dist/preview/code-renderer.js +651 -0
  23. package/dist/preview/primitives/sketch.d.ts +14 -0
  24. package/dist/preview/primitives/sketch.d.ts.map +1 -0
  25. package/dist/preview/primitives/sketch.js +407 -0
  26. package/dist/preview/renderer.d.ts +1 -1
  27. package/dist/preview/renderer.d.ts.map +1 -1
  28. package/dist/preview/renderer.js +23 -13
  29. package/dist/preview/unified-renderer.d.ts +16 -0
  30. package/dist/preview/unified-renderer.d.ts.map +1 -0
  31. package/dist/preview/unified-renderer.js +270 -0
  32. package/dist/system.d.ts +7 -3
  33. package/dist/system.d.ts.map +1 -1
  34. package/dist/system.js +187 -11
  35. package/dist/types.d.ts +125 -5
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/types.js +12 -3
  38. package/package.json +2 -2
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @nexart/ui-renderer
2
2
 
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
 
5
- **Declarative System Authoring SDK for NexArt Protocol**
5
+ **Declarative and Code Mode System Authoring SDK for NexArt Protocol**
6
6
 
7
7
  ---
8
8
 
@@ -51,6 +51,66 @@ Or use directly in HTML:
51
51
 
52
52
  ## Quick Start
53
53
 
54
+ ### Code Mode Systems (v0.3+)
55
+
56
+ Create and preview Code Mode sketches with deterministic rendering:
57
+
58
+ ```typescript
59
+ import { createSystem, previewSystem } from '@nexart/ui-renderer';
60
+
61
+ const system = createSystem({
62
+ type: 'code',
63
+ mode: 'loop',
64
+ width: 1950,
65
+ height: 2400,
66
+ totalFrames: 120,
67
+ seed: 12345,
68
+ source: `
69
+ function setup() {
70
+ noFill();
71
+ stroke(0);
72
+ }
73
+ function draw() {
74
+ background(246, 245, 242);
75
+ for (var i = 0; i < 10; i++) {
76
+ var x = width / 2 + cos(t * TWO_PI + i * 0.5) * 200;
77
+ var y = height / 2 + sin(t * TWO_PI + i * 0.3) * 200;
78
+ ellipse(x, y, 50);
79
+ }
80
+ }
81
+ `
82
+ });
83
+
84
+ const canvas = document.getElementById('canvas');
85
+ const renderer = previewSystem(system, canvas);
86
+ renderer.start();
87
+ ```
88
+
89
+ **Static Mode** (single-frame, setup only):
90
+
91
+ ```typescript
92
+ const staticSystem = createSystem({
93
+ type: 'code',
94
+ mode: 'static',
95
+ width: 1950,
96
+ height: 2400,
97
+ seed: 12345,
98
+ source: `
99
+ function setup() {
100
+ background(246, 245, 242);
101
+ fill(0);
102
+ for (var i = 0; i < 100; i++) {
103
+ ellipse(random(width), random(height), random(10, 50));
104
+ }
105
+ }
106
+ `
107
+ });
108
+
109
+ previewSystem(staticSystem, canvas).render();
110
+ ```
111
+
112
+ ### Declarative Systems
113
+
54
114
  ### 1. Create a System
55
115
 
56
116
  ```typescript
@@ -111,9 +171,23 @@ console.log(JSON.stringify(compiled, null, 2));
111
171
 
112
172
  Create a validated NexArt system.
113
173
 
174
+ **Code Mode Input:**
175
+ ```typescript
176
+ const system = createSystem({
177
+ type: 'code',
178
+ mode: 'static' | 'loop',
179
+ width: number,
180
+ height: number,
181
+ source: string, // Raw p5-like sketch code
182
+ seed?: number, // Optional: PRNG seed
183
+ totalFrames?: number // Required for loop mode
184
+ });
185
+ ```
186
+
187
+ **Declarative Input:**
114
188
  ```typescript
115
189
  const system = createSystem({
116
- version?: string, // Protocol version (default: '0.2')
190
+ version?: string, // Protocol version (default: '0.3')
117
191
  seed: number, // Required: PRNG seed
118
192
  background: {
119
193
  color: string, // Required: background color
@@ -205,7 +279,7 @@ Use this to:
205
279
 
206
280
  ---
207
281
 
208
- ## Primitive Vocabulary (v0.2)
282
+ ## Primitive Vocabulary (v0.3)
209
283
 
210
284
  ### Elements
211
285
 
@@ -1,11 +1,12 @@
1
1
  /**
2
- * @nexart/ui-renderer v0.2.0 - System Compiler
2
+ * @nexart/ui-renderer v0.3.0 - System Compiler
3
3
  *
4
4
  * Compiles validated systems into canonical protocol-compatible JSON.
5
5
  */
6
6
  import type { NexArtSystem } from './types';
7
- export interface CompiledSystem {
7
+ export interface CompiledDeclarativeSystem {
8
8
  protocol: 'nexart';
9
+ systemType: 'declarative';
9
10
  systemVersion: string;
10
11
  seed: number;
11
12
  background: {
@@ -29,6 +30,21 @@ export interface CompiledSystem {
29
30
  compiledAt: string;
30
31
  compilerVersion: string;
31
32
  }
33
+ export interface CompiledCodeSystem {
34
+ protocol: 'nexart';
35
+ systemType: 'code';
36
+ systemVersion: string;
37
+ source: string;
38
+ mode: 'static' | 'loop';
39
+ width: number;
40
+ height: number;
41
+ seed: number;
42
+ totalFrames?: number;
43
+ deterministic: boolean;
44
+ compiledAt: string;
45
+ compilerVersion: string;
46
+ }
47
+ export type CompiledSystem = CompiledDeclarativeSystem | CompiledCodeSystem;
32
48
  export declare function compileSystem(system: NexArtSystem): CompiledSystem;
33
49
  export declare function serializeSystem(system: NexArtSystem): string;
34
50
  //# sourceMappingURL=compiler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,SAAS,CAAC;AAG3D,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE;YACT,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,EAAE,MAAM,EAAE,CAAC;YACjB,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC;IACF,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC,CAAC;IACH,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACzB;AAID,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc,CAyClE;AAuCD,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAG5D"}
1
+ {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAsD,MAAM,SAAS,CAAC;AAGhG,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,aAAa,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IAC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.0 - System Compiler
2
+ * @nexart/ui-renderer v0.3.0 - System Compiler
3
3
  *
4
4
  * Compiles validated systems into canonical protocol-compatible JSON.
5
5
  */
6
- import { validateSystem } from './system';
7
- const COMPILER_VERSION = '0.2.0';
6
+ import { isCodeModeSystem } from './system';
7
+ const COMPILER_VERSION = '0.3.0';
8
8
  export function compileSystem(system) {
9
- const validation = validateSystem({
10
- seed: system.seed,
11
- background: system.background,
12
- elements: system.elements,
13
- motion: system.motion,
14
- });
15
- if (!validation.valid) {
16
- throw new Error(`Cannot compile invalid system: ${validation.errors.join('; ')}`);
9
+ if (isCodeModeSystem(system)) {
10
+ return compileCodeSystem(system);
17
11
  }
12
+ return compileDeclarativeSystem(system);
13
+ }
14
+ function compileCodeSystem(system) {
15
+ return {
16
+ protocol: 'nexart',
17
+ systemType: 'code',
18
+ systemVersion: system.systemVersion,
19
+ source: system.source,
20
+ mode: system.mode,
21
+ width: system.width,
22
+ height: system.height,
23
+ seed: system.seed,
24
+ ...(system.totalFrames !== undefined && { totalFrames: system.totalFrames }),
25
+ deterministic: true,
26
+ compiledAt: new Date().toISOString(),
27
+ compilerVersion: COMPILER_VERSION,
28
+ };
29
+ }
30
+ function compileDeclarativeSystem(system) {
18
31
  const compiled = {
19
32
  protocol: 'nexart',
33
+ systemType: 'declarative',
20
34
  systemVersion: system.systemVersion,
21
35
  seed: system.seed,
22
36
  background: {
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @nexart/ui-renderer
3
- * Version: 0.2.0
3
+ * Version: 0.4.0
4
4
  *
5
- * Declarative System Authoring SDK for NexArt Protocol
5
+ * Opinionated Generative Design System SDK for NexArt Protocol
6
6
  *
7
7
  * ⚠️ IMPORTANT DISCLAIMER
8
8
  *
@@ -15,19 +15,30 @@
15
15
  * - NOT protocol-authoritative
16
16
  *
17
17
  * Use it for:
18
- * - Creating NexArt systems declaratively
18
+ * - Creating NexArt systems with background/primitive/sketch elements
19
19
  * - Previewing systems in the browser
20
- * - Compiling systems to protocol-compatible JSON
20
+ * - Building AI-friendly generative backgrounds
21
21
  * - Building platforms, tools, and integrations
22
+ *
23
+ * Design Philosophy:
24
+ * - Beauty by default > unlimited freedom
25
+ * - Aesthetic guardrails ensure pleasing output automatically
26
+ * - All elements compile to Code Mode for deterministic rendering
22
27
  */
23
- export { createSystem, validateSystem } from './system';
28
+ export { createSystem, validateSystem, isCodeModeSystem, isDeclarativeSystem, isUnifiedModeSystem } from './system';
24
29
  export { compileSystem, serializeSystem } from './compiler';
25
30
  export { previewSystem } from './preview/renderer';
31
+ export { renderCodeModeSystem } from './preview/code-renderer';
32
+ export { renderUnifiedSystem } from './preview/unified-renderer';
33
+ export { compileBackgroundPreset, getPaletteColors } from './presets/backgrounds';
34
+ export { compilePrimitive } from './presets/primitives';
35
+ export { wrapSketch, validateSketchSafety } from './presets/sketch-wrapper';
26
36
  export { getCapabilities, getPrimitiveTypes, getMotionSources, getBackgroundTextures, } from './capabilities';
27
- export type { NexArtSystemInput, NexArtSystem, SystemElement, DotsElement, LinesElement, WavesElement, GridElement, FlowFieldElement, OrbitsElement, BackgroundConfig, MotionConfig, PreviewOptions, ValidationResult, } from './types';
37
+ export type { NexArtSystemInput, NexArtSystem, DeclarativeSystemInput, DeclarativeSystem, CodeSystem, NexArtCodeSystem, UnifiedSystemInput, UnifiedSystem, UnifiedElement, BackgroundElement, PrimitiveElement, SketchElement, BackgroundPreset, PrimitiveName, ColorPalette, MotionSpeed, StrokeWeightAuto, LoopConfig, DeclarativeElement, SystemElement, DotsElement, LinesElement, WavesElement, GridElement, FlowFieldElement, OrbitsElement, BackgroundConfig, MotionConfig, PreviewOptions, ValidationResult, } from './types';
38
+ export { AESTHETIC_DEFAULTS, SDK_VERSION as TYPE_SDK_VERSION } from './types';
28
39
  export type { Capabilities, PrimitiveCapability, ParameterSpec, } from './capabilities';
29
- export declare const SDK_VERSION = "0.2.1";
30
- export declare const PROTOCOL_VERSION = "0.2";
40
+ export declare const SDK_VERSION = "0.4.0";
41
+ export declare const PROTOCOL_VERSION = "0.4";
31
42
  export declare const IS_CANONICAL = false;
32
43
  export declare const IS_ARCHIVAL = false;
33
44
  export declare const RENDERER = "@nexart/ui-renderer";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,YAAY,EACV,YAAY,EACZ,mBAAmB,EACnB,aAAa,GACd,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,WAAW,UAAU,CAAC;AACnC,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AACtC,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,WAAW,QAAQ,CAAC;AACjC,eAAO,MAAM,QAAQ,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE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@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @nexart/ui-renderer
3
- * Version: 0.2.0
3
+ * Version: 0.4.0
4
4
  *
5
- * Declarative System Authoring SDK for NexArt Protocol
5
+ * Opinionated Generative Design System SDK for NexArt Protocol
6
6
  *
7
7
  * ⚠️ IMPORTANT DISCLAIMER
8
8
  *
@@ -15,17 +15,28 @@
15
15
  * - NOT protocol-authoritative
16
16
  *
17
17
  * Use it for:
18
- * - Creating NexArt systems declaratively
18
+ * - Creating NexArt systems with background/primitive/sketch elements
19
19
  * - Previewing systems in the browser
20
- * - Compiling systems to protocol-compatible JSON
20
+ * - Building AI-friendly generative backgrounds
21
21
  * - Building platforms, tools, and integrations
22
+ *
23
+ * Design Philosophy:
24
+ * - Beauty by default > unlimited freedom
25
+ * - Aesthetic guardrails ensure pleasing output automatically
26
+ * - All elements compile to Code Mode for deterministic rendering
22
27
  */
23
- export { createSystem, validateSystem } from './system';
28
+ export { createSystem, validateSystem, isCodeModeSystem, isDeclarativeSystem, isUnifiedModeSystem } from './system';
24
29
  export { compileSystem, serializeSystem } from './compiler';
25
30
  export { previewSystem } from './preview/renderer';
31
+ export { renderCodeModeSystem } from './preview/code-renderer';
32
+ export { renderUnifiedSystem } from './preview/unified-renderer';
33
+ export { compileBackgroundPreset, getPaletteColors } from './presets/backgrounds';
34
+ export { compilePrimitive } from './presets/primitives';
35
+ export { wrapSketch, validateSketchSafety } from './presets/sketch-wrapper';
26
36
  export { getCapabilities, getPrimitiveTypes, getMotionSources, getBackgroundTextures, } from './capabilities';
27
- export const SDK_VERSION = '0.2.1';
28
- export const PROTOCOL_VERSION = '0.2';
37
+ export { AESTHETIC_DEFAULTS, SDK_VERSION as TYPE_SDK_VERSION } from './types';
38
+ export const SDK_VERSION = '0.4.0';
39
+ export const PROTOCOL_VERSION = '0.4';
29
40
  export const IS_CANONICAL = false;
30
41
  export const IS_ARCHIVAL = false;
31
42
  export const RENDERER = '@nexart/ui-renderer';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Background Presets - Compile to Code Mode sketches
3
+ * These are aesthetic-first presets that always look good
4
+ * All code uses p5-compatible APIs only
5
+ */
6
+ import { BackgroundPreset, ColorPalette, LoopConfig } from '../types';
7
+ export interface PresetColors {
8
+ background: string;
9
+ foreground: string;
10
+ accent?: string;
11
+ }
12
+ export declare function getPaletteColors(palette?: ColorPalette): PresetColors;
13
+ export declare function compileBackgroundPreset(preset: BackgroundPreset, palette?: ColorPalette, loop?: LoopConfig): string;
14
+ //# sourceMappingURL=backgrounds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backgrounds.d.ts","sourceRoot":"","sources":["../../src/presets/backgrounds.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAsB,MAAM,UAAU,CAAC;AAE1F,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,YAA8B,GAAG,YAAY,CA+BtF;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE,YAA8B,EACvC,IAAI,GAAE,UAAgE,GACrE,MAAM,CAkBR"}
@@ -0,0 +1,222 @@
1
+ /**
2
+ * Background Presets - Compile to Code Mode sketches
3
+ * These are aesthetic-first presets that always look good
4
+ * All code uses p5-compatible APIs only
5
+ */
6
+ import { AESTHETIC_DEFAULTS } from '../types';
7
+ export function getPaletteColors(palette = 'offwhite-dark') {
8
+ const palettes = {
9
+ 'offwhite-dark': {
10
+ background: 'rgb(246, 245, 242)',
11
+ foreground: 'rgb(45, 45, 45)',
12
+ },
13
+ 'midnight': {
14
+ background: 'rgb(18, 18, 24)',
15
+ foreground: 'rgb(200, 200, 210)',
16
+ },
17
+ 'warm-neutral': {
18
+ background: 'rgb(245, 240, 235)',
19
+ foreground: 'rgb(80, 60, 50)',
20
+ },
21
+ 'ocean': {
22
+ background: 'rgb(230, 240, 245)',
23
+ foreground: 'rgb(30, 60, 90)',
24
+ accent: 'rgb(60, 120, 180)',
25
+ },
26
+ 'sunset': {
27
+ background: 'rgb(255, 245, 235)',
28
+ foreground: 'rgb(120, 60, 40)',
29
+ accent: 'rgb(255, 140, 80)',
30
+ },
31
+ 'forest': {
32
+ background: 'rgb(235, 242, 235)',
33
+ foreground: 'rgb(40, 70, 50)',
34
+ accent: 'rgb(80, 140, 90)',
35
+ },
36
+ };
37
+ return palettes[palette];
38
+ }
39
+ export function compileBackgroundPreset(preset, palette = 'offwhite-dark', loop = { duration: AESTHETIC_DEFAULTS.loop.defaultFrames }) {
40
+ const colors = getPaletteColors(palette);
41
+ const totalFrames = loop.duration;
42
+ switch (preset) {
43
+ case 'layered-waves':
44
+ return generateLayeredWaves(colors, totalFrames);
45
+ case 'soft-noise-field':
46
+ return generateSoftNoiseField(colors, totalFrames);
47
+ case 'orbital-lines':
48
+ return generateOrbitalLines(colors, totalFrames);
49
+ case 'flowing-stripes':
50
+ return generateFlowingStripes(colors, totalFrames);
51
+ case 'minimal-grid':
52
+ return generateMinimalGrid(colors, totalFrames);
53
+ default:
54
+ return generateLayeredWaves(colors, totalFrames);
55
+ }
56
+ }
57
+ function generateLayeredWaves(colors, totalFrames) {
58
+ return `
59
+ function setup() {
60
+ noFill();
61
+ strokeWeight(1.5);
62
+ }
63
+
64
+ function draw() {
65
+ background('${colors.background}');
66
+ stroke('${colors.foreground}');
67
+
68
+ const margin = width * 0.08;
69
+ const waveCount = 8;
70
+ const waveSpacing = (height - margin * 2) / waveCount;
71
+
72
+ for (let i = 0; i < waveCount; i++) {
73
+ const y = margin + i * waveSpacing;
74
+ const phase = i * 0.3 + t * TWO_PI;
75
+ const amp = 15 + i * 5;
76
+
77
+ beginShape();
78
+ for (let x = margin; x <= width - margin; x += 3) {
79
+ const nx = (x - margin) / (width - margin * 2);
80
+ const wave = sin(nx * PI * 3 + phase) * amp;
81
+ const easeEdge = sin(nx * PI);
82
+ vertex(x, y + wave * easeEdge);
83
+ }
84
+ endShape();
85
+ }
86
+ }
87
+ `;
88
+ }
89
+ function generateSoftNoiseField(colors, totalFrames) {
90
+ return `
91
+ function setup() {
92
+ noStroke();
93
+ }
94
+
95
+ function draw() {
96
+ background('${colors.background}');
97
+
98
+ const margin = width * 0.08;
99
+ const dotSize = 3;
100
+ const spacing = 20;
101
+ const cols = floor((width - margin * 2) / spacing);
102
+ const rows = floor((height - margin * 2) / spacing);
103
+
104
+ for (let i = 0; i < cols; i++) {
105
+ for (let j = 0; j < rows; j++) {
106
+ const x = margin + i * spacing + spacing / 2;
107
+ const y = margin + j * spacing + spacing / 2;
108
+
109
+ const n = noise(i * 0.1, j * 0.1, t * 2);
110
+ const offsetX = (n - 0.5) * spacing * 0.6;
111
+ const offsetY = (noise(i * 0.1 + 100, j * 0.1, t * 2) - 0.5) * spacing * 0.6;
112
+
113
+ const alpha = map(n, 0, 1, 80, 200);
114
+ fill(red('${colors.foreground}'), green('${colors.foreground}'), blue('${colors.foreground}'), alpha);
115
+ ellipse(x + offsetX, y + offsetY, dotSize + n * 3);
116
+ }
117
+ }
118
+ }
119
+ `;
120
+ }
121
+ function generateOrbitalLines(colors, totalFrames) {
122
+ return `
123
+ function setup() {
124
+ noFill();
125
+ strokeWeight(1);
126
+ }
127
+
128
+ function draw() {
129
+ background('${colors.background}');
130
+ stroke('${colors.foreground}');
131
+
132
+ const cx = width / 2;
133
+ const cy = height / 2;
134
+ const maxRadius = min(width, height) * 0.4;
135
+ const orbitCount = 6;
136
+
137
+ for (let i = 0; i < orbitCount; i++) {
138
+ const radius = maxRadius * (0.3 + i * 0.12);
139
+ const rotation = t * TWO_PI * (0.5 + i * 0.1) * (i % 2 === 0 ? 1 : -1);
140
+
141
+ beginShape();
142
+ for (let a = 0; a <= TWO_PI; a += 0.05) {
143
+ const wobble = sin(a * 3 + t * TWO_PI + i) * 8;
144
+ const r = radius + wobble;
145
+ const x = cx + cos(a + rotation) * r;
146
+ const y = cy + sin(a + rotation) * r;
147
+ vertex(x, y);
148
+ }
149
+ endShape(CLOSE);
150
+ }
151
+ }
152
+ `;
153
+ }
154
+ function generateFlowingStripes(colors, totalFrames) {
155
+ return `
156
+ function setup() {
157
+ noFill();
158
+ strokeWeight(2);
159
+ }
160
+
161
+ function draw() {
162
+ background('${colors.background}');
163
+ stroke('${colors.foreground}');
164
+
165
+ const margin = width * 0.1;
166
+ const stripeCount = 12;
167
+ const stripeSpacing = (width - margin * 2) / stripeCount;
168
+
169
+ for (let i = 0; i < stripeCount; i++) {
170
+ const x = margin + i * stripeSpacing;
171
+ const phase = i * 0.2 + t * TWO_PI;
172
+
173
+ beginShape();
174
+ for (let y = margin; y <= height - margin; y += 4) {
175
+ const ny = (y - margin) / (height - margin * 2);
176
+ const wave = sin(ny * PI * 2 + phase) * 15;
177
+ const easeEdge = sin(ny * PI);
178
+ vertex(x + wave * easeEdge, y);
179
+ }
180
+ endShape();
181
+ }
182
+ }
183
+ `;
184
+ }
185
+ function generateMinimalGrid(colors, totalFrames) {
186
+ return `
187
+ function setup() {
188
+ rectMode(CENTER);
189
+ noFill();
190
+ strokeWeight(1);
191
+ }
192
+
193
+ function draw() {
194
+ background('${colors.background}');
195
+ stroke('${colors.foreground}');
196
+
197
+ const margin = width * 0.12;
198
+ const cols = 6;
199
+ const rows = 6;
200
+ const cellW = (width - margin * 2) / cols;
201
+ const cellH = (height - margin * 2) / rows;
202
+ const baseSize = min(cellW, cellH) * 0.5;
203
+
204
+ for (let i = 0; i < cols; i++) {
205
+ for (let j = 0; j < rows; j++) {
206
+ const x = margin + i * cellW + cellW / 2;
207
+ const y = margin + j * cellH + cellH / 2;
208
+
209
+ const n = noise(i * 0.3, j * 0.3, t * 1.5);
210
+ const size = baseSize * (0.5 + n * 0.5);
211
+ const rotation = n * PI * 0.25;
212
+
213
+ push();
214
+ translate(x, y);
215
+ rotate(rotation);
216
+ rect(0, 0, size, size);
217
+ pop();
218
+ }
219
+ }
220
+ }
221
+ `;
222
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Presets Index - Export all preset utilities
3
+ */
4
+ export { compileBackgroundPreset, getPaletteColors } from './backgrounds';
5
+ export { compilePrimitive } from './primitives';
6
+ export { wrapSketch, validateSketchSafety } from './sketch-wrapper';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/presets/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Presets Index - Export all preset utilities
3
+ */
4
+ export { compileBackgroundPreset, getPaletteColors } from './backgrounds';
5
+ export { compilePrimitive } from './primitives';
6
+ export { wrapSketch, validateSketchSafety } from './sketch-wrapper';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Primitive Elements - Safe ranges with aesthetic clamping
3
+ * Declarative blocks that compose well and always look tasteful
4
+ * All code uses p5-compatible APIs only (no globalAlpha, etc.)
5
+ */
6
+ import { PrimitiveName, MotionSpeed, StrokeWeightAuto } from '../types';
7
+ export interface PrimitiveConfig {
8
+ name: PrimitiveName;
9
+ count?: number;
10
+ strokeWeight?: StrokeWeightAuto;
11
+ motion?: MotionSpeed;
12
+ color?: string;
13
+ opacity?: number;
14
+ }
15
+ export declare function compilePrimitive(config: PrimitiveConfig, foreground?: string): string;
16
+ //# sourceMappingURL=primitives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/presets/primitives.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAsB,MAAM,UAAU,CAAC;AAE5F,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAsCD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,UAAU,GAAE,MAA0B,GAAG,MAAM,CA2BxG"}