{{Short description|Typesetting language and program for drawing}} {{Infobox software | name = Pic | screenshot = | logo = | screenshot size = | caption = | author = Brian Kernighan<br />(AT&T Bell Laboratories) | developer = Various | released = {{Start date and age|1988}} | latest release version = | latest release date = | programming language = C (programming language), Yacc<ref name=":0" /> | operating system = Unix, Unix-like, Plan 9 | platform = Cross-platform | genre = Command, Graphics | license = | website = }}

In computing, '''Pic''' is a domain-specific programming language by Brian Kernighan for specifying line diagrams. The language contains predefined basic linear objects: line, move, arrow, and spline, the planar objects box, circle, ellipse, arc, and definable composite elements. Objects are placed with respect to other objects or absolute coordinates. A liberal interpretation of the input invokes default parameters when objects are incompletely specified. An interpreter translates this description into concrete drawing commands in a variety of possible output formats. Pic is a procedural programming language, with variable assignment, macros, conditionals, and looping. The language is an example of a ''little language'' originally intended for the comfort of non-programmers in the Unix environment (Bentley 1988).

== History == Pic was implemented using Yacc compiler-compiler.<ref name=":0">{{cite web |date=September 30, 2015 |title=UNIX Special: Profs Kernighan & Brailsford |url=https://www.youtube.com/watch?v=vT_J6xc-Az0 |url-status=live |archive-url=https://ghostarchive.org/varchive/youtube/20211213/vT_J6xc-Az0 |archive-date=2021-12-13 |work=Computerphile}}{{cbignore}}</ref>

== Implementations == Pic was first implemented as a preprocessor in the troff document processing system but is now often used with LaTeX. The pic preprocessor filters a source document, replacing diagram descriptions by drawing commands in a specified format, and passing the rest of the document through without change. Alternatively, diagram source is passed through the preprocessor to produce a file for insertion into the document source.

A version of pic is included in groff, the GNU version of troff. GNU pic can also act as a preprocessor for TeX documents, emitting its own '''tpic''' DVI specials, which aren't as widely supported as those of other TeX graphic facilities.<ref name="gc2">{{cite book|title=The LaTeX Graphics Companion|year=2008|publisher=Addison-Wesley|isbn=978-0-321-50892-8|author=Michel Goossens, Frank Mittelbach, Sebastian Rahtz, Denis Roegel, Herbert Voß|edition=2nd|pages=17–20}}</ref> Arbitrary diagram text can be included for formatting by the word processor to which the pic output is directed, and arbitrary graphic processor commands can also be included.

=== DPIC === Dwight Aplevich's implementation, [http://www.ece.uwaterloo.ca/~aplevich/dpic/ DPIC], can also generate pdf, postscript, svg, and other images by itself, as well as act as a preprocessor producing several LaTeX-compatible output formats. The three principal sources of pic processors are GNU pic, found on many Linux systems, and dpic, both of which are free, and the original AT&T pic.

=== Pikchr === '''[https://pikchr.org/home/doc/trunk/homepage.md Pikchr]''' (pronounced "picture") is a modern replacement for Pic in some contexts, designed to be embedded in Markdown, instead of troff or LaTeX. It should run most of the example scripts contained in the original technical report on Pic with little to no change.<ref>{{cite web |last1=Hipp |first1=Richard |title=Differences Between Pikchr And Legacy-PIC |url=https://pikchr.org/home/doc/trunk/doc/differences.md |website=Pikchr |accessdate=16 August 2021}}</ref> Created by D. Richard Hipp, in August 2020,<ref>{{cite web |last1=Hipp |first1=Richard |title=Check-in [d06dd0ebe7] |url=https://pikchr.org/home/info/d06dd0ebe7dae623 |website=Pikchr |accessdate=13 September 2020}}</ref> it is used in Fossil, SQLite, and [https://subplot.liw.fi/ Subplot].

== Alternatives == Pic has some similarity with MetaPost and the DOT language.

== See also ==

* Eqn language

==References== {{reflist}} ;Notes *{{cite journal|last=Kernighan|first=Brian W.|year=1982|title=PIC - A Language for Typesetting Graphics|journal=Software: Practice and Experience|volume=12|issue=12|pages=1–20|doi=10.1002/spe.4380120102|s2cid=59543886}} *J. Bentley. ''More Programming Pearls'', Addison-Wesley (1988).

==External links== {{Wikibooks |Guide to UNIX | Commands | roff}} * [https://www.chiark.greenend.org.uk/doc/groff-base/html/pic.html Making Pictures With GNU PIC] * [http://www.kohala.com/start/troff/troff.html Troff resources (see the "pic" section)] * [https://gitlab.com/aplevich/dpic/ DPIC], an implementation of the PIC language by Dwight Aplevich. This implementation has a few nice extensions and outputs many different image formats. *[https://web.archive.org/web/20110929131155/http://figr.bzero.se/ figr], web based pic renderer. *{{cite tech report|author=Brian W. Kernighan|author-link=Brian Kernighan|title=PIC — A Graphics Language for Typesetting. User Manual|institution=Bell Laboratories|work=CSTR #116|edition=Revised|year=1991|url=https://archive.org/details/pic-graphics-language}} * [https://www.gnu.org/software/plotutils/manual/en/html_node/pic2plot-Introduction.html GNU pic2plot] "''takes one or more files in the pic language, and either displays the figures that they contain on an X Window System display, or produces an output file containing the figures. Many graphics file formats are supported.''" * The [https://gitlab.com/aplevich/Circuit_macros/ Circuit_macros] distribution includes numerous examples of electric circuits and other objects of a sophistication well beyond the basic box-and-arrow diagrams in the original pic manuals. The examples employ dpic principally together with macros written in the pic and m4 macro languages. * [https://pikchr.org/ Pikchr]

{{Programming languages}}

Category:Programming languages Category:Markup languages Category:Troff Category:Programming languages created in 1980 Category:1980 software Category:Graph description languages