~Karpie's Korner

Equation Art

Where the colour of each point is defined as a mathematical function of its co-ordinates

Wow, you must be interested if you actually want to read more about equation art. Getting into the depths of it can be kinda scary >.> But I'll do my best to explain it... in a non-scary way, while keeping true to form.

What is equation art?

Equation art is a method of generating (usually psychedelic trippy-looking) artwork. You've probably seen examples of it now, all over the site, and if you've dared to take a sneak peek into my equation art gallery.

For a detailed overview of how it works (you're THAT sadistic!?) feel free to scroll down. I put it at the bottom, I figured not many people would be interested ^_^

Who 'made' equation art?

That's up for debate, but my experience is that the term was coined by my best friend, Patrick Heddles. Before he came up with the idea sometime in 2004 (I think), others had been created computer- generated art, some using similar ideas, but none using the particular algorithm we now know as equation art.

In his experimentation with equation art, Patty created an online equation art generator. If you'd like to try it out for yourself, put in some numbers and figures and see if you can come up with masterpieces of your own (it's easier than it looks!), feel free to visit EACoder.

How did he come up with such an idea?

Believe me, I've asked myself that same question. Basically, Patty's one of those geeky types that likes to tinker with computers and programs and invent new things. Especially if it is said that something can't be done - he'll set out to find a way to do it. One of those pesky types that never takes no for an answer :P

One day way back when, young Patrick sat down at his computer and decided to write a ray-tracing algorithm. For what purpose, I do not know, nor do I have much of an idea what a ray tracer is. But he wanted one. His weapon of choice was BASIC - a olden-day programming language that no-one has used in about three hundred years. And he sat down, and wrote a program that generated an image. It wasn't a ray tracer image, but it was an appealing picture nonetheless. He saw the picture, and the picture was good. And he saw the potential of this program - to generate different pictures. Pretty pictures.

After scouring the internet to see if anyone had written any similar program, and failing (there was a something called algorithm art, but it turned out to be something different entirely), he coined the term 'equation art'. And he set off on a pilgrimage around the intarweb, trying to convert as many people as he could to this new method of artwork. Pretty art for non-arty computer-geeky people! Oh yeah!

How did you get involved in equation art?

Well, me being the best friend in all of this, I got to watch the entire ride of Patty discovering his craft, from start to finish. It's been my experience that most technical non-artistic people wish they could be artistic, and one day I expressed this idea to Patty. Naturally, he suggested equation art as an artistic outlet, where I could use my coding skills to improve on his concept, to take the ball and run with it, so to speak.

He says I'm a better programmer than he is, so the work behind the code comes more naturally to me, but I reckon he's full of shit. But I tried equation art anyway, and the results are what you can see here on the site.

OK OK, so how exactly does it work?

You poor thing. Couldn't help yourself, huh?

If you're not mathematically minded, you might want to skip this part, as it's not going to make a lot of sense. Imagine a blank canvas, whatever size you like. Now imagine this canvas as a blank graph, with a set of x and y axes on it. Any point on that canvas can be described in terms of its x and y co-ordinates. For example, the dead center of your canvas would generally be (0,0), the origin. And you could pick out any particular point, or pixel, like shown.

For the more graphically minded... ph33r mah Illustrator skillz

Now, the basis of an equation art program is the equations involved. As you may or may not know, a colour in computer terms is generally defined as a combination of red, green, and blue. And for each component, red green and blue, we set up an equation to represent that colour. The equations are functions of x and y - ie, the locations on the canvas.

For each point on the canvas, each pixel, we work out the x and y co-ordinates, then evaluate all three equations based on those co-ordinates. Add the results of the equations together and you have a number representing the exact colour of that particular pixel.

An example please!?

Oh, alright. A simple one. Say our equations are red = -18x, green = 30y, and blue = -12xy. For our sample pixel located at, x = -9.5 and y = 2.3, we then have red = 171, green = 69, and blue = 262.2 (which you can choose to round off to 262.) So that pixel, x = -9.5 and y = 2.3, has the color rgb(171, 69, 262) (the colour of that text).

That kinda makes sense...

Well, I hope so. Now that you've got one pixel's colour, repeat the process for as many pixels as there are in your image, then crunch all those pixels into an image format (usually bitmap or PNG). My images are all 800x600, meaning 480,000 pixels, or 1,440,000 equations to evaluate! This is why we need a computer program to do the job, because if there's one thing computers do extremely well, its number crunching.

Summed up in a couple of paragraphs, that's how equation art works. There are extra programming ideas to be taken into account (such as how to convert pixels to co-ordinates, or how to turn the list of pixel colours into an image) but that's the general gist of the theory.

For an online demonstration where you can try out equation art for yourself, should you be so inclined, feel free to visit Patty's EACoder. There you can design your own equations, and see the results, all automatically generated for you :)

How can you extend the idea?

The above wasn't enough for you? Aww, well... here goes with some of the stuff that I've been playing with.

Mathsy people will know that what I described above are equations with Cartesian co-ordinates, ie. a graphing system using x and y. Now, since I was a goody-goody uni student several years ago, studing maths, I made a switch to a different co-ordinate system, that of polar co-ordinates (equations of r and theta). All of the radial images you see in my gallery (such as Circlets or Lotus) use polar co-ordinates, while the linear images (such as Winter Loopy) are using traditional Cartesian co-ordinates. I quite like polar co-ordinates, you could even say I'm fond of them.

In particular, I like to mess with trigonometric functions of polar co-ordinates. C'mon, we all remember doing trigonometry in high school, however vaguely. Sines, cosines, tangents, and the like. I even go further and work with hyperbolic functions - though this can only be done in versions of the equation art program written in more modern languages than BASIC (due to limitations on the size of numbers in BASIC... no-one loves buffer underflow errors.) I enjoy what I do immensely, and I'm adding new images to my equation art gallery every now and then, as is Patty on his site.

I still remember the first time I truly impressed Patty with one of my pieces of art (Infinite). Puts a smile on my face, thinking about it :) Off to make more pretty artwork! Yay!