In this post I’ll explain how I combine coding in python with hand drawn artwork to generate an infinite number of unique images. The concept came about while doodling interconnected pipes and realizing it might be possible to automate or scale this technique very quickly using code. I’ve played around with the wave function collapse function in the past to generate more “structured” images, but never using hand drawn images. My thought was that I could make the images look more real with hand drawn building blocks.





I won’t go into the details of the algorithm here as that’s not the intent of this post, but there are many great articles explaining it in great detail across the internet and I’m sure chatGPT can also provide a nice overview. The general idea is that you pick a tile at random and place it into the canvas and then select the set of all tiles that will “fit” with a tile already placed on the canvas and then pick one at random. It gets more complex as more tiles get placed as every tile can have up to 4 other tiles attached to it. The beauty of the code is that it figures this out for you. I learned most of what I know about it from The Coding Train in case you want to explore on your own.
A sampling of the hand drawn tileset I created in photoshop (using a pen tablet) is shown below. Each is saved as a transparent .png file to allow the underlying background layer(s) to show through. In this case, the background is simply black.

In this case, the tiles are made to resemble plumbing parts such that the edges of each tile can fit with other tiles in the set. This is done by using a 3×3 grid with each edge cell in the grid either a blank (B), narrow pipe (N) or wide pipe (W). Each edge of each tile is then designated a 3 letter code corresponding to what was drawn in that section starting from the top edge and moving clockwise around the tile.
Looking at the tiles below, we would have the following representations:
- Tile 1: [ WNB, BWB, BNW, BBB ]
- Tile 2: [BNB, BNB, BNB, BNB ]
- Tile 3: [ BNB, BBB, BBB, BNB ]
To avoid having to draw hundreds of tiles, each tile is rotated 3 times within the python code to generate rotated version of each. This allows for an even more unique final image.
To-date, I’ve created 29 different plumbing component tiles consisting of elbows, tees, intersections, valves and caps. This set of tiles results in an infinite set of python generated doodles which look hand drawn since every piece of the overall image is, in fact, hand drawn.
To make things more interesting and to give the appearance of depth, I modified the code to overlay each new image fading the previous images over time. As you can see, this leads to infinite possibilities.



So, where do I go from here. My plan is to modify and extend the tileset to look even more realistic and complex by adding guages, valves, interconnects and vines growing around the pipes. I can also modify the probabilities to generate images with more straight sections, more valves, and so on.
I also plan to create additional tilesets for different subject matter ranging from technology to nature themes. My next project will likely be based on neurographic art. If you have other ideas or would like to learn more, please leave me a comment below!