Kolam SVG: Build and Verify One Closed Path
Turn a finite dot grid into one closed path, audit connectivity and clearance, compose accountable editions, and export a topology receipt.
Kolam SVG can turn a finite dot grid into one connected closed path, but a program must not confuse geometric verification with cultural authenticity. This tutorial declares that boundary, builds a bounded route, audits closure and dot clearance, and exports original SVG geometry with a deterministic receipt.
Kolam SVG needs a declared cultural boundary
Kolam SVG can be a computational study of one closed path around a finite dot grid, but code does not confer cultural authenticity. Kolam traditions are living, situated practices with regional vocabularies, materials, gestures, meanings, and expertise. This tutorial studies graph and path constraints inspired by one visual idea; it does not certify a drawing as traditional, ritual, representative, or culturally complete.
The construction goal is intentionally narrow: generate one connected closed loop, keep it clear of the dot centers, expose its gates, and export a valid SVG path plus a machine-readable topology receipt. Every preset is bounded and deterministic so the same inputs reproduce the same edition.
A recent heritage-science study of kolam provides cultural and analytical context. Read the paper for its authors’ methods and conclusions. The figures here are original teaching diagrams, not reproductions of paper images or a claim that a finite algorithm captures the breadth of practiced kolam.
That boundary improves the creative work. Instead of borrowing authority from a name, we can show exactly what the program controls: grid dimensions, spacing, corner radius, clearance, traversal order, closure, and export. The result is accountable generative geometry and an invitation to learn from primary cultural scholarship rather than a substitute for it.
- Dots: protected centers with a visible clearance radius.
- Gates: horizontal midpoint lanes between neighboring dot rows.
- Route: one ordered comb component that alternates across every lane and closes on a separate left return.
- Boundary: a computational study, not a claim of cultural authenticity.
Reading rule: labels, values, patterns, and structure carry the conclusion; color is supplementary.
Turn a finite dot grid into gates
Begin with an odd rectangular grid between three-by-three and nine-by-nine dots. Each dot is a protected center with a declared clearance radius. The path travels through gates located halfway between neighboring dots or around the outer boundary. This dot grid pattern is a geometric input, and a gate is a waypoint rather than a cultural taxonomy.
For the bounded presets, construct a rounded comb route through the horizontal midpoint lanes between dot rows: start in a separate left return lane, enter the top gate, cross the field, descend outside the dots, return through the next gate, and alternate until the bottom. A short connector reaches the separate return lane, which closes to the exact starting coordinate. The route materially traverses the grid instead of merely framing its perimeter.
The dot-and-gate figure separates protected points from permitted corridors. Spacing is the master dimension. Corner radius is clamped below half the spacing, while clearance must remain below the distance from every sampled curve point to every dot. Invalid combinations are rejected instead of squeezed into self-intersection.
This differs from the Celtic knotwork SVG graph tutorial. Both can use planar graphs and closed paths, but their cultural histories, construction rules, visual grammars, and meanings are not interchangeable. The inbound and outbound links state that non-equivalence explicitly.
Build one Eulerian-style traversal contract
A one-stroke SVG requirement is a topology contract: one connected component, no dangling endpoints, and a return to the starting point without lifting. An Eulerian circuit is a useful graph model when every traversed edge belongs to a connected graph and every vertex has even degree. The rendered cubic or quadratic curves are geometry laid over that topology.
The computational kolam paper explores algorithmic perspectives on kolam patterns. This tutorial uses its existence as motivation to make computation inspectable, not as permission to copy diagrams or flatten cultural practice into one universal graph. Our particular preset generator is independently drawn and deliberately limited.
Represent each gate as a stable coordinate key and each corridor as an undirected edge. Before rendering, count endpoint degrees, run a breadth-first connectivity walk, and confirm every used edge belongs to the visited component. Then trace the ordered path and confirm its final endpoint equals its start within a fixed epsilon.
The lab derives nodes and undirected edges from the ordered route, then runs breadth-first search, counts vertex degrees and dangling endpoints, compares the final coordinate with the start, and checks nonadjacent flattened segments for intersections. It also runs independent disconnected, dangling, crossing, and clearance fixtures that must each be rejected. Redundant checks matter because a future preset, smoothing change, or export refactor can violate a hidden assumption while the thumbnail remains plausible.
Translate the traversal into one SVG path
A closed SVG path is the portable drawing contract. Emit one M command, a bounded sequence of L and Q commands, and one Z close command. Keep coordinates in a stable viewBox rather than device pixels so the work scales without changing its geometry. Round exported decimals consistently to avoid meaningless diff noise.
The SVG 2 paths specification defines path-data syntax and closepath behavior. A Z command joins the current subpath to its initial point; it does not prove that the intended graph has one component or that no unwanted intersections exist. Syntax validation and topology validation remain distinct.
Corner smoothing should preserve the ordered route. For each turn, shorten the incoming and outgoing line by the clamped radius and connect those tangent points with a quadratic segment through the original corner. When adjacent segments are too short, reduce the radius rather than reversing direction or creating a loop.
Keep dots as separate circle elements and the stroke as one path element. That makes the semantic structure inspectable, supports non-scaling stroke choices, and allows the exported JSON to name dots and path independently. The browser preview uses the generated safe attributes directly; user text never becomes markup.
- Traverse the used graph and require one connected component.
- Require one subpath whose final endpoint equals its start.
- Reject dangling endpoints.
- Sample curves and require minimum dot clearance.
- Reject unplanned nonadjacent segment crossings.
Reading rule: labels, values, patterns, and structure carry the conclusion; color is supplementary.
Audit closure, connectivity, and clearance
A visually closed mark can still contain multiple overlapping subpaths. Audit path topology from the route data, not from pixels. This generator requires exactly one route, one M command, and one Z command. It reports zero dangling endpoints and confirms the ordered final point returns to the start.
Clearance is geometric. Sample every line and quadratic segment at a deterministic resolution derived from spacing, then compute the Euclidean distance from each sample to every dot center. The minimum observed distance must be greater than or equal to the requested clearance. Sampling is an approximation, so the lab reports the sample interval and keeps a conservative margin.
Self-intersection is a separate question. A one-stroke closed curve may cross itself, touch itself, or remain simple depending on the chosen grammar. The bounded serpentine presets aim for a simple loop and test nonadjacent flattened segments for intersections. Shared endpoints between adjacent segments are allowed; other crossings fail the preset.
For another way to compose deterministic paths, see Truchet tile composition. Tiled arcs choose local connections that form larger routes; this study starts from one global traversal. They can share verification techniques without pretending their visual or cultural origins are the same.
Compose editions without hiding the recipe
Once the topology passes, variation can live in presentation: stroke width, line cap, paper tone, dot treatment, scale, and a small palette. Freeze the geometry before changing those layers. A contact sheet is most useful when each panel names the one changed parameter and all other settings remain constant.
The three included editions use the same five-by-five grid and traversal with different stroke and dot relationships. “Graphite” emphasizes construction; “Indigo” makes the loop dominant; “Night chalk” reverses figure and ground. None is presented as a traditional classification. They are art-direction studies over one computational route.
The L-systems botanical SVG tutorial is a useful contrast in generative authorship. L-systems grow a symbolic grammar recursively, while this Kolam SVG exercise solves a finite closure and clearance contract before styling. In both cases, a seed and parameter receipt make visual iteration accountable.
Export the contact sheet only after each panel reuses the same verified path data. Do not redraw by eye and call the panels comparable. If a style needs different geometry, give it a new receipt and audit. Visual coherence is stronger when the code admits which changes are cosmetic and which alter topology.
- Invariant
- Alternating gate path data, grid, connectivity, closure, crossings, and clearance.
- Graphite
- Construction-forward neutral surface.
- Indigo
- Loop-forward light surface.
- Night chalk
- High-contrast reversed surface.
- Provenance
- Original computational editions with an explicit cultural boundary.
Reading rule: labels, values, patterns, and structure carry the conclusion; color is supplementary.
Design for access and respectful reuse
The article’s figures include titles, descriptions, captions, and semantic equivalents. The path conclusion is never carried by color alone. In forced-colors mode, the lab uses system colors; at reduced motion, it disables the optional draw-on effect; at narrow widths and 200% zoom, controls wrap and the SVG remains horizontally contained.
The artifact labels itself a computational study. Its exports repeat the truth boundary so a downloaded file does not lose context. If you publish an edition, include the recipe and provenance note. If you are presenting cultural history, commission or cite practitioners and scholarship rather than using this generator as the authority.
Avoid names that imply a community endorsed the result. Do not train a commercial style model on scraped kolam imagery and point to this tutorial as consent. A technically original path can still participate in extractive presentation if its framing erases living authorship and context.
Simplification is another risk. The Ramer–Douglas–Peucker SVG path guide explains error-bounded point reduction, but topology must remain a hard gate here. If simplification changes closure, clearance, or intersections, reject it. A smaller file is not a better edition when it breaks the declared construction.
Export a verifiable Kolam SVG receipt
The local Kolam SVG lab offers three bounded presets and deterministic controls for grid, spacing, corner radius, clearance, stroke, and palette. It clamps total dots and segments, rejects non-odd or out-of-range grids, generates one alternating gate path, derives its graph, audits connectivity, degrees, closure, dangling endpoints, crossings, and sampled dot clearance, then exports SVG plus JSON.
The JSON receipt records generator version, preset, parameters, route points, path-data hash, node and edge counts, component count, degree histogram, closed-loop result, endpoint and crossing counts, sampled minimum clearance, negative-fixture results, and truth boundary. The SVG contains a title and description, a background, dot circles, and exactly one authored path. It contains no remote resources, scripts, or hidden raster image.
The Kolam SVG audit is evidence about this finite implementation, not proof of cultural authenticity or a classification of kolam traditions. Curve sampling approximates clearance; future generators with different splines need a suitable analytic or tighter numeric bound. The path is small enough that every gate can be recomputed locally.
Use the Kolam SVG artifact to practice accountable geometry: declare the grid, show the gates, build one route, preserve closure through smoothing, test the path, and keep provenance beside the image. The most interesting creative code does not hide its constraints. It turns them into a visible part of the work.
Runnable local artifact — The lab is an original computational study of finite closed-path constraints inspired by a visual idea; it does not certify cultural authenticity, reproduce paper figures, or represent the range of living kolam traditions.
Select a bounded odd grid, construct one rounded route, verify one component, closure, zero dangling endpoints, clearance, and limits, then export SVG and JSON.