Monday, 16 February 2009

EvoLisa "Viewer"

This post is related to Roger Alsing's EvoLisa (or GenArt, if you prefer) genetic algorithm. If you aren't familiar with it, read the FAQ and check out the Image Gallery.

Here's how it looks "in action": the image on the left is the 'source', on the right is the evolving polygon 'dna' (it gets gradually better as the dna evolves):

Actually that image is probably too complex to be a great example, sorry.

Anyway, that's old news. This post is because I've added a little piece of code to the 'ecosystem': a viewer for the .DNA files that also lets you save a high-resolution JPG copy. It was inspired by a couple of comments asking about exporting the images.

This is what the DNA Viewer looks like - on the left is a Xaml rendering, on the right is an Image. They both look the same - the interesting bit is comparing the code that generates each of them

The Image is generated by the existing Renderer class in Roger's source (which is also the logic used to save the JPG); the Canvas version uses a new (although very similar) WpfRenderer class. From that it was trivial to create the XamlRenderer which outputs a .xaml file which can be used to view the GenArt creation in Silverlight!

You can download a (16Kb) ZIPped exe to play with, or the WpfApplication itself can be reconstructed with the original source and these c# files:
Window1.xaml, Window1.xaml.cs, WpfRenderer.cs and XamlRenderer.

You can test it by unZIPping and opening the .dna file inside. I've uploaded a 3200x2032 copy of the image on Flickr to demonstrate the high-resolution output.

FYI, the relative file sizes are:
- operahouse6.dna 51.4Kb
- scene.xaml 17Kb
- operahouse6.jpg 371Kb

p.s. Roger has posted subsequent performance-related posts on EvoLisa, but I'm not sure he's released the source for them yet.

UPDATE [17-Feb-09] another example:
Opera House by day .DNA 49Kb (ZIPped 17Kb)
Opera House by day (Silverlight 17Kb)
Opera House by day (Flickr 1920x1440 162Kb)

While I was testing the new 'DNA', I added SvgRenderer as well (needs updated Window1.xaml.cs). At first it didn't seem to work (left image) because I couldn't figure out how to make the background black. Decided to draw a big black rectangle behind the rest (bit of a hack, but it works). You can view operahouse_day.svg.xml (21Kb) in Firefox.


  1. I know this will probably be a silly question, but how do I 'compile' the updated Windowl.xaml.cs file to allow for svg output. I'm looking to have a version of WpfApplication.exe that has svg output. Maybe I'm just reading it wrong.

  2. I have Visual Studio and some others...

  3. There is a link to Roger's source near the start of the post - you need to download the source-code from there first. Make sure you can compile and run it successfully before making any changes.

    THEN replace his Window1.xaml.cs with my version and add my SvgRenderer.cs class to the project.

    It will then output SVG like this.

  4. Hi
    Try this one:

  5. Can you please just release a compiled version with SVG support?
    I can't build it on my own since I have no experience with C# and can't follow this instruction
    >replace his Window1.xaml.cs with my version
    there is no Window1.xaml.cs file in the original EvoLiza source.

  6. Any chance of getting the (16Kb) ZIPped exe

    Tried to access from the above link, but not able to.

  7. oh boy... it's been ages since I've looked at this. I'll try to dig the code out in the next few days, if I find it I'll update the post.

  8. None of the links are working, can you please fix this? I tried writing my own svg renderer, but it fucks up at some point and I can't understand why.

  9. I found the code on an old hard drive. It's now on GitHub so it shouldn't disappear again.

  10. Is it possible you could take the files from GitHub and turn them into an executable as I'm not sure how it's done myself. Sorry, thanks in advance. ^^