Now For Something ...
I’m sort of burned out on linkages. A confluence of coincidental occurrences has me entertaining myself with Celtic Knots. Is there programming to be found here?
The charming Calligrafae, also found at, draws lovely things like this one, done as a commission from me:

Please consider the above as copyrighted, owned by me, not for reuse, even if it speaks to you as it does to me.
And it came to pass in those days that Calligrafae offered a 10 page course in drawing Celtic Knots, which appealed to me as I used to be able to draw somewhat and am seriously out of practice. Even when I was in practice, my drawings were unquestionably better than those of people who never draw, and not many others, but I’d been wanting to get back to it. So I got the course, and began drawing things. Here’s one of my favorites so far:

You can see that while I have the algorithm pretty well figured out, my skill is still not entirely impressive. Part of that is impatience, part is due to the fact that I hold my iPad in one hand while drawing with the other, part due to the unsteadiness of old age, etc etc. But I continue to improve, and the process is a bit like meditation: it takes enough attention that one can’t think about all the horrors, which do persist, as all here surely know.
I’ll not steal Calligrafae’s thunder here, but I need to share a bit about the “algorithm” that one follows to draw these things. Here is a diagram showing the base pattern one starts with, with a knot drawn in light gray on top of it:

We start with a grid of the size of the knot we want to draw. We put circles around all the integer points of the grid, and in the center of each square of the grid. We want the circles to be all the same size. If they are large, the resulting knot ribbon will be narrow. If they are small, the knot ribbon will be wide.
The main process consists of starting with a diamond made up of four dots top bottom left right. We draw two parallel lines, tangent to the dots, on the inside of the diamond. We can pick either direction, southwest to northeast or southeast to northwest. Then, at each of the sides of that diamond, we draw parallel lines in the adjacent diamonds, at right angles to the first one’s lines.
When we reach an edge, we cannot draw our lines outside the box, so we might stop along that path, for now, and proceed until we have all these easy ones filled in. (There can be “break” lines in the diagram, as shown in the example above, and we do not draw our lines if we’d have to cross a break line.)
After some time, we have reached all the edges and break lines and, assuming that we have not messed up somewhere, the necessary continuations all offer only one possibility, the curved lines along the sides of the above diagram, or the loop-back ones in the corners. There are a few possibilities not shown in the simple diagram. I the colored one above you can find one such possibility, two intertwining ribbons forming a sort of twist that is one cell wide. There is at least one other such pattern that can occur in corners.
If you decide to try this, and if you enjoy this sort of thing I certainly recommend it. I’d suggest that you pick up Calligrafae’s little course: it’s just a few quid and is a good start. Failing that, there are some videos out there, as you might expect. And, as you might expect, some of them are quite good and some not so much. You know the drill.
But anyway …
GeePaw Hill wondered whether there was a possible little programming project in these things, something that our Zoom Ensemble1 might work on variously, individually and severally, resulting in the kind of thing that amuses us, looking at different solutions and discussing them. Let’s think about that.
What might we program that would be fun, interesting, or useful? I can imagine at least these ideas:
- Define a diagram, have the computer draw the squares and circles to serve as a base for human drawing.
- Define a diagram, have the computer draw the easy part of the ribbon;
- Define a diagram, have the computer draw the entire resulting ribbon.
- Define a diagram, have the computer place drawing elements as the human selects them.
Hill was thinking that a given program might not have to do the graphics, instead producing a solution in some other form, which could be drawn by separate code, so that those of us who prefer to work on the “model” part of things could solve the problem abstractly. It seems to me that any reasonable program in this space would want a decent internal model, other than perhaps the last one, where you just drag pictures into a grid. So a model-only solution would be interesting, at least to the likes of us, because we are that kind of person.
When you look at a knot with the grid drawn over it, it is immediately clear that there are only a few possible patterns in a square. How many is a few? I have not counted, nor have I found anything on the web that tells me the answer, but it’s more like ten or twenty than a hundred. There are rotations and reflections to consider, so it will depend how one counts. Here is a large knot where I have colored cells containing the same shape the same colors:

In a large knot, the most common grid cell has a sort of windmill shape in it, the blue cells in the above diagram. There are two such four-armed shapes, which are mirror images of each other, I believe, but have not shown, that any contiguous knot can only include one of the two possible windmills. If that’s true, then each such diagram has two related forms with everything the same except everywhere reversing which ribbon is on top.
However. In a simple-enough knot, the windmill pattern never appears in a cell. So while it is tempting to think of a program working at the level of cells, it’s possible that we would have to work at the level of the inner diamond shapes, similarly to how we do it as a human. When I’m drawing a knot, I don’t draw a windmill. The windmill in a given cell emerges from drawing the parallel lines in the four diamonds that share the circle at the center of the cell.
Intuitively, I think I’d prefer a programming solution that works at the cell level rather than at the diamond level. What I find most interesting about that preference is that when I solve them by hand I do not think in terms of the cells, only the diamonds. But when I look at the shapes diagram above, the individual cells stand out, not just because they are now different colors, but even with just the lines drawn. It seems clear that there is a semantic aspect to the cell’s contents, and I can imagine a game consisting of a bunch of tiles with the patterns on them, where one would build up a knot in a sort of knotty game of scrabble / dominoes / mahjong. Might even be fun.
So would we do better programming to the cells, or to the diamonds? I don’t know. I’m not ready to answer the question, and I’m not ready to start programming today. Might wait until after the holidays.
I do think I know what I might do first, to sharpen my Python graphics: I will probably come up with code that will draw a grid with the circles, perhaps allowing specification of the number of rows and columns, and the circle size. Then I’ll import those into Procreate and use them to draw things by hand, which I still enjoy.
What we have here, I guess, is a report of a bit of design thinking, which may result in a programming exercise. Or maybe it’s just a report about something I find rather meditative and distracting.
I wish you happy holidays, and a better new year than this one was, and more of the same forever after.
-
FGNO - Friday Geeks Night Out, a Zoom meeting held each Tuesday evening, which I hope is obvious to all here. ↩