The Frustrating Magical Aspect

December 4th 17:29
by why

While plundering around in the NodeBox forums, I happened upon a very stirring library for creating SVG drawings in Ruby. Goes by the name of XRVG.

Let me give you an idea of the mind at work behind this. XRVG is a response to “the frustrating magical aspect of generative fractals like the Mandelbrot set” and, perhaps even moreso, “the hermetique aspect of the dominant graphics programming toolkits notation.” You get the sense this fellow’s trying to work out new ways to express shapes, particularly generative shapes like fractals.

And, for further study, I highly recommend the author’s blog of fractals, which he has filled with nearly 200 samples throughout the year.

Toward the middle of the philosophy page, XRVG’s author Julien Léonard goes into a very compelling rationale for why XRVG strays from using coordinate systems. I’m quoting liberally from this, because it’s really fantastic stuff that speaks well on behalf of context-free art kits.

Nearly every programming toolkit that you may find, in any programming language, instanciates shapes with absolute geometrical coordinates. What that means is that if you want to do graphics programming with them, you rapidly get lost in a list of basic drawing primitives with lots of numbers, without being able to recover the abstract compositional content of the graphic.

Actually, a graphic is foremost a composition of basic shapes and color. It is not their absolute values (that is absolute spatial and color coordinates) but their relations that matters. This is even more true because our visual perceptive chain processes its inputs in a relative way, as paradoxical visual games highlight it.

As a consequence, XRVG strives to get rid of these absolutes, by using shapes and functions as numerical patterns to compute shapes and composition. Thus, if you want to draw five circles in a regular way, you must be able to do it without using trigonometric formulae to figure out where these circles have to be drawn. Instead, you just need to use a first circle and “sample” it five times to have subcircle centers.

Now begin the comments …



said on December 4th 13:51

That’s a pretty neat library! Since you seem to know your way around the graphical libraries in Ruby, are there any pure-Ruby libraries you recommend for generating pretty graphs of data?

I liked your post on Processing but don’t have the time to get cracking with JRuby at the moment.


said on December 4th 16:15

Anything else than sudo gem install xrvg i need to get ‘require “xrvg”’ to work in irb? O_o

little gray alien

said on December 4th 16:54

This could be useful for prototyping crop circles.


said on December 4th 18:00

Seb: Well, if we can get the gem to work, you could use XRVG to create graphs. It generates an SVG file, which is just an image format.

But, since I imagine you’re asking for business purposes, I think a lot of people use libraries like Gruff or Scruffy or RMagick, all of which generate the good old formats for the web. PNG and JPEG .

magiker: Sure enough, I can’t seem to find a version that works either. ミ◎_◎彡,,/)


said on December 4th 18:03

I get LoadError: no such file to load — attributable when I try to use it after installing the gem.

Bill Mill

said on December 4th 18:21

@magiker do you get “LoadError: no such file to load — attributable” like I do?


said on December 4th 19:45

After a bit of detective work, it turns out attributable.rb was last seen in xrvg-0.0.3. I don’t know how it got removed from later versions, but it’s in there. I made a pastie of it so you can print it out and show to your grandma:

At least that’s what I’m doing with my print copy.

Peter Cooper

said on December 4th 20:28

I get the attributable error like those above.

I downloaded and unpacked several old version of the library and attributable.rb was still not present.. so I went back all the way to 0.1 and it’s in there. I’ve put it up at

I added that to the latest version of xrvg and.. then I get a different error:

uninitialized constant XRVG ::Samplable (NameError)


This is just a experimental beta – hold out until the developer releases a version that works :)

Peter Cooper

said on December 4th 20:29

I guess this shows the value of refreshing before posting. seydar’s approach and mine match – although it still doesn’t work for me :)


said on December 5th 00:28

@_why: yeah, the gem not working is kind of a deal-breaker at the moment. :P

And you’re right, I was asking on a business note, but they like pretty graphics where I work, so I thought it was worth asking. Thank you for the links!


said on December 5th 00:47



said on December 5th 03:07

At first I didn’t really get all the nodebox/processing/fractal enthusiasm on here, but it is definitely growing on me.


said on December 5th 04:31

I’m also getting the attributable error and then the uninitialized constant XRVG ::Samplable after install the suggested pastie. Think I’ll drop a bug in Rubyforge about it.


said on December 5th 06:22

Hello everyone, I’m afraid I am the author of the XRVG library :-)
First my apologizes about problems encountered with the XRVG gem, I actually didn’t test gem building and installation carefully (mainly because I prefer drawing something than making an install :-(.
Second, I am very pleased to notice interest here, so I will try to release a next version usable very soon so that you may play with it for the WE.
Last, thanks a lot “why” for your article.


said on December 5th 08:11

Awesome, thanks Julien! I’m really looking forward to checking this out.


said on December 5th 16:31

I’ve got the gem working after some help from Julien:

Add the attached attributable.rb to the xrvg gem lib directory, then add:

require ‘forwardable’

to lib/spiral.rb

Works for me.

Trying to make it work..

said on December 5th 20:53

I installed the gem, followed those instructions, but..

“LoadError: no such file to load — xrvg”



said on December 6th 07:17

now the gem works perfectly and I’m already in love with it.
Checking the implementation details and I definitely like the work done on ranges.

off to fractalize some reality now!


said on December 6th 09:32

As Onigiri wrote it (by the way, thanks a lot for your message), XRVG gem must be usable now (I added attribute.rb, and remove (for the moment) dependancy on Forwardable). Note however that the example in README is broken :-(: you must add a “include XRVG ” line after “require”, as XRVG had been packed in a namespace.
If you “read” through fractalyze blog, you may have noticed that for the last six months, I actually rewrote XRVG into C++ (CVG), to gain efficiency. As a consequence, XRVG developpment has been frozen since :-(.
Anyway, I hope XRVG would be useful whatever your purpose, and be sure to check tutorials page ( to ease your learning curve. Wish you a nice hacking :-)

on making it work...

said on December 6th 20:14

This was probably obvious to you guys, but it didn’t work for me until I added: include 'rubygems', which is not included the sample or tutorial files.


said on December 7th 09:29

“on making it work …”, well, no, it is absolutely not obvious to me but weird that you need to include rubygems to use XRVG . I cannot write about XRVG gem (as I us e code straightforward instead of gem), but for other gems I downloaded, I never needed to do such a thing. Furthermore, Onigiri did not seem to have problem … Maybe something wrong with your ruby install ? Anyone else got this problem, and solved it ?


said on December 7th 23:44

on making it work…: A lot of people have the RUBYOPT environment variable set so that RubyGems is automatically loaded. See the end of this page.


said on December 8th 18:09

Because lolcats are coming back in a big way.

Bil Kleb

said on December 11th 18:37

Thank you Julien and Why: this post sparked an idea for unstructured grid generation as used in Computational Fluid Dynamics. I’ll be sure to pass along results if the idea pans out. Thanks again!


said on December 12th 06:21

Be sure to share your progress, I am very interested in (once I used to do a lot of fluid mechanic, but I switched to softdev :-).

Bil Kleb

said on December 22nd 21:27

It seems that my idea has already been developed—see Bubble Meshing and the man behind it, Kenji Shimada.

Comments are closed for this entry.