Blog Post RSS ?

Blogs » PHP » ASCII diagrams to image
 

ASCII diagrams to image

by Harry Fuecks

In:


    +---------+         +---------+     +---------+
    |  Shape  |         |  Line   |     |  Point  |
    +---------+         +---------+   2 +---------+
    | draw    +<--------+ start   +----O+ x       |
    | move    +<-+      | end     |     | y       |
    +---------+   \     +---------+     +---------+
                   \
                    \   +---------+
                     +--+ Circle  |
                        +---------+
                        | center  |
                        | radius  |
                        +---------+

Out:

UML from ASCII

Seems this is a to-be-released feature of docutils (Python) called aafigure – source available here – also see the README before and after. To install you’d need Python + PIL – after that download the various .py files from here and run aafigure.py --help from the command line. Able to generate svg, png or jpg.

Very cool. It’s not yet quite so clever to handle any old diagram from JavE, which doesn’t necessarily produce clean lines (depends on the drawing tools you used) and Iñtërnâtiônàlizætiøn is problem but this would be very handy for wikis and similar. Just needs porting to PHP…

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Ping.fm
  • Twitthis

This post has 12 responses so far

Sponsored Links

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

Follow SitePoint on...