Mathematics and Computation

A blog about mathematics for computers

Random art in Python

I get asked every so often to release the source code for my random art project. The original source is written in Ocaml and is not publicly available, but here is a simple example of how you can get random art going in python in 250 lines of code.

Download source: randomart.py

The idea is to generate expression trees that describe an image. For each point `(x,y)` of the image we evaluate the expression and get a color. A color is represented as a triple `(r,g,b)` where the red, green, blue components are numbers between `-1` and `1`. In computer graphics it is more usual to use the range `[0,1]`, but since many operations are symmetric with respect to the origin it is more convenient to use the interval `[-1,1]`. I kept the program as simple as possible, and independent of any non-standard Python libraries. Consequently, a number of improvements and further experiments are possible:

Comments

red,green,black?! Probably should be blue.

Oops, fixed it, thanks!

Ghislain LEVEQUE

Well, it's fun because I was thinking that the interesting part in your random art is not the generation algorithm but the functions used and I see you released the algorithm and some functions but you keep the nicest functions.

I guess this is normal as the functions are the "art" part of the project and your additionnal value over the plain theoric application.

Nice work indeed !

desolate

Your fans are dazed, confused and worried. Is Random Art gone for good? Will it be back again, perhaps, in a new improved version? When? Please, a few words of assurance or solace for your followers?

It's temporarily down because my server is getting flooded by Hacker News (a social bookmarking site read by too many people). I think the main wave is over, so I will turn on random art shortly. Sorry for the inconvenience.

Deb

Thank you Andrej! I too have been bereft and worried. Look forward to being back to normal and making beautiful stuff again! Deb

Jesse Cochran

In my opinion, there should be an added string where you follow the "randomart.py" command with text or a binary file, and art can be made from that.

Asmodeus

I agree. I tried to fiddle with the randomart.py and to some degree I managed to make the output depended on manually made input but... it's far from perfect. Plus the output images do not align with those created by the generator on www.random-art.org

I would appreciate some help too.

Nice work

Sylvain

I would love to continue building on your python code. Is this the help you are looking for ?

Check out this animated GPU-accelerated random-art renderer, LIVE demo: https://vshymanskyy.github.io/randomart/

Tim {TVNF}

Hello anyone, I found this page after hours of searching for info on random-art. I've decided to make a little project out of trying to find out about users of random-art, and since some people here left comments worried when it went down, I figured that these people would be most likely to be active.

I'm specifically looking for MethMode, the user who's been by far the most prolific (or the most prolific moniker used by dozens of different users, I guess). I'm using r-a a bit now as {TVNF}.

Thanks in advance :)

How to comment on this blog: At present comments are disabled because the relevant script died. If you comment on this post on Mastodon and mention andrejbauer@mathstodon.xyz, I will gladly respond. You are also welcome to contact me directly.