Python Randomized Zellige

see full process & documentation on Google Colab here!

-----

Solo development - Python (Turtle, image output, randomization, procedural & function-oriented)

-----


Some examples of output from the program.

Generating Islamic tiling patterns through Python code, using Turtle

In my visual work, I am often referencing Moroccan cultural imagery. Zellige is one such piece of iconography which I have grown up around and only learned to appreciate once I had moved away. Zellige designs are complex, striking, and varied, but my favorites are the concentric star-like patterns often seen in fountain tilework. As these patterns are geometrical in nature, my aim with this project was to find a way to generate unique variations digitally, which would make them easier to use in my graphical work than free-handing or designing one manually from scratch each time.

In my process, I started with researching papers documenting both the mathematical processes for design and the types of islamic tiling.

I have referenced Islamic Patterns Constructed by Craftsmen Working on Wood (2011, Thalal & Al), J. Bourgoin's Les éléments de l'art arabe (1879), the website entrelacs (https://castera.net/entrelacs/entrelacs.htm), and the textbook Turtle Geometry (1981) by Harold Abelson and Andrea A. diSessa.

From these resources I pulled a lot of reference material, and started to study the patterns geometrically to understand how to replicate them in drawing. I did this so that I could break down the steps into functions that I could then implement in python.

Code Samples

In my research, I arrived at the conclusion that one can theoretically derive a concentric star pattern from any random line, so long as it is mirrorred and then repeated around a center point. I therefore defined a gen_vals(n) function, which generates n random lengths and n random angles.

Then, Squig4 (named as such because Squig3 was a failed attempt) takes those values, and generates a line containing n segments. Each segment is drawn using the length & angle parameters of gen_vals.

I did it this way so that all the random values could be generated only once at the start, and then the Squiggle could be reused without getting scrambled each time.

The parameters of the starter Squiggle line can be altered by changing the range of randomness within gen_vals (default for angles = -90:90 and default for lengths = 20:100, at lines 12 and 13 respectively) and/or the amount of segments in a given Squiggle (on line 17, the value of the variable 'segments'). This permits the user to modify the scale & possible complexity of the final Star pattern.

Now that we our Squiggle function, we must mirror it to create a Shape. This Shape, when replicated symmetrically around a given point, creates a Star.

The Shape function below takes a direction integer (angle to face), a coordinate tuple, and a Squiggle function as arguments. It then draws the Squiggle and its mirror at the coordinate, facing the given direction. This is useful, as when we later use this Shape in a Star, the direction angle will change with each iteration to make its way around 360 degrees.

The following Star function takes for argument the original Squiggle, the Shape (that it will call by passing the Squiggle), and optionally, how many repetitions of a Shape will the Star contain. It also starts off facing the 0 direction by default, but this too can be modified optionally by passing a different argument in the 4th position.

This is how you could, for example, call the program to randomly generate a given Star such as the one below.

Here, I gave gen_vals(n) the int argument 6 so that it would create a 6-segmented Squiggle (tends to be shorter than, for example, a 12-segmented Squiggle, for a more proportional pattern).

And then, this is the same star, but colored in with a random RGB value and an evenodd fillrule.


-----

back to main page