Fractal Tree (Canvas)
✓ Published0🌍 Public
KKristin Baumann
Last edited Apr 25, 2024
Created on Apr 25, 2024
Forked from Svelte + D3: Canvas & renderless components
A fractal tree unfolds recursively on a canvas, with each branch splitting into two shorter, angled offshoots until it reaches a fixed depth. The tree remains static, but the canvas re-renders through a custom Svelte context system, where drawing functions register and invalidate frames via `requestAnimationFrame`. The example uses the Canvas 2D API for all drawing, with recursive `branch` calls handling rotation, translation, and stroke paths to create the organic, geometric structure.
AI-generated descriptionMIT Licensed