Jump to content

HP-GL

From Alfawiki
Hewlett-Packard Graphics Language (HP-GL)
Company typePrinter control language
IndustryPrinting technology, Vector graphics
Founded1977
FounderHewlett-Packard
ProductsHP-GL, HP-GL/2

HP-GL, an abbreviation for Hewlett-Packard Graphics Language (commonly abbreviated as HPGL), is a printer control language created by Hewlett-Packard (HP). Launched alongside the HP-9872 plotter in 1977, HP-GL quickly became the predominant control language for a wide range of plotters. Most HP printers offer support for HP-GL/2 in addition to PCL.

Design

HP-GL utilizes two-letter mnemonic commands, which may be followed by parameters. For instance, the command:

AA100,100,50;

instructs the device to draw an arc centered at the absolute coordinates 100,100 starting at an angle of 50 degrees measured counter-clockwise. An optional fourth parameter can specify the arc length, which defaults to 5 degrees if omitted.

The original set of HP-GL commands included:

Command Description
Vector Commands
PA x,y{,x,y{...}} Plot points using absolute coordinates
PR x,y{,x,y{...}} Plot points using relative coordinates
PD Lower pen to start drawing
PU Raise pen to stop drawing
Character Commands
CA n Choose alternate character set n
CP spaces, lines Plot characters
CS m Select standard character set m
DI run, rise Define absolute direction vector
DR run, rise Define relative direction vector
LB c,...,c Output ASCII string as label
SA Activate alternate character set
SI wide, high Specify absolute character dimensions
SL tan θ Set character slant angle relative to vertical
SR wide, high Adjust character size relatively
SS Activate standard character set
UC x,y,pen{,...} Define user-created character
Line Type Commands
LT t{,l} Set line type and segment length
SM c Enable symbol mode
SP n Select pen number n
VA Enable adaptive velocity mode
VN Use normal velocity mode
VS v{,n} Assign velocity v for pen n
Digitizer Commands
DC Clear digitizer buffer
DP Capture digitizer point
OC Output current location and pen status
OD Output digitized point with pen status
Axis Commands
TL tp{,tn} Set tick mark length
XT Generate tick on X axis
YT Generate tick on Y axis
Setup Commands
IP p1x,p1y,p2x,p2y Define input points p1 and p2
IW xlo,ylo,xhi,yhi Specify input window boundaries
OP Output points p1 and p2
Configuration and Status Commands
AP Enable automatic pen pickup
DF Restore default settings
IM e{,s{,p}} Configure input masks e, s, and p
IN Initialize the device
OE Output error information
OS Output device status information
SI w,h: Define character width and height explicitly
Additional Commands Introduced Later

Parameter formats include:

  • [i]: integer values ranging from -32767 to 32768 (no decimal points)
  • [d]: decimal values within ±127.9999 (decimals optional)
  • [c]: ASCII characters

Examples

Standard HP-GL files typically start with initialization commands, followed by a series of graphical instructions. These files are stored as ASCII text. An example of an HP-GL file might look like this:

Sample HP-GL file
Command Description
IN; initialize the device and begin the plotting task
IP; reset scaling points (P1 and P2) to their default locations
SP1; choose pen number 1
PU0,0; raise the pen and move to the origin point
PD100,0,100,100,0,100,0,0; lower the pen and draw a rectangular shape
PU50,50; lift pen and navigate to position 50,50
CI25; create a circle with a radius of 25 units
SS; select the standard font set
DT*,1; define an asterisk as text delimiter without printing it
PU20,80; raise pen and move to coordinates 20,80
LBHello World*; render a text label

Coordinates are expressed in the finest units supported by HP plotters: 25 μm (equivalent to 40 units per millimeter or 1016 units per inch), with coordinate values spanning ±230.

HP-GL/2

The initial HP-GL specification did not include commands for line thickness; this aspect was dependent on the physical pens installed in the plotter. For inkjet devices, setting line width required manual adjustment per pen at the printer itself—a process that was inefficient. Hewlett-Packard Graphics Language/2 (HP-GL/2) introduced in-language line width control, simplifying printer configuration. Additionally, it incorporated a binary file format that reduced file size and expedited data transfer while enhancing resolution.

Sample HP-GL/2 commands
Command Description
NPx sets the number of pens available (x ranges from 1 to 256)
PCx,r,g,b assigns pen color where x is the pen number and r/g/b represent color intensities from 0 to 255
PWw,x specifies pen width in millimeters including decimal values; x indicates the pen number

AGL

AGL (A Graphics Language) is an extension of BASIC connected to HP-GL. Developed for Hewlett-Packard minicomputer systems, AGL facilitated plotter management by converting high-level graphic commands into multiple HP-GL instructions.

See also

  • DMPL, Houston Instruments' proprietary plotter language
  • Gerber format, another format for describing graphical layouts
  • Logo, a programming language focused on drawing

Further reading

  • The HP-GL/2 and HP RTL Reference Guide – A handbook for Program Developers, Hewlett-Packard Company, Barcelona Division, draft 2, second edition, September 1996. Published by Addison-Wesley Publishing Company.

External links