16.3 Pic
Pic 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
Pic has the following command-line syntax:
Full descriptions of primitive objects in pic can be ended by starting another line, or by the semicolon character (;). A single primitive description can be continued on the next line, however, by ending the first with a backslash character (\). Comments may be placed on lines beginning with the pound sign (#). 16.3.1 Pic Macros
16.3.2 Declarations
At 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, say 1 = one-
scale = Pic takes variable substitutions for numbers used in the description. Instead of:
line right
you may use a lowercase character as a
variable, for example
a = You may then write:
line right a 16.3.3 PrimitivesPic recognizes several basic graphical objects, or primitives. These primitives are specified by the following keywords:
arc circle move arrow ellipse spline box line " 16.3.3.1 SyntaxPrimitives may be followed by relevant options. Options are discussed later in this section.
16.3.4 Options
The options below are grouped by function.
Note that
16.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:
16.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: [ Brackets are used as delimiters. Note that the object is declared as a proper noun, hence should begin with a capital letter. 16.3.7 MacrosThe same sequence of commands can be repeated by using macros. The syntax is:
define Here we used the percent sign (%) as the delimiter, but you can use any character that isn't in the description. Macros can take variables, expressed in the definition as $1 through $9 . Invoke the macro with the syntax:
16.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 - (3,1)
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 ({ }), pic then returns to the position before the first brace. 16.3.8.1 Positioning Between ObjectsTo refer to a previous object, use proper names. This can be done two ways:
To refer to a point between two objects, or between two points on the same object, you may write:
or (abbreviated):
16.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:
For example:
Valid corners can be specified as any of the following:
You may also refer to the following parts of an object:
upper right lower right upper left lower left 16.3.9 Arithmetic OperatorsPic recognizes the operators below:
16.3.10 Default ValuesThe default dimensions of objects are controlled by various system variables. You can change these defaults by typing a description line of the form:
16.3.11 A Pic ExampleInput:
.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: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|