Skip to content

tel/sequences

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sequences

A computational graphics framework for generative art in Zig.

Overview

Sequences provides a sketch-based programming model for creating mathematical visualizations and algorithmic art. Write simulations in continuous space, accumulate results into rasters, and export high-quality images.

Quick Start

# Build and run a sequence
zig build sq -Doptimize=ReleaseFast -- rw1

# Run all tests
zig build test

# Check compilation
zig build check

Architecture

Sequences

Each sequence consists of:

  • .zig - Implementation using the Context(Config) framework
  • .zon - Configuration file with runtime parameters
pub fn sequence(ctx: sq.Context(Config)) !void {
    // Setup simulation space
    const sim_rect = sq.Rect2.ofExtentCentered(ctx.config.frame);
    var raster = try sq.GrayscaleRaster.init(ctx.allocator, pixel_extent);
    
    // Run simulation
    for (0..iterations) |_| {
        const point = simulate();
        if (sim_rect.contains(point)) {
            const uv = sim_rect.getUv(point);
            raster.splat(uv, intensity, .bilinear);
        }
    }
    
    // Post-process and export
    processor.processInPlace(raster.buffer);
    try raster.writeToFile(ctx.allocator, "out.png", .{});
}

Core Types

Sequence Framework

  • Context(Config) - Provides services to your sequence:
    • allocator - Memory allocation
    • rng - Seeded random number generation
    • config - Parsed configuration from .zon file
    • node - Progress tracking for long operations
    • timer - Performance measurement

Coordinate Systems

  • Extent2 / Rect2 - Floating-point geometry with physical dimensions
  • Extent2i / Rect2i - Integer pixel-space geometry
  • Uv2 - UV coordinates [0,1)×[0,1)
  • Seamless conversion between simulation, UV, and pixel spaces

Rasterization

  • GrayscaleRaster - Accumulation buffer with point/bilinear/box filtering
  • StdGrayscalePostProcessor - Tone mapping, normalization, inversion pipeline

Utilities

  • ReservoirSampler - Random sampling from streams

Design Philosophy

  • Resolution independent - Work in physical units (inches), render at any DPU
  • Memory explicit - All allocations use provided allocators
  • Performance conscious - SIMD vectors, fused operations, progress reporting
  • Test driven - Comprehensive tests for core components

Examples

See src/sequences/ for examples including:

  • rw1 - Random walk/Brownian motion trails
  • if1 - Iterated function systems
  • if2 - IFS with nonlinear transformations

Each demonstrates different techniques for point generation, accumulation, and post-processing.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages