Basic use of PIC for old drawing tools

Source: Internet
Author: User
Tags chop

The author's Little White has a special feeling for the drawing of WYTIWYG (what are you Think are what Get). Before I heard of MetaPost and asymptote two kinds of drawing tools, many netizens say, two kinds of drawing tools, will one, can meet the needs of a lifetime.

The author also inadvertently found Uncle Raymond (yes, the author of the Cathedral and the Bazaar) wrote an article "Making Pictures with GNU pic", introducing the basic use of pic. Which, in the article says,


"The pic language is a troff extension this makes it easy to create and alter box-and-arrow diagrams of the kind Frequentl Y used in technical papers and textbooks. ”


Are you familiar with the author of pic? Before the little white did not say, it is estimated that very few people guessed, yes, he is the brain kernihan of Bell Labs, one of the authors of the C programming Language, and one of the authors of awk.


Well, the others do not pull that much, just a few examples. All pic code needs to be placed between. PS and. PE, similar to MetaPost's Beginfig and Endfig.

The following two illustrations are examples from the help documentation and have a good learning guide.

Example 1:

$ cat pic08.pic . psdefine filter {box ht 0.25 rad 0.125}lineht = 0.25; top: [     right;     box  "\fBms\fR"   "sources ";     move;     box " \fBHTML\fR " " Sources ";      move;     box  "\FBLINUXDOC-SGML\FP"   "sources"   wid 1.5;     move;     box  "\fBTexinfo\fP"   " Sources ";     line down from 1st box .s lineht;      a: line down;     line down from 2nd  box .s; filter  "\FBHTML2MS\FP";     b: line down;      line down from 3rd box .s; filter  "\fbformat\ FP ";      c: line down;     line down from  4th box .s; filter  "\FBTEXI2ROFF\FP";      d: line  down;] move down 1 from last [] .s; anchor: box wid 1 ht 0.75  "\FBMS\FR"   "intermediate"   "form";arrow  From top.a.end to anchor.nw;arrow from top.b.end to 1/3 of the  way between anchor.nw and anchor.ne;arrow from top.c.end to 2/3  of the way between anchor.nw and anchor.ne;arrow from top.d.end  to Anchor.ne{     # PostScript column      move to Anchor .sw;     line down left then  down ->;     filter  "\fbpic\FP ";     arrow;     filter " \fBeqn\fP ";      arrow;     filter  "\FBTBL\FP";      arrow;     filter  "\FBGROFF\FP";     arrow;      box  "PostScript";     # html column      move to anchor .se;     line down right  then down ->;     A: filter dotted  "\FBPIC2IMG\FP";      arrow;     B: filter dotted  "\fbeqn2html \FP ";     arrow;     c: filter dotted " \ FBTBL2HTML\FP ";     arrow;     filter " \fBms2html\fP ";      arrow;     box  "HTML";     # nonexistence  caption     box dashed wid 1 at b +  (2,0)   " These tools " " Don ' T yet exist ";     line chop 0  chop 0.1 dashed from last box .nw to a.e ->;      line chop 0 chop 0.1 dashed from last box .w to  B.e ->;     line chop 0 chop 0.1 dashed  From last box .sw to c.e ->;}. PE

How does the above code compile?

$ pic Pic08.pic |groff |ps2eps > pic08.eps$ epstopdf pic08.eps$ evince pic08.pdf

Note: The Texlive kit is already installed in the small white computer, so the above procedures are already available. So, if you do not have the appropriate tools on your PC, please install them yourself.

For:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/C0/wKiom1WE8_DQ06ssAAE3Yur5x3s264.jpg "title=" Pic08.png "alt=" Wkiom1we8_dq06ssaae3yur5x3s264.jpg "/>

Example 2:

$ cat box01.pic.psdefine ndblock {       box wid  boxwid/2 ht boxht/2       down; box same  with .t at bottom of last box; box same}boxht = .2;  boxwid = .3; circlerad = .3; dx = 0.05down; box; box;  box; box ht 3*boxht  "."   "."   "." l: box; box; box invis wid 2*boxwid  "Hashtab:"  with .e at  1st box .wrightStart: box wid .5 with .sw at 1st  box.ne +  (. 4,.2)   "..." n1: box wid .2  "N1"; d1: box wid  .3  "D1" n3: box wid .4  "N3"; d3: box wid .3  "D3" Box wid  .4  "..." n2: box wid .5  "N2";  d2: box wid .2  "D2" Arrow right from 2nd boxndblockspline -> right  .2 from 3rd last box then to N1.sw +  (dx,0) spline - > right .3 from 2nd last box then to D1.sw +  (dx,0) arrow right from last boxndblockspline -> right .2 from 3rd  last box to n2.sw-(dx,.2)  to n2.sw+ (dx,0) spline -> right .3  from 2nd last box to d2.sw-(dx,.2)  to d2.sw+ (dx,0) arrow right  2*linewid from Lndblockspline -> right .2 from 3rd last  box to n3.sw +  (dx,0) spline -> right .3 from 2nd last  box to D3.sw +  (dx,0) circlerad = .3circle invis  "Ndblock"   at last box.e +  (1.2,.2) arrow dashed from last circle.w to last box chop 0  chop .3box invis wid 2*boxwid  "ndtable:"  with .e at  Start.w.pe

For:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/BC/wKioL1WE9nuxXt02AAHgI_CGXUk978.jpg "title=" Box01.png "alt=" Wkiol1we9nuxxt02aahgi_cgxuk978.jpg "/>


Small white use two lunch break time, roughly read the pic of the help document, not difficult, more practice a few small examples, basic can master its usage. I have also drawn the following several graphics, only for the needs of netizens reference, one is awk work flow chart, one is in the SED work flow chart, because pic temporarily does not support Chinese, so, the use of the E-text here.

Example 1:

$ cat sedworkflow.pic . psa: box ht 0.8 rad 0.08  "line 1"   "line 2"   "Line 3"   "line 4"   "b: box width 1.8 " \fbread\fp a line into  the " " Pattern space " with .nw at A.ne +  (0.5,0) c: box  width 1.8  "\fbexecute\fp given sed commands"   "on the pattern  Space " at B -  (0,0.8) d: box width 1.8 " \fbprint\fp the  Pattern space " " And empty it " at C -  (0,0.8) e: box width  1.8  "\fbrepeat\fp for the next line until"   "end of the  input file " at D -  (0,0.8) f: box width 0.5 ht 0.35  rad 0.05  "Line 1"  with .w at B.e +  (0.35,0) g: circle& nbsp;" Output " with .w at D.e +  (0.35,0) l1: line chop 0.01 chop  0.9 FROM 1ST BOX AT 1/3 <A.E,A.NE> TO B ->L2:  line down from b to c -> chopl3: arrow down from  C to D chopL4: arrow down from D to E chopL5:  Line dashed from b.e to f.w ->l6: line dashed from c.e  to F.w ->L7: line dashed from D.e to G.w ->L8:  Line down 2.85 from l1 .centerl9: line right from l8.end to  E.s -  (0,0.2) l10: line from e.s to l9.end.pe

The graphic effect is:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/BC/wKioL1WE-ZvSPL2BAAGcQVY7MIk451.jpg "title=" Sedworkflow.png "alt=" Wkiol1we-zvspl2baagcqvy7mik451.jpg "/>

Example 2:

$ cat awk_workflow.pic . psa: box ht 0.8 rad 0.08  "line 1"   "line 2"   "Line 3"   "line 4"   "..." infile:  "\FBINPUT FILE\FP"  with .n at a.s -   (0,0.15) b: box width 1.8  "Read a line"  with .nw at  a.ne +  (0.5,0) c: box width 1.8  "Execute awk commands"   "in  The \fbbody\fp block on the line " at B -  (0,0.8) d: box  width 1.8  "\fbrepeat\fp for the next line until"   "end of the  input file " at C -  (0,0.8) e: box width 1.8 rad 0.1   "Execute awk commands in"   "The \fbend\fp block"  at d -   (0,0.8) f: box width 1.8  "execute awk commands in"   "the&Nbsp;\fbbegin\fp block " at B +  (0,0.8) l1: line chop 0.01 chop  0.9 FROM 1ST BOX AT 1/3 <A.E,A.NE> TO B ->L2:  line down from b to c -> chopl3: arrow down from  C to D chopL4: arrow down from D to E chopL5:  Line down 2 from l1 .centerl6: line right from l5.end to  l4.centerl7: arrow  from f.s to b.n.pe

The graphic effect is:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/BC/wKioL1WE-bWBf8vrAAFVK2ALfIA774.jpg "title=" Awkworkflow.png "alt=" Wkiol1we-bwbf8vraafvk2alfia774.jpg "/>


All right, here's the little white practice. More source file Small white also share it, interested netizens can take a look.

This article is from the "Tiandaochouqin" blog, make sure to keep this source http://lavenliu.blog.51cto.com/5060944/1663810

Basic use of PIC for old drawing tools

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.