Free, in your browser

Sketch a distance field

Two shapes as signed distance fields: join, cut or blend them, round the corners or keep a shell, and watch the field as you go. Then copy the functions, or the whole shader.

Inside is pale, outside ember; each ring is the same distance further from the edge.
Open in the playground

What a distance field is

Each function gives, for any point, how far it is from the shape's edge: negative inside, positive outside. That one number draws the shape (where it crosses zero), an outline (where it is small), a glow (where it is small and positive), and lets shapes combine with min and max. Blend is the smooth kind, with a reach k; Rounding takes a little off the distance, which rounds every corner; Shell keeps only a wall of that thickness.

In a shader

The functions are Inigo Quilez's 2D primitives and operators; copy them into any Metal shader and call scene(p, …) with a point in the same units. The whole shader opens in the playground and the Ray Kiln app, the sliders as they are here. The link in the address bar keeps everything.