Pic language
From Christoph's Personal Wiki
Pic is a domain-specific language by Brian Kernighan for specifying diagrams in terms of objects such as boxes with arrows between them. The pic compiler translates this description into concrete drawing commands. Pic is a procedural programming language, with variable assignment, macros, conditionals, and looping.
Pic has some similarity with MetaPost and the DOT language.
Example PIC file
Create a file, foo.pic
, with the following:
.PS # Draw a demonstration up left arrow with grid box overlay define gridarrow { move right 0.1 [ {arrow up left $1;} box wid 0.5 ht 0.5 dotted with .nw at last arrow .end; for i = 2 to ($1 / 0.5) do { box wid 0.5 ht 0.5 dotted with .sw at last box .se; } move down from last arrow .center; [ if ( $1 == boxht ) \ then { "\fBline up left\fP" } \ else { sprintf("\fBarrow up left %g\fP", $1) }; ] ] move right 0.1 from last [] .e; } gridarrow(0.5); gridarrow(1); gridarrow(1.5); gridarrow(2); undef gridarrow .PE
Now, turn this PIC into a PNG with:
pic2plot -T png -f 0.012 --bitmap-size 1000x1000 foo.pic >foo.png convert -crop 0x0 foo.png foo.png
References
- Kernighan BW (1982). "PIC: a language for typesetting graphics". Software Practice Experience, 12:1-20.
External links
- Making Pictures With GNU PIC
- Troff resources (see the "pic" section)
- Turning PIC into HTML
- DPIC, an implementation of the PIC language by Dwight Aplevich. This implementation has a few nice extensions and outputs many different image formats.