Skip to main content
This example demonstrates how to create procedurally generated animations that are fully deterministic and reproducible using Helios utility functions.

Overview

The procedural generation example shows:
  • Deterministic random number generation
  • Frame-based procedural animations
  • Color interpolation over time
  • Grid-based generative patterns

Complete implementation

composition.html
main.ts

Key patterns

Deterministic random generation

The random() function from Helios core provides deterministic pseudo-random numbers based on a seed:
This ensures that procedural animations are reproducible and render identically every time.

Seed-based property generation

Generate unique but deterministic properties for each element:
By using different seed offsets (1000, 2000, 3000), each property gets independent randomness while remaining deterministic.

Color interpolation

Use interpolateColors() for smooth color transitions:
This interpolates between colors based on frame number with clamping at the end.

Frame-based animation

Combine random seeds with frame-based timing for dynamic animations:
Each element animates at its own deterministic speed and phase offset.

Performance tips

Cache random values

For large grids, cache random values instead of recalculating:

Optimize grid rendering

Skip rendering elements outside the viewport:

Use integer calculations

Where possible, use integer math for better performance:

Batch canvas operations

Group similar drawing operations to reduce state changes:

Advanced techniques

Noise-based generation

Implement Perlin or simplex noise for organic patterns:

Particle systems

Create deterministic particle systems:

L-System generation

Generate fractal patterns using L-Systems:

Multi-layer composition

Combine multiple procedural layers: