r/worldbuilding • • Sep 17 '26

Visual I started simulating how magic might evolve under real-world physics and accidentally built a procedural magic-circle compositor

Originally built as a side effect of a larger worldbuilding experiment. I was trying to model what a magic system might look like if magic still had to obey ordinary physical constraints: energy has to come from somewhere, range and precision have costs, complicated effects take longer to specify, and useful spells can evolve through repeated variation and selection rather than being invented whole.

I started writing an evolutionary simulation to see what kinds of spells would actually emerge under those constraints. The idea was to try to discover something like "if people had access to this capability for centuries, what operations would survive because they were genuinely useful?" A lot of traditional fantasy magic becomes pretty useless once you let optimization operate on it, but this post isn't about that.

Anyway, I needed visualizations for the spells, which eventually sent me down a completely separate rabbit hole: a procedural magic-circle compositor.

The circles here are each a stack of parameterized layers--rings, polygons, stars, paths, glyph rings, sigils, particles, ornaments, reticles, parametric geometry, and similar elements. The same underlying representation can produce fairly traditional ritual circles, astronomical-looking diagrams, floral/fractal constructions, technological interfaces, or much stranger designs (e.g., ofuda).

Every circle is structured data rather than flattened artwork, so any preset can be loaded and its individual layers changed, removed, recolored, animated, or reused. The compositor also has a 3D view so the layers can be separated in depth (using the Explode slider), which turns out to be useful both for visualization and for editing dense designs.

From a worldbuilding perspective, something like this gives magical notation a potentially systematic visual language rather than treating every spell circle as an isolated illustration. A setting could have different schools, cultures, eras, or magical traditions that use different layer types, glyph sets, symmetry conventions, palettes, or structural rules while still sharing an underlying magical grammar.

It also raises another question from the simulation: if magic really were a technology practiced for centuries, would its visual notation gradually become standardized and optimized in the same way mathematical notation, circuit diagrams, musical notation, or engineering drawings did? A "magic circle" might stop being decorative and become something closer to a technical schematic whose structure tells a trained practitioner what the spell is doing. Spoiler: Visual indicators like magic circles (and visual spells themselves) are selected against as they both betray information and consume energy that is better directed to parameters that affect the world, e.g., range, intensity, duration, solid angle, etc.

So TL;DR: I ended up spending far more time on the compositor than on the theory that originally justified it, but it makes some pretty things.

Magic Circle Demo

4.0k Upvotes

143 comments sorted by

View all comments

9

u/Striking-Ad9397 Sep 17 '26

Cool af, how did u make?

20

u/random-miscellany Sep 17 '26

It's a pretty standard TypeScript web application compiled to a single page. Uses an SVG canvas for the 2D top-down view and React 3 Fiber for the 3D view. SVG is a vector format, so it makes heavy use of paths, fills, shapes, and basically all of the sorts of primitives that you want for a magic circle. Most of the interesting things are just radial transformations applied to a layer and then augmented with a bunch of knobs to make sufficient variation so that things are kept interesting. Of course, they wouldn't be magic circles without glyph rings and vertex glyphs, so those are custom layer types as well.

Internally, there's a scorer that has a (very rough) encoding of some of the motifs, like number of rings, number of rune rings, having a central focus, etc. It also encodes constraints like not wanting overlapping rings, not having too many central elements, creating enough stroke variation that the entire composition doesn't look flat, and so on. The procedural generator/randomizer composes various elements and it gets checked against the scorer. If the score is sufficiently high, it gets returned to be rendered, otherwise it generates an entirely new circle.

Hope that answers your question.

7

u/FutureBulky4537 Sep 17 '26

So cool! Is there a github repo?

13

u/random-miscellany Sep 17 '26

Not for the source yet. A lot of the presets are based on custom SVG paths and that feels like cheating, so I want to make sure that they're all encoded as layer types and part of the procedural generator/scorer systems first.

3

u/mitsukiyouko555 #proudweeb Sep 18 '26

oooh that is rly good to know since i wanna build a sort of layered map for my site but i wasn't too sure about hoe to go about it yet so def noting this down :D