Posted: 2020-03-07 16:48 | More posts about art code music
I'm very fond of Liz Harris's art — so much so that I have a small canvas print of the cover for the Grouper single "Water People" hanging in my living room. The cover looks like this:
This morning, having spent the last few days on sick leave from work, it caught my eye and I decided to relieve my boredom by attempting to recreate it in code. One naive solution is simple:
- Draw a square - a "segment" - containing 7 inner squares, with an equal amount of spacing between each, and diagonal lines from the top-left to the bottom-right and bottom-left to top-right.
- Repeat this N times from left to right, ensuring segments are visibly stacked towards the center, to draw a row.
- Repeat this N times from top to bottom, ensuring rows are visibly stacked towards the middle, to draw the full canvas.
- Draw two lines that span the entire height and width of the drawn area, meeting in the center, forming a cross.
I've never ever done any graphics programming before and have a questionable grasp of mathematics, so I was pleased with the result after an hour's hacking, regardless of how trivial the problem is. You can see it here:
The code (~50 lines) can be viewed on github and requires no dependencies to run
(apart from the
graphics.py library, which is checked in to the repo.)
Its parameters (e.g. padding, number of segments per row, etc.) can easily be played around with.
After many years of programming professionally, it is nice to create something inefficient and functionally useless but aesthetically pleasing — just for the sake of creating something.