Draw Koch Fractal

Draw Koch curve, snowflake, or anti-snowflake at any angle. Iterations 0-7. Free, offline, client-side, instant, secure.

Helge von Koch's 1904 L-system fractal with 3 shape modes (single curve / snowflake / anti-snowflake) at any 1°-89° angle. Sister tool: draw-frosty-fractal (snowflake-only with 4 render styles including ice glow).

How to Use Draw Koch Fractal

  1. Pick shape mode: Single Koch curve (one open zigzag), Koch snowflake (3 curves rotated 120° forming closed triangle), or Anti-snowflake (bumps inward, concave star).
  2. Set iteration depth (0-7). Iter 0 = base shape (line or triangle). Each iter quadruples segment count. Iter 7 snowflake = 49,152 segments. Iter ≥ 6 triggers "Drawing…" loading state.
  3. Set angle (1°-89°). 60° is the canonical Koch - equilateral triangle bumps with dim log(4)/log(3) ≈ 1.2619. Non-60° angles render but the rigorous dimension formula no longer applies (stats note "dim N/A").
  4. Adjust segment length, line width, colors. Auto-scale fits the curve to the canvas with 40 px padding. Low-contrast color pairings trigger an info-toast warning.
  5. Press Ctrl+Enter or click Draw. Stats: shape, iteration, segment count, fractal dimension (or N/A), perimeter in display px, L-system char count.
  6. Copy or Download. Copy puts PNG bytes on clipboard via ClipboardItem (paste straight into image editors). Download saves koch-snowflake-iter-N.png (or curve/anti-snowflake).
  7. Experiment: snowflake at 30° (sharp narrow points), anti-snowflake at 80° (very flat indentations), curve at 45° (wider zigzag). Each angle creates a visually distinct "Koch-like" variant.

Frequently Asked Questions

How does this differ from draw-frosty-fractal?

Both render Koch snowflakes. This tool: shape-mode explorer – pick curve / snowflake / anti-snowflake AND set custom angle 1-89°. Stats show fractal dimension only when angle = 60° (the rigorous Koch). Sister tool draw-frosty-fractal: snowflake-only at 60° but 4 render styles (Solid, Outline, Gradient, Ice-crystal with glow). Pick this one for shape variety and angle exploration. Pick that one for ice-style visualization at the canonical 60°.

What is the Koch snowflake?

Constructed by Helge von Koch in 1904 as the first published example of a continuous curve that is nowhere differentiable (no defined tangent at any point – sharp corners everywhere). Start with an equilateral triangle; replace the middle third of each edge with two sides of a smaller equilateral triangle bump pointing outward. Repeat for every new edge. The limit has INFINITE perimeter enclosing finite area = (8/5) · A₀ where A₀ is the original triangle’s area.

What’s the difference between curve, snowflake, and anti-snowflake?

Koch curve: one Koch L-system rendered as an open zigzag. Snowflake: 3 Koch curves rotated 120° apart, joined at endpoints – closed equilateral-shaped boundary with bumps pointing OUTWARD. Anti-snowflake: same construction but bumps point INWARD, creating a concave star. All three have identical fractal dimension (log(4)/log(3) ≈ 1.2619 at 60°) and identical perimeter-multiplier (4/3 per iteration).

Why infinite perimeter, finite area?

Per-iteration perimeter multiplies by 4/3 (each edge becomes 4 edges of 1/3 length each). So total perimeter = P₀ × (4/3)^n → ∞. But area added each iter shrinks geometrically (each iter adds smaller-and-smaller bumps): iter 1 adds 3 small triangles totaling (3/9)·A₀, iter 2 adds 12 even-smaller totaling (12/81)·A₀, etc. Geometric series converges to (3/5)·A₀ of added area, total limit area = (8/5)·A₀. Hence “infinite perimeter, finite area” – the most famous fractal paradox.

What happens if I change the angle?

At 60° you get classic Koch with provable dim log(4)/log(3) ≈ 1.2619. At OTHER angles, the rule F → F+F–F+F still runs but the geometry no longer matches an equilateral triangle bump – the “bump” becomes a different isoceles triangle. The resulting fractal has a DIFFERENT (and harder-to-compute) dimension. We mark the stats line as “dim N/A (non-60°)” rather than report a wrong value. Try 30° for sharp pointed bumps, 80° for very shallow zigzags.

What’s the L-system rule?

Axiom: F. Rule: F → F+F--F+F. F = move forward and draw. + = turn right by the chosen angle. - = turn left by the chosen angle. Each iteration replaces every F with the 4-instruction sequence, so segment count grows as 4^iter. Snowflake mode wraps 3 of these strings with 120° rotations: <koch>--<koch>--<koch>. Anti-snowflake wraps with ++- between curves so bumps face inward.

Why is iteration capped at 7?

Iter N snowflake has 3 × 4^N edges. Iter 7: 49,152 segments. Iter 8: 196,608. Each segment is a lineTo Canvas call. At ~200k operations, render time becomes seconds-long and the L-system character string itself exceeds 100k chars. Iter 7 is the comfortable ceiling. Visually, iter 6-7 are nearly indistinguishable from each other at typical canvas sizes – segments fall below 1 px and merge.

What’s “nowhere differentiable” mean?

A function has a derivative at a point if you can draw a unique tangent line there. The Koch curve has CORNERS everywhere – at every point in the limit set there’s an infinite stack of right-angle bends. So no point has a tangent. This was shocking in 1904 – before Koch, mathematicians believed continuous functions were “mostly” differentiable (smooth lines with at most isolated kinks). Koch (and earlier Weierstrass in 1872 with a different curve) proved otherwise. Today we know “most” continuous functions in a measure-theoretic sense are nowhere differentiable.

Is my data secure?

Yes – 100% client-side. L-system expansion and Canvas drawing run in your browser. No parameters or images leave your device. Verify via your browser’s Network tab.