17.3 picpic is a graphics language program that facilitates the drawing of simple flowcharts and diagrams. pic offers dozens of ways to draw a picture, not only because of the many abbreviations it allows, but because pic tries to combine the language of geometry with English. For example, you can specify a line by its direction, magnitude, and starting point, yet you can often achieve the same effect by simply stating, "from there to there ." pic has the following command-line syntax: pic [files ] Full descriptions of primitive objects in pic
can be ended by starting another line, or with the semicolon character (;). A single primitive description can be continued on the next line, however, by ending the first with a backslash character ( Solaris does not have pic . The canonical reference for pic is Bell Labs Computing Science Technical Report #116 , by B.W. Kernighan. This paper may be downloaded from http://cm.bell-labs.com/cm/cs/cstr/116.ps.gz . That document describes a newer version of pic with more features than what is described here, but such features may not be universally available. You should read it if you plan to do any serious work in pic . 17.3.1 pic Macros
troff requests or macros embedded in the body of a picture description are passed through unchanged. They are assumed to make sense at that point. Be careful not to use requests or macros that generate any horizontal or vertical motion. 17.3.2 DeclarationsAt the beginning of a pic description, you may declare a new scale, and declare any number of variables. pic assumes you want a 1-to-1 scale, where units are inches by default. You can declare a different scale, i.e., centimeters, by declaring: scale = 2.54 You may use variables instead of numbers in a description; pic substitutes the variable's value. Instead of: line right n you may use a variable, for example, a = n You may then write: line right a Variable names must begin with a lowercase letter. The rest of the name may consist of uppercase or lowercase letters, digits, and underscores. Variables retain their values from picture to picture. 17.3.3 Primitivespic recognizes several basic graphical objects, or primitives. These primitives are specified by the following keywords:
17.3.3.1 SyntaxPrimitives may be followed by relevant options. Options are discussed later in this section.
17.3.4 OptionsThe options below are grouped by function. Note that
17.3.5 TextText must be placed within quotes. To break the line, break into two (or more) sets of quotes. Text always appears centered within the object, unless given one of the following arguments:
17.3.6 Object BlocksSeveral primitives can be combined to make a complex object (for example, an octagon). This complex object can be treated as a single object by declaring it as a block: Object: [ description . . . ] Brackets are used as delimiters. Note that the object is declared as the name of a place, and hence it must begin with a capital letter. 17.3.7 MacrosThe same sequence of commands can be repeated by using macros. The syntax is: define sequence % description . . . % Here the percent sign ( Macros can take parameters, expressed in the definition as sequence (value1 ,value2 ,... ) 17.3.8 PositioningIn a pic description, the first action begins at (0,0) unless otherwise specified with coordinates. Thus, as objects are placed above and left of the first object, the point (0,0) moves down and right on the drawing. All points are ultimately translated by the formatter into x- and y-coordinates. You may therefore refer to a specific point in the picture by incrementing or decrementing the coordinates. For example: 2nd ellipse + (.5,0) This refers to the position 1/2 inch to the right of the center of the second ellipse. The x- and y-coordinates of an object are the point where the center of the object is placed. You may refer to the x- and y-coordinates of an object by placing last box.x refers to the x-coordinate of the most recent box drawn. You can refer to some of the object's physical attributes in a similar way:
Unless otherwise positioned, each object begins at the point where the last object left off. However, if a command (or sequence of commands) is set off by curly braces ( 17.3.8.1 Positioning between objectsThere are two ways to refer to a previous object.
To refer to a point between two objects, or between two points on the same object, you may write: fraction of the way between first.position and second.position or (abbreviated): fraction <first.position, second.position> 17.3.8.2 CornersWhen you refer to a previous object, pic assumes you mean the object's center unless you specify a corner. To specify a corner, use either of these forms: .corner For example:
Valid corners can be specified as any of the following:
You may also refer to the following parts of an object:
17.3.9 ExpressionsExpressions may be used anywhere pic needs a numeric value (such as when specifying coordinates or amounts of motion). Expressions consist of numeric constants, variables, and operators. pic recognizes the following operators.
17.3.10 Default ValuesVarious system variables control the default dimensions of objects. You can change these defaults by typing a description line of the form: variable = value
17.3.11 pic ExamplesInput: .PS define smile % a = $1 circle radius a at 0,0 arc cw radius a*.75 from a*.5,-a*.25 to -a*.5,-a*.25 "\(bu" at a*.33,a*.25 "\(bu" at a*-.33,a*.25 % smile(.5) .PE Result: Input (from CSTR #116): .PS ellipse "document" arrow box "PIC" arrow box "TBL/EQN" "(optional)" dashed arrow box "TROFF" arrow ellipse "typesetter" .PE Result: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|