Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and processing.py

Sunday, 22 August 2010

LSystemUtilities for Processing

I've noticed a big uptrend in interest in my LSystem library since it got included in the Processing contributed libraries section.  There are proportionally fewer downloads than I expected, perhaps more people are downloading the source via SVN or git (but I doubt it).  Why should you want to download it:-

1. It is simple

2. Here are links to stuff I've done with it

Dome
Bent Hilbert
Rod Hilbert   Features use of cos/sin look up table utility
Peano Curve
Animated LSystem
Another Animated LSystem
A fern fractal I created before I implemented the Pen class, you could try converting it to use the new Pen class as an exercise.

Why did I create the library, well mainly for the experience?
What inspired me? Jeremy Ashkenas ruby-processing context free DSL.
It is that inspiration that made me try to keep things simple, using domain specific terminology and standard LSystem notation. One of the disappointments of java is how bloody complicated it has become it is a Behemoth, and that is surely one of the reasons for the success of processing.
If you are fed up with all the complication you should try ruby-processing. Links to ruby-processing on my other blog.
Although it doesn't have nice ide like processing there is a textmate bundle for the Apple folks, and I've created a tool (mainly a commando file for JEdit) that lets you launch your applets from the editor. JEdit has syntax highlighting for ruby built in, but you should probably install the RubyPlugin for extra features, and you will need to install the console plugin for the commando feature (JEdit has a superb built in manual so you just need to follow the instructions, while you are at it, learn how to create a macro to launch the commando file). You can even do live editing of your sketch.

By the way you are more than welcome to hack my library if you wish, it is dead easy if you've got netbeans, project kenai is closely integrated with netbeans. You will need to 'create' a processing library to hack processing with netbeans (set the path to the processing core.jar, and whatever other libraries you want to use). Earlier this year there was a bit of hiatus when it appeared as though Oracle was going to throw us amateurs off project kenai, they have since relented. It is possible that they may one day transfer us to java.net, when it gets the kenai functionality (I'm not sure what the status is regarding the creation of new projects).
Update December 2010, Oracle have been true to their word java.net is getting upgraded to be compatible with kenai (and hence netbeans). They expect to transition projects from kenai to java.net next year, so I'm happy to stick with them. The netbeans integration is excellent, and I've never really got on with eclipse. In my experience despite the availability of a template to create processing libraries on eclipse, it is actually far easier to use netbeans....(netbeans does not by default bundle libraries such as core.jar/opengl.jar in your library jar, something which seems to happen for some library developers that use eclipse).

Update 9 September 2012 since version 0.91 my lsystem library is compiled to run with processing-2.0b1+, anyone wanting to use it with earlier version should download version 0.81.

Update 22 November 2012, MouseWheel zoom for ArcBall is failing since NEWT jogl
processing-2.0b7, also you will need to explicitly import the CharacterIterator
import java.text.CharacterIterator;

Monday, 16 August 2010

Triple Spiral Another Ypsilon Scheme Context Free Sketch

Another example by Sordina translated to Ypsilon Scheme context free DSL.
   1 ;triple_spiral.sps
   2 ;After Triple Spiral
   3 ;By Sordina
   4 ;
   5 
   6 (import (rnrs)
   7         (psilab cfdg core)
   8         (psilab cfdg rule))
   9 
  10 (rule triple
  11    (1 (spirals 
  12       (brightness 1)
  13       )
  14    )
  15 )
  16 
  17 (rule spirals
  18    (1 (spiral)
  19       (spiral 
  20       (x 5)
  21       )
  22       (spiral 
  23       (y (* (sin 45) 5))
  24       (x (* (cos 45) 5))
  25       )
  26     )
  27 )
  28 
  29 (rule spiral
  30    (1 (circle)
  31       (spiral       
  32       (scale 0.99999)
  33       (y 0.1)
  34       (rotate 0.1) 
  35       (brightness -0.00005)
  36       )
  37    )
  38 )
  39 
  40 (init-cfdg)
  41 
  42 (background (brightness 1)) 
  43 
  44 (bounds -117 3 -60 60)
  45 
  46 (start-shape triple) 
























Here's a little bash script I created to simplify the input, and to automate the displaying of the image:-
   1 #!/usr/bin/env bash
   2 SPS=sps
   3 PNG=png
   4 LIMIT=256
   5 filename=$1
   6 outfile=${filename%.$SPS}.$PNG
   7 /usr/local/bin/ypsilon --heap-limit $LIMIT $filename --out-file $outfile
   8 feh $outfile

Interestingly I've used 45 in place of 60 degree angle in Sordina cfdg version, yet the result is more similar to the cfdg art, than when I used 60 degrees.

Another Context Free Sketch Using Ypsilon Scheme

Here's another example of translating cfdg context free rule to ypsilon context free. To get this one to run I needed to increase the heap size to 256 Mb.

   1 ;double_spiral.sps
   2 ;After Double Spiral
   3 ;By Sordina
   4 ;
   5 
   6 (import (rnrs)
   7         (psilab cfdg core)
   8         (psilab cfdg rule))
   9 
  10 
  11 (rule double
  12    (1 (spiral)
  13       (spiral 
  14       (x 2)
  15       )
  16    )
  17 )
  18 
  19 (rule spiral
  20    (1 (circle)
  21       (spiral       
  22       (scale 0.99999)
  23       (y 0.1)
  24       (rotate 0.1) 
  25       )
  26    )
  27 )
  28 
  29 (init-cfdg)
  30 
  31 (background (brightness 1)) 
  32 
  33 (bounds -125 15 -70 70)
  34 
  35 (start-shape double) 


Followers

Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2