Packages
@genart-dev/format
File format types, parsers, and canvas presets — version 0.5.0
@genart-dev/format
Version 0.5.0. The foundation package defining the .genart and .genart-workspace file formats. Zero runtime dependencies.
Installation
npm install @genart-dev/formatCore Types
SketchDefinition
The top-level type representing a .genart file:
interface SketchDefinition {
version: string;
renderer: 'p5' | 'canvas2d' | 'three' | 'glsl' | 'svg';
algorithm: string;
canvas: CanvasSize;
seed: number;
params?: ParamDef[];
colors?: ColorDef[];
layers?: DesignLayer[];
symbols?: SketchSymbolValue[];
metadata?: SketchMetadata;
}ParamDef
Parameter definitions that become interactive controls:
interface ParamDef {
name: string;
type: 'number' | 'string' | 'boolean' | 'select' | 'color';
default: any;
min?: number;
max?: number;
step?: number;
options?: string[];
}ColorDef
Named color palette entries:
interface ColorDef {
name: string;
value: string; // hex, rgb, hsl
role?: 'background' | 'primary' | 'secondary' | 'accent';
}Parsers
| Function | Description |
|---|---|
parseSketchFile(json) | Parses and validates a .genart JSON string into SketchDefinition |
parseWorkspaceFile(json) | Parses a .genart-workspace JSON string into WorkspaceDefinition |
serializeSketch(def) | Serializes a SketchDefinition to formatted JSON |
serializeWorkspace(def) | Serializes a WorkspaceDefinition to formatted JSON |
Canvas Presets
17 canvas presets across 5 categories:
Screen
| Preset | Width | Height |
|---|---|---|
1080p | 1920 | 1080 |
4k | 3840 | 2160 |
| Preset | Width | Height |
|---|---|---|
letter | 2550 | 3300 |
a4 | 2480 | 3508 |
a3 | 3508 | 4961 |
Social
| Preset | Width | Height |
|---|---|---|
instagram-square | 1080 | 1080 |
instagram-portrait | 1080 | 1350 |
instagram-story | 1080 | 1920 |
twitter-post | 1200 | 675 |
twitter-header | 1500 | 500 |
Square
| Preset | Width | Height |
|---|---|---|
square-sm | 500 | 500 |
square-md | 1000 | 1000 |
square-lg | 2000 | 2000 |
square-xl | 4000 | 4000 |
Widescreen
| Preset | Width | Height |
|---|---|---|
ultrawide | 3440 | 1440 |
cinema | 4096 | 1716 |
banner | 1920 | 480 |
Version History
| Format Version | Changes |
|---|---|
| 1.0 | Initial format — sketch definition, params, colors, canvas |
| 1.1 | Added design layers, metadata |
| 1.2 | Added symbols field (SketchSymbolValue, SketchSymbolDef) |
| 1.3 | Added symbol categories, custom symbol creation |