You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Renderer adapters, skill registry, and runtime interfaces for genart.dev — a generative art platform with an MCP server, desktop app, and IDE extensions.
Re-exports everything from @genart-dev/format so consumers get the full format API without a separate import.
Install
npm install @genart-dev/core
Usage
import{createDefaultRegistry,createDefaultSkillRegistry,parseGenart,resolvePreset,}from"@genart-dev/core";// Set up renderer registry with all 5 adaptersconstrenderers=createDefaultRegistry();// Parse a .genart file and resolve its rendererconstsketch=parseGenart(JSON.parse(fileContents));constadapter=renderers.resolve(sketch.renderer.type);// → P5RendererAdapter// Validate an algorithm for a specific rendererconstresult=adapter.validate(sketch.algorithm);if(!result.valid){console.error(result.errors);}// Generate standalone HTML (embeds algorithm + CDN runtime)consthtml=adapter.generateStandaloneHTML(sketch);// Browse design knowledge skillsconstskills=createDefaultSkillRegistry();skills.list("composition");// → 6 composition skillsskills.list("color");// → 6 color skills
Renderer Adapters
Five pluggable rendering engines, each implementing the RendererAdapter interface:
Adapter
Type
Language
Runtime
Algorithm Signature
P5RendererAdapter
p5
JavaScript
p5.js 1.x
function sketch(p, state)
Canvas2DRendererAdapter
canvas2d
JavaScript
Native
function sketch(ctx, state)
ThreeRendererAdapter
three
JavaScript
Three.js
function sketch(THREE, state, container)
GLSLRendererAdapter
glsl
GLSL
WebGL2
Fragment shader source
SVGRendererAdapter
svg
JavaScript
Native
function sketch(state)
import{P5RendererAdapter}from"@genart-dev/core";constp5=newP5RendererAdapter();// Validate algorithm sourcep5.validate(algorithm);// Compile for executionconstcompiled=awaitp5.compile(algorithm);// Create a live instance (browser context)constinstance=p5.createInstance(compiled,sketch.state,sketch.canvas);instance.mount(document.getElementById("canvas"));instance.updateState(newState);instance.captureFrame({format: "png"});// → data URL// Generate standalone HTML with embedded CDN runtimeconsthtml=p5.generateStandaloneHTML(sketch);// Get starter template for new sketchesconsttemplate=p5.getAlgorithmTemplate();
RendererRegistry
import{createDefaultRegistry,RendererRegistry}from"@genart-dev/core";// Pre-loaded with all 5 adaptersconstregistry=createDefaultRegistry();registry.resolve("p5");// → P5RendererAdapterregistry.resolve("glsl");// → GLSLRendererAdapterregistry.list();// → ["p5", "canvas2d", "three", "glsl", "svg"]registry.getDefault();// → P5RendererAdapterregistry.has("three");// → true
Skill Registry
11 built-in design knowledge skills grounded in classical design theory — composition principles (Arnheim, Wong) and color theory (Albers, Itten). Each skill includes theory text, key principles, academic references, and optional renderer-specific algorithm examples.
import{createDefaultSkillRegistry}from"@genart-dev/core";constskills=createDefaultSkillRegistry();constskill=skills.resolve("golden-ratio");skill.theory;// Markdown theory textskill.principles;// Key design principlesskill.references;// Academic citationsskill.suggestedParameters;// Example ParamDefs for this techniqueskill.examples?.p5;// p5.js algorithm example
API Reference
Interfaces
Interface
Description
RendererAdapter
Contract for rendering engines — validate, compile, mount, capture, export
SketchInstance
Live sketch — mount/unmount, updateState, pause/resume, captureFrame
CDN dependency for standalone HTML export (name, version, cdnUrl)
CaptureOptions
Screenshot options (format, quality, scale)
CompiledAlgorithm
Opaque compiled algorithm handle
Classes
Class
Description
RendererRegistry
Register and resolve renderer adapters by type
SkillRegistry
Register and resolve design knowledge skills
Factory Functions
Function
Description
createDefaultRegistry()
Registry pre-loaded with all 5 renderer adapters
createDefaultSkillRegistry()
Registry pre-loaded with all 11 skills
Utilities
Function
Description
hexToVec3(hex)
Convert "#rrggbb" to [r, g, b] floats in [0, 1] — for GLSL uniforms
Re-exports from @genart-dev/format
All types and functions from @genart-dev/format are re-exported: parseGenart, serializeGenart, parseWorkspace, serializeWorkspace, convertLegacySketch, CANVAS_PRESETS, resolvePreset, SketchDefinition, WorkspaceDefinition, ParamDef, ColorDef, and more. See the format README for the full list.