Designing Kolam in Clojure Through Visit Order and Tangency
Kolam is a geometric floor-art tradition rooted in South India. 1 At first glance, it looks intricate. At second glance, it looks inevitable. The lines seem to know where they are going.
1 Definition: Kolam (Tamil: கோலம்) is a South Indian threshold-art practice, often organized around dots and continuous curves, with forms ranging from quick daily motifs to elaborate festival compositions. References: Kolam (art), South India.
Many people draw kolams every day as a practice of welcome and care. They are often made with rice flour, which feeds ants and insects, which in turn feed birds. 2
2 Context: Everyday kolam practice differs by region, household, material, and occasion.
Generative-art often chases novelty first. In kolam practice, continuity usually comes before variation. If you repeat the same rules over time, new variations still appear.
Most kolam constructions begin from a dot field. Dots are the quiet part of the story. Curves are the dramatic part.
What’s This About?
This article is about a drawing recipe: start with a grid, choose a dot path, and pass by the dots to the side.
By the end, you should be able to:
- Make interesting visuals from small, deliberate rule changes.
- Use a kolam programming model: visit order, tangency, and turns.
- Reuse the core helpers in this notebook to design your own variations.
This notebook focuses on one geometry-first subset of kolam practice. The code model here is a respectful lens, not a complete account of kolam.
We start from a finished kolam, peel it into parts, then recombine those parts.
Core Idea
Kolams are visitation paths through a grid of nodes. The path moves around dots, not through them.
Here is the simplest way to think about this system. We shape kolam with two choices and one rule:
- Visit order chooses structure (which dots connect and where crossings can occur).
- Swap policy chooses whether you keep the same side at each step or swap sides as you move to the next dot.
- Wrap rule: once you arrive at a side, the path rounds the dot smoothly before continuing.
Glossary
This section keeps only the terms needed for the walkthrough. Detailed geometry terms are introduced later in “How the Drawing Model Works.”
- Dot
- A grid point in the visit list.
- Route
- Also called visit order: the ordered list of dots we follow (for example, 1 -> 2 -> 1). The rendered line then wraps around those dots in that order.
- Visit order
- Same sequence as the route. This defines structure: which dots are connected as neighbors, where revisits occur, and which crossings are possible.
- Tangent point
-
Where a segment touches a dot-circle at distance
radius. These are the anchor points used to connect straight segments and smooth arcs. - Start side
- The side used for the first segment (left or right). This sets the initial orientation of the path and can flip the visual posture.
- Alternate tangent side
- Leave each dot on one side and arrive at the next dot on the opposite side. In practice, this often introduces crossings and produces tighter woven-looking routes.
Guided Walkthrough
Here is the outline of what we are about to walk through:
- Start with one simple route on a dot grid.
- Make small rule changes and see how the shape responds.
- Compare a few route families across small dot sets.
- Reorder the same dots to get different crossings.
- End by layering multiple routes into one composition.
Every figure in this section is generated from code. You can read this top to bottom like a regular article, or treat it as a lab notebook and run it in your REPL.
Source code: this notebook and repository root.
This is the target pattern we will build up to:
Start with the Dot Grid
Now start from the simplest version. No curves yet. Just dots.
Routing Concepts
Let’s quickly run through how routing concepts work together to construct a kolam.
A neutral dot field before we draw any route. We can assign each dot an index (1-9) so the path is easy to state.
The same dots, now connected in the order we will follow: 1 -> 2 -> 7 -> 4 -> 9 -> 8 -> 3 -> 6 -> 1.
The two marker colors show tangent touch points on neighboring dot-circles. Each straight connector runs from an outgoing touch point to the next incoming touch point, which sets up smooth curve transitions.
Arc joins replace the straight tangency connectors, producing a continuous flowing route.
Tangency alternates by segment, which changes crossings and shape.
Reuse the previous route, then overlay a second symmetric route to build a richer composition.
Comparing Side Alternation
The first two panels use a minimal two-node route. The third and fourth use a longer multi-node route to show how side policy changes complex paths.
Revisiting dots
Paths can revisit the same dot.
Consider the path: 1 -> 2 -> 3 -> 2 -> 1. Revisiting the middle node is intentional. The return pass uses the opposite side of that node.
These all intentionally revisit the center, showing how “double-backing” can produce useful structure.
Overlaying paths
Rather than restricting ourselves to one path, we can combine multiple paths in one kolam.
Here’s an example of combining a diagonal cross and an inner cross to get a star-like crossing field.
Here is a more complex overlay of multiple spokes that share one center, and double back through that center on the opposite side.
Visualizing Control Points and Route Structure
- Start anchor (blue): where the path begins (large marker)
- End anchor (red): where the path closes (small marker)
- Tangent in (coral): incoming tangency point at a dot (marker-in)
- Tangent out (mint): outgoing tangency point at a dot (marker-out)
(Colors: blue = marker-start, red = marker-end, coral = marker-in, mint = marker-out)
Toggle Alternation on the Baseline Route
Switch the Start Side to Right
Combine Right Start with Alternation
In this variant, segment exits and next-dot entries use opposite sides.
Change the Visit Order
This different visit order creates different crossings.
Layered Patterns
Layered 4x4 motif: three symmetric routes in one composition. This avoids forcing one long stroke and gives cleaner radial structure.
Composition Insights
Two practical discoveries emmerged while creating this gallery. Neither is fancy; both matter a lot in practice.
Not visiting the center can improve balance. Leaving it empty creates breathing room and makes symmetry easier. This only applies to odd sized grids, as even sized grids have no dot at the center.
More than one unconnected path is often cleaner than one forced stroke. Forcing continuity can create awkward detours and uneven density. Splitting into coordinated paths gives better control: one can carry perimeter rhythm, another can shape the core, and a third can tie them together.
Why I Built This
A big reason I got interested in kolam is educational: finding better ways to invite young people into programming. Turtle graphics is a great starting point, but kolam feels more immediately compelling. Both approaches are built from a small, logical set of primitives. 3
3 Context: Turtle-graphics learning traditions show how simple movement rules can produce expressive structure. That background helps explain why kolam modeling can be taught through explicit movement choices such as visit order, side policy, and turn rules. References: Mindstorms (Papert), Turtle graphics.
Kolam is a promising programming canvas. Visit order and side alternation policy are explicit and composable. One big downside is pedagogical: turtle tasks offer more obvious on-ramps for introducing repetition and functions than kolams. Kolams have many rich graph concepts to explore, however it’s not immediately clear how to motivate basic programming features like functions.
Kolam, Script, and Context
This work also clarified a cultural difference in emphasis. A lot of Western “generative art” language centers novelty, surprise, and style exploration. Kolam practice often centers continuity, repetition, care, and daily ritual, where variation stays within a rule template.
Kolam is a Tamil word (கோலம், kolam), and the practice is deeply rooted in Tamil culture while also appearing across South India under related regional names. 4
4 Note: kolam terminology is culturally situated and partially overlaps with broader South Asian threshold-art terms. Usage in this article: “kolam” refers to Tamil-rooted practices that motivate these geometric examples. References: Tamil language, Kolam (art), Rangoli.
5 Definition: Margazhi is a month in the Tamil calendar, about mid-December to mid-January. Reference: Tamil calendar.
6 Definition: pulli kolam uses dots as structural anchors; sikku kolam emphasizes continuous knot-like looping around dots; ezhuthu kolam composes forms from script-like letter shapes. Classification note: these terms distinguish families of construction rules.
At the letterform level, kolam geometry resonates with the visual rhythm of Tamil script, which uses many rounded, loop-like curves. Tamil is a Dravidian language primarily spoken in Tamil Nadu and Puducherry in southern India, and also widely spoken in Sri Lanka and the global Tamil diaspora (including Singapore, where it is an official language). During Margazhi5, kolam practice becomes especially visible in many Tamil communities, with larger and more elaborate threshold drawings. Alongside classical pulli/sikku forms, artists also explore Tamil letter kolam compositions (ezhuthu kolam), shaping letters such as “அ” or “உ”, and sometimes words like “தமிழ்”, through dot-based curve grammars. 6 One short phrase that fits the spirit here is:
“தமிழ் எழுத்து வளைவுகள் நிறைந்தது” (Tamil script is rich with curves).
Tamil script and kolam both tend toward rounded, continuous strokes.
Kolam is interesting because small local choices create strong global structure. The same dot field can produce very different outcomes by changing only visit order, tangent-side policy, or turn handling. It sits at a useful intersection of craft and geometry: you can reason about continuity and closure like a formal system, while still working by eye for rhythm, proportion, and balance.
Embellishments
Kolams often include embellishments beyond the base path structure. Here we explore one way to add restrained decorative motifs while keeping the same geometry model.
How the Drawing Model Works
This section explains how the code draws kolam paths. It covers one geometric subset of kolam practice: dot-avoiding linework, and line/arc segments.
When the path turns, the code must choose between possible arc directions and sizes to ensure smooth, continuous curves. The SVG sweep and large-arc flags control these choices, determining whether the arc bends clockwise or counterclockwise, and whether it takes the shorter or longer route between points.
- External tangent: touches two equal circles on the same side.
- Internal tangent: touches two equal circles on opposite sides.
- Segment: the connection (curve or line) between two consecutive dots in the route.
- Tangency: the property that each segment touches the dot-circle at a single, smooth point, ensuring a continuous path.
- Arc: a curved segment (SVG arc) used to smoothly connect tangency points when the path turns.
- Closure: the property that a closed route rejoins its starting anchor, forming a continuous loop.
- Collinear/turn: collinear means the path continues straight through a dot; a turn means the path changes direction at the dot.
sweepflag (SVG arc): chooses clockwise vs counter-clockwise direction.large-arcflag (SVG arc): chooses shorter vs longer arc branch.- C0 continuity: the path stays connected (no gaps).
- G1 continuity: tangent direction matches at smooth joins (visual smoothness).
Path View and Coordinate View
Two equivalent views describe the same route:
- Path view: an ordered visit list over indexed dots (for example 1 -> 2 -> 1).
- Coordinate view: the same dots written as positions. With spacing s, [gx gy] maps to [(gx-1)s, (gy-1)s]. Example: index 1 -> [1 1] -> [0 0].
Path view is usually easier for design. Coordinate view is what geometry and SVG commands use. In other words, path order drives structure, while coordinates drive drawing.
Worked micro-example (2-dot baseline intuition):
- Dots: [1 1] -> [2 1] -> [1 1], spacing=10, radius=3, start side=:left.
- Centers become [0,0] and [10,0], so segment directions are horizontal.
- Same-side mode gives a pill-like envelope around both dots.
- Alternating mode gives a figure-eight crossing.
- Visit order is identical in both cases; tangent-side policy is what changes.
Output shape:
- Input: ordered dots [gx gy], with spacing, radius, and side policy.
- Output: an SVG path composed of absolute M/L/A commands. 7
7 Definition: SVG path commands M, L, and A encode move, line, and arc primitives. Implementation link: this model’s kolam flow is built directly from those primitives, so geometry choices map transparently to SVG syntax. Reference: MDN SVG path.
Segment Tangency Rules
For each segment from dot[i] to dot[i+1], compute touchpoints together (segment-touch-points), one on each dot-circle.
- Same-side mode (alternate-tangent-side? = false): use the external common tangent.
- Alternating mode (alternate-tangent-side? = true): use the internal common tangent. 8
8 Definition: equal-radius circle pairs admit external (same-side) and internal (opposite-side) common tangents. Geometric consequence: the alternation toggle switches between these tangent families, directly changing crossing behavior. Reference: Tangent lines to circles.
This segment-level construction is the key stability rule: connector lines are tangent by construction.
Turn Rules
At each interior dot, we look at the direction coming in and the direction going out:
- If the path continues straight (the directions are collinear), we simply connect with a straight segment (unless the tangency points coincide, in which case we may skip the arc).
- If the path turns, we draw a smooth arc to connect the outgoing and incoming tangency points.
The path draws a line to the incoming tangency point, then an arc to the outgoing tangency point when needed.
- The direction (sweep) and size (large-arc) of the arc are chosen to ensure a smooth, continuous path.
- U-turns and other special cases reuse the same arc-selection logic.
Closure and Guarantees
Start anchor is the previous segment’s final touchpoint.
Closed routes rejoin that start anchor by construction.
Path continuity is C0 everywhere and G1 at non-collinear line/arc joins. 9
radius < spacing / 2 is a local clearance heuristic, not a full non-self-intersection guarantee.
Traversal order choice is independent from geometric rendering rules.
9 Definition: C0 means no gaps; G1 means tangent direction matches across joins even if curvature magnitude changes. Visual result: linework reads as continuous and intentional, with smooth transitions. Reference: Smoothness.
Conclusion
We worked through a clear geometric framework for constructing kolam patterns. Paths are represented as ordered visits to dots. Tangency at each segment ensures mathematical precision and visual continuity. Arcs are used to handle turns smoothly. The notebook enables study, modification, and generation of kolam designs.
Kolams are a study in creativity, care, and connection. Working with these forms brings both mathematical satisfaction and a sense of beauty. I hope this notebook helps you appreciate and enjoy the art of kolam.
source: src/art/gen_svg/kolam.clj
