[dokuwiki] Re: graphics in articles

  • From: jason-doku@xxxxxxxxxxxxxxxx
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 25 Jan 2007 16:57:08 -0700

Jay Dickon Glanville wrote:
On 1/25/07, Martin Tschofen <martin.tschofen@xxxxxxxxx> wrote:
Have you looked if any of these could do the trick? ...martin



What about a new plugin that uses the PIC language to generate
diagrams?  I've found the language very easy to learn and it's
surprising how much you can do with just a few lines.  For instance, the
source to get a diagram that looks something like:

----------        -----------
|  start | -----> | finish  |
----------        -----------

is just:

.PS
box "start"
arrow
box "end"
.PE


(you need to have fixed-width fonts to see the ascii art above).

While there is a GNU version of PIC packaged with the groff typesetting
system, I prefer to use Dwight Aplevich's implementation, called
"dpic".  Dwight added a few constructs to the language that make it much
more powerful, in my opinion, and his dpic program generates postscript
images as well as a number of other formats.

A plugin that uses this could have syntax something like:

<pic>
box "start"
arrow
box "end"
</pic>

The plugin would take the input, wrap it in ".PS" and ".PE" lines (like
above), run it through dpic to generate the postscript output, then
convert that to SVG or PNG or whatever else you wanted.  The resulting
image is cached and inserted into the page.  Is that very easy to do?
(I haven't written a plugin before, just fiddled and modified existing
plugins.)

With this plugin, the source is stored in the actual page, so is
versioned.  The image is cached, so it isn't regenerated each time it is
rendered.  The language has macros, so you can create your own
functions.  It also has for loops, if statements, etc.

I'll probably write this plugin someday, if someone hasn't beaten me to
it.  Feel free to beat me to it, though :).

-Jason


References:

The GPIC manual:
http://www.sm5sxl.net/~mats/text/unix/troff/gpic.raymond.pdf

DPIC implementation: http://www.ece.uwaterloo.ca/~aplevich/dpic/

(the dpic program includes the original PIC manual and the GPIC manual,
both in postscript format)



--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: