HomeJournalThis post

SVG Celtic Knotwork From Path Graphs

Represent crossings as signed graph data, prove closure and alternation, then derive editable masks, shadows, and plotter-safe paths.

JP
JP Casabianca
AI Engineer and Product Designer · full-stack delivery · Bogotá

SVG Celtic knotwork becomes easier to generate and edit when crossings are signed graph data rather than paint-order accidents. This tutorial validates loop closure and over-under alternation first, then derives masks, shadows, outlines, and plotter-safe paths from the same geometric source.

SVG Celtic knotwork begins as a graph

Place a planar graph whose edges describe the intended interlace centerlines and whose degree constraints support continuous travel. Each geometric crossing becomes a record with an ID, two participating strand visits, coordinates, local tangent directions, and a sign naming which visit passes over. SVG Celtic knotwork then emerges from data that can be checked before it becomes decorative pixels.

Keep topology separate from rendering. A node means a connection in the strand graph; a visual intersection may be a crossing where strands do not connect. Confusing those concepts creates accidental branch points and broken loops. An SVG path graph should therefore store connectivity, crossing order, and geometry in distinct layers, even if a small editor presents them together through draggable handles.

Give graph nodes stable human-readable labels in the editor. A designer can then discuss “north border crossing C7” during critique instead of relying on fragile screen coordinates or generated path order.

A signed path graph becomes one alternating ribbonA four-lobed closed knot shows centerline nodes, crossing IDs, and alternating over and under masks derived from graph visits.
  • Node: true centerline connection
  • Crossing: two non-connecting visits
  • Plus: first visit passes over
  • Minus: next visit passes under
Figure 1: Signed crossings turn visual paint order into inspectable topology.

Build loops before drawing ribbons

Traverse every half-edge exactly once according to the pairing rule at each vertex. Record ordered samples for each resulting component and assert that the final endpoint returns to the first within a declared tolerance. Reject dangling degree-one nodes, unpaired visits, duplicate edge consumption, and near-closed gaps. Procedural knot patterns should fail loudly as graph data instead of hiding a discontinuity under a thick stroke.

Use the SVG 2 paths specification for path grammar and curve behavior. Serialize geometry with stable precision and explicit close commands where appropriate, but do not rely on Z to repair a large gap. The closure proof belongs to the graph and sampled geometry before export. Similar discipline appears in origami crease patterns, where structural relationships matter more than attractive linework.

Check each component's orientation and signed area when generating fills or offsets. Unexpected reversal can flip normal directions, move outlines inward, and break local crossing masks even while the centerline remains closed.

FixtureClosureAlternationGeometryResult
Four-lobePassPassClearRender
Open tailFailGapReject
Odd visitsPassFailClearReject
Tangent touchPassPassAmbiguousReview
Tiny gapPassPassCrowdedRetune
Figure 2: The crossing inspector separates topology failures from rendering failures.
  1. 1Graph

    Pair half-edges into closed components

  2. 2Sign

    Solve alternating over-under visits

  3. 3Render

    Derive ribbons, masks, outlines, and shadows

  4. 4Proof

    Inspect zoom, thumbnail, plotter, and archive

Figure 3: One edition moves from topology through signed crossings to physical proof.

Sign crossings along each component

Walk a closed component and assign over, under, over, under to its successive crossing visits. When the traversal returns, the expected next sign must agree with the first; otherwise the component has an odd number of crossing visits and cannot alternate under that assignment. Multi-component links also need consistent signs at shared crossings, so solve constraints across components rather than styling each loop independently.

The MathWorld overview of knots provides mathematical vocabulary, but this renderer uses a modest diagram constraint rather than claiming to solve knot equivalence. SVG Celtic knotwork needs a signed projection that looks coherent, not a complete topological classifier. Store manual sign overrides as authored data and rerun validation, making art direction explicit instead of embedding exceptions in mask IDs.

Show constraint conflicts directly at both visits to a crossing. A single red badge at the geometric intersection hides which component traversal introduced the impossible alternation assignment.

Derive gaps and shadows from crossing data

Render a broad dark outline, a narrower colored ribbon, and small overpass segments above localized underpass masks. Generate each mask window from the crossing coordinate and tangent, with radius based on ribbon width and crossing angle. At shallow angles the window must grow or the strands visually fuse. Shadows should be subtle and offset consistently so they clarify order without pretending to simulate a specific physical material.

Avoid a single global z-order: one strand must alternate across the piece. Signed crossing records generate local paint order that remains correct after palette changes. Use unique IDs for masks and clips when multiple editions share a page. SVG Celtic knotwork remains selectable and scalable because the visual layers are derived vector paths, while the semantic caption explains the system without requiring anyone to decode color alone.

Derive shadow width and gap radius from one ribbon token, then allow limited optical correction. This keeps editions coherent while acknowledging that shallow crossings may need more breathing room than algebra alone supplies.

The graph fixture verifies closed traversal, even crossing visits, and alternating signs for one teaching component; it does not classify historical motifs or general knot equivalence.

Runnable artifact — signed-knot-graph.test.mjs

import assert from "node:assert/strict";
const component={vertices:["a","b","c","d","a"],crossings:["x","y","z","w"]};assert.equal(component.vertices[0],component.vertices.at(-1));assert.equal(component.crossings.length%2,0);
const visits=component.crossings.map((id,index)=>({id,sign:index%2===0?"over":"under"}));for(let i=1;i<visits.length;i++)assert.notEqual(visits[i].sign,visits[i-1].sign);assert.notEqual(visits.at(-1).sign,visits[0].sign);
const edges=new Set(component.vertices.slice(0,-1).map((v,i)=>v+"-"+component.vertices[i+1]));assert.equal(edges.size,4);console.log("PASS: knot component closes and crossings alternate");

Run node signed-knot-graph.test.mjs. Expected receipt: PASS: knot component closes and crossings alternate.

Shape curves with rhythm, not automation alone

Graph validity can produce an ugly knot. Place anchors to create a hierarchy of long sweeps, tight turns, and breathing spaces. Align tangents through crossings, avoid near-touches that read as missing intersections, and tune ribbon width relative to the smallest cell. A useful editor overlays curvature warnings and clearance circles but allows a designer to reshape control points without breaking identities.

Borrow generative discipline from guilloché SVG patterns and compositional tension from Penrose tiling posters, while resisting ornamental sameness. SVG Celtic knotwork gains character through asymmetrical emphasis, intentional borders, and palette, even when the crossing law stays regular. Save the seed, graph, control points, signs, widths, and colors so an edition can be regenerated rather than approximated from its final image.

Add a curvature comb and minimum-clearance overlay to the editor. These diagnostics expose flat spots and near-collisions early without pretending that the tool can choose the most expressive curve for the artist.

Design a failure atlas beside the beauty frame

Keep examples of open components, odd crossing counts, duplicate IDs, tangent touches, acute intersections, insufficient gap radius, self-overlapping masks, clipped outlines, and plotter pen lifts. Label the violated invariant and show the diagnostic overlay. A failure atlas teaches more than a gallery of successful generative knot art because it connects visible defects to graph or rendering causes.

Test at favicon scale, normal reading width, 200 percent zoom, print, forced colors, and monochrome. Convert strokes to plotter-safe centerlines only when the physical tool expects them; a filled ribbon outline may require a different fabrication plan. SVG path morphing can animate related editions, but topology and point correspondence must remain stable or the crossing proof no longer describes intermediate shapes.

Print the over-under crossings failure atlas in monochrome as well as color. Crossing order must remain legible through gap and outline geometry when palette, display gamut, or color perception no longer differentiates strands.

Separate contemporary method from historical claim

The Trinity College Dublin digital collection for the Book of Kells offers direct access to historical visual material for study. It does not establish that historical makers used this graph algorithm, signed crossings, SVG-like construction, or the terminology in this tutorial. Describe the output as contemporary computational work inspired by interlace traditions, and cite art-historical scholarship separately if making claims about origin, meaning, or technique.

That distinction strengthens the creative project. SVG Celtic knotwork can acknowledge a rich visual lineage without converting cultural artifacts into a software backstory. Keep source notes, motif sketches, and design decisions in the edition ledger. Inspiration is not a license to flatten place, period, manuscript function, and craft into a generic aesthetic tag.

Record the exact manuscript page or object used for each observation, not only a collection landing page. Specific references make later scholarship and creative attribution substantially more responsible and useful. SVG Celtic knotwork remains a contemporary computational interpretation in this tutorial.

Archive the editable knot edition

Package the graph JSON, signed crossing list, SVG paths, mask parameters, palette, seed, validator output, accessible title and description, preview PNG, and plotter test. The SVG should remain editable without losing stable crossing IDs. Publish the failure atlas or a small crossing inspector so readers can see that the visual thesis is executable rather than hidden in a final polished image.

Revisit SVG Celtic knotwork when geometry, export tooling, or fabrication method changes. Re-run closure, alternation, uniqueness, clearance, and rendering checks after every edit. The finished ribbon may feel intricate and ancient, but its computational integrity comes from a simple contemporary promise: every line returns, every crossing has an explicit order, and every visual gap can be traced back to signed graph data.

Offer a clean centerline export beside the illustrated ribbon. Fabricators, animators, and future editors can choose an appropriate derivation without reverse-engineering geometry from masks, shadows, and expanded outlines.

Produce three editions from the same validated topology: a broad two-color screen ribbon, a monochrome print version whose gaps alone communicate order, and a centerline plotter study. For each, archive crossing IDs, sign assignments, ribbon width, mask radius, curvature and clearance warnings, component orientation, SVG IDs, target dimensions, and a thumbnail and zoom proof. Invite a reviewer to select any visible overpass and trace it back to the two graph visits and the local mask that created the gap. Then edit one control point, rerun closure and alternation, and show that the edition remains structurally valid or fails with a specific diagnostic. This exercise proves the creative system can support real iteration: the graph does not imprison the drawing, the drawing cannot silently escape its crossing contract, and different material derivations preserve the same authored interlace without claiming a historical construction method.