After meaning to get around to it for quite a while, I’ve finally released version 0.2 of the Haskell diagrams library. Here’s the release announcement. And here’s one of my favorite examples showing off the new path support:

Heighway dragon
I made this Heighway dragon curve in just a few minutes of hacking this afternoon, with the following code:
{- Heighway dragon. See http://en.wikipedia.org/wiki/Dragon_curve. -}
module Main where
import Graphics.Rendering.Diagrams
import Control.Monad.State
import Data.Maybe
dragonStr :: Int -> String
dragonStr 0 = "FX"
dragonStr n = concatMap rules $ dragonStr (n-1)
where rules 'X' = "X+YF+"
rules 'Y' = "-FX-Y"
rules c = [c]
strToPath :: String -> Path
strToPath s = pathFromVectors . catMaybes $ evalState c (0,-1)
where c = mapM exec s
exec 'F' = Just `fmap` get
exec '-' = modify left >> return Nothing
exec '+' = modify right >> return Nothing
exec _ = return Nothing
left (x,y) = (-y,x)
right (x,y) = (y,-x)
dragon :: Int -> Diagram
dragon = lc red . curved 0.8 . strToPath . dragonStr
main = renderAs PNG "dragon.png" (Width 300) (dragon 12)
A special thank you to Dougal Stanton for adding text rendering support and other features, switching diagrams over to Russell O’Connor’s colour library, and generally helping out with this release.
The patches you made after I left look really good. I’m sorry I didn’t get that colour thing working as best it could.
But the path work — and that dragon! — really cool. I’ll see what I can do about working up some projects that use the new features now.
Dougal: hey, no worries. I don’t think I’ve quite got it working as best it could, either. =) You did some good work, and I’m grateful!
Projects that use the new features would be great! We need some cool projects to drive development of more new features. I have some ideas for one or two of my own, as well.
Pingback: Looking Out To Sea » In support of a release announcement (or, Pimp your diagrams package)
Hi Brent,
Diagrams looks great but so far no go.
Any chance of a fix for cabal install cairo -any problem?
It’s needed for formlets.
Cheers
Jim
Hi Jim,
Unfortunately, the cairo package has not (yet) been cabalized, for, I’m told, various technical reasons. As explained in the installation instructions, you have to manually download and install gtk2hs (which includes the cairo library). A bit of a pain, but that’s the way it is for now. Hopefully at some point in the future the cairo bindings will be split out into their own package and cabalized.
Pingback: Imitating Metapost using Haskell « Random Determinism