{{Short description|Page description language created by Hewlett-Packard (HP)}} {{more citations needed|date=September 2016}} {{Infobox file format |name = Hewlett-Packard Graphics Language |mime = application/vnd.hp-HPGL }} '''HP-GL''', short for '''Hewlett-Packard Graphics Language''' and often written as '''HPGL''', is a [[page description language]] created by [[Hewlett-Packard]] (HP). HP-GL was the primary page description language used by HP [[plotter]]s.<ref name="Hennessee_1977"/> It was introduced with the plotter [http://www.hpmuseum.net/display_item.php?hw=79 HP-9872] in 1977 and became a standard for almost all plotters. Hewlett-Packard's [[computer printer|printers]] also usually support HP-GL/2 in addition to [[Printer Command Language|PCL]].<ref name="HP_1990_HP-GL/2"/>

== Design == The language is formed from a series of two letter codes ([[mnemonic]]s), followed by optional parameters. For instance an [[Arc (geometry)|arc]] can be drawn on a page by sending the string:

<code>AA100,100,50;</code>

This means ''Arc Absolute'', and the parameters place the center of the arc at absolute [[Cartesian coordinate system|coordinates]] 100,100 on the page, with a starting angle of 50 [[Degree (angle)|degrees]] measured counter-clockwise. A fourth optional parameter (not used here) specifies how far the arc continues, and defaults to 5 degrees.

When first introduced, HP-GL contained the following commands:

{| class="wikitable" ! Command ! Meaning |----- ! colspan=2 | Vector Group |----- | <code>PA</code> x,y{,x,y{...}<nowiki/>} || Plot absolute [i] |----- | <code>PR</code> x,y{,x,y{....}<nowiki/>} || Plot relative [i] |----- | <code>PD</code> || Pen down |----- | <code>PU</code> || Pen up |----- ! colspan=2 | Character Group |----- | <code>CA</code> n || Designate alternate character set n [i] |----- | <code>CP</code> spaces, lines || Character plot [d] |----- | <code>CS</code> m || Designate standard set m [i] |----- | <code>DI</code> run, rise || Absolute direction [d] |----- | <code>DR</code> run, rise || Relative direction [d] |----- | <code>LB</code> c, ..., c || Label [[ASCII]] string [c] |----- | <code>SA</code> || Select alternate character set |----- | <code>SI</code> wide, high || Absolute character size [d] |----- | <code>SL</code> tan θ || Absolute character slant (from vertical) [d] |----- | <code>SR</code> wide, high || Relative character size [d] |----- | <code>SS</code> || Select standard character set |----- | <code>UC</code> x, y, pen{, ...} || User defined character [i] |----- ! colspan=2 | Line Type Group |----- | <code>LT</code> t{,l} || Designate line type t and length l [d] |----- | <code>SM</code> c || Symbol mode [c] |----- | <code>SP</code> n || Select pen [i] |----- | <code>VA</code> || Adaptive velocity |----- | <code>VN</code> || Normal velocity |----- | <code>VS</code> v{,n} || Select velocity v for pen n [i] |----- ! colspan=2 | Digitize Group |----- | <code>DC</code> || Digitize clear |----- | <code>DP</code> || Digitize point |----- | <code>OC</code> || Output current position and pen status |----- | <code>OD</code> || Output digitized point and pen status |----- ! colspan=2 | Axes |----- | <code>TL</code> tp{,tn} || Tick length [d] |----- | <code>XT</code> || X axis tick |----- | <code>YT</code> || Y axis tick |----- ! colspan=2 | Set-Up Group |----- | <code>IP</code> p1x,p1y,p2x,p2y || Input p1 and p2 [i] |----- | <code>IW</code> xlo,ylo,xhi,yhi || Input window [i] |----- | <code>OP</code> || Output p1 and p2 [i] |----- ! colspan=2 | Configuration Status |----- | <code>AP</code> || Automatic pen pickup [i] |----- | <code>DF</code> || Set default values |----- | <code>IM</code> e{,s{,p}<nowiki/>} || Input e, s and p masks [i] |----- | <code>IN</code> || Initialize |----- | <code>OE</code> || Output error [i] |----- | <code>OS</code> || Output status [i] |}

{|class = wikitable |+ Commands added (when?) | {{code|SI}} w,h || set character width and height |}

Formats: * [i]: integer formats between -32767 and 32768. No decimal point. * [d]: decimal format between +/- 127.9999. Optional decimal point. * [c]: ASCII character

== Examples == Typical HP-GL files start with a few setup commands, followed by a long string of graphics commands. The file was in [[ASCII]] ([[text file]]) [[File format|format]], for instance:

{| class="wikitable" |+ An example HP-GL file |----- ! Command ! Meaning |----- | {{mono|IN;}} || initialize, start a plotting job |----- | {{mono|IP;}} | set the scaling points (P1 and P2) to their default positions |----- | {{mono|SP1;}} || select pen 1 |----- | {{mono|PU0,0;}} | lift Pen Up and move to starting point for next action |----- | {{mono|PD100,0,100,100,0,100,0,0;}} | put Pen Down and move to the following locations (draw a box around the page) |----- | {{mono|PU50,50;}} || Pen Up and move to X,Y coordinates 50,50 |----- | {{mono|CI25;}} || draw a circle with radius 25 |----- | {{mono|SS;}} || select the standard character set |----- | {{mono|DT*,1;}} | set the text delimiter to the asterisk, and do not print them (the 1, meaning "true") |----- | {{mono|PU20,80;}} || lift the pen and move to 20,80 |----- | {{mono|LBHello World*;}} || draw a label |}

The coordinate system was based on the smallest units one of the HP plotters could support, and was set to 25&nbsp;μm (i.e. 40 units per millimeter, 1016 per inch). The coordinate space was positive or negative [[floating point]] numbers, specifically ±2<sup>30</sup>.

== {{anchor|HPGL2}}HP-GL/2 == The original HP-GL language did not support definition of line width, as this parameter was determined by the pens loaded into the plotter. With the advent of the first [[inkjet]] plotters, line width for the "pens" specified within the HP-GL files had to be set at the printer so it would know what line width to print for each pen, a cumbersome and error-prone process. With '''Hewlett-Packard Graphics Language/2''' aka '''HP-GL/2''', definition of line width was introduced into the language and allowed for elimination of this step. Also, among other improvements a [[binary file]] format was defined that allowed for smaller files and shorter file transfer times, and the minimal resolution was reduced.

{| class="wikitable" |+ Examples of HP-GL/2 commands |- ! Command ! Meaning |- | NPx || number of pens; x=1..256 |- | PCx,r,g,b || pen color; x=pen, r=red, g=green, b=blue, 0..255 |- | PWw,x || pen width; w=pen width in mm with decimal point, x=pen |}

== AGL == HP-GL is related to '''AGL''' (A Graphics Language), an extension of the [[BASIC]] programming language. AGL was implemented on Hewlett-Packard [[minicomputer]]s to simplify controlling a plotter. AGL commands describe the desired graphics plotting function, which the computer relays as several HP-GL instructions to the plotter.

== See also == * [[DMPL]], another plotter language by Houston Instruments * [[Gerber format]] is another plot-description format * [[Logo (programming language)|Logo]], a computer language with drawing commands similar to HP-GL

== References == {{Reflist|refs= <ref name="Hennessee_1977">{{cite journal |author-last1=Daniels |author-first1=Thomas H. |author-last2=Hennessee |author-first2=Larry W. |title=Easy-to-Use Interface Language Controls HP-IB Plotter |journal=[[Hewlett-Packard Journal]] |date=September 1977 |volume=29 |issue=1 |page=5 |url=http://www.hpl.hp.com/hpjournal/pdfs/IssuePDFs/1977-09.pdf |access-date=2016-09-12 |url-status=live |archive-url=https://web.archive.org/web/20170227192359/http://www.hpl.hp.com/hpjournal/pdfs/IssuePDFs/1977-09.pdf |archive-date=2017-02-27}}</ref> <ref name="HP_1990_HP-GL/2">{{cite book |title=PCL 5 Printer Language Technical Reference Manual |publisher=[[Hewlett-Packard Company]] |date=September 1990 |edition=1st |id=HP Part No. 33459-90903}} (NB. Chapter 15-21 also contain a description of HP-GL/2.)</ref> }}

== Further reading == * {{cite book |title=The HP-GL/2 and HP RTL Reference Guide - A handbook for Program Developers - Hewlett-Packard Graphics Language/2 - Hewlett-Packard Raster Transfer Language |author=Hewlett-Packard Company, Barcelona Division |author-link=Hewlett-Packard Company |location=Barcelona, Spain |edition=draft 2, second |date=September 1996 |orig-year=1990 |isbn=0-201-63325-6 |publisher=[[Addison-Wesley Publishing Company]] |id=HP Part No. 5961-3526, 5959-9733 |url=http://www.hpmuseum.net/document.php?catfile=213 |access-date=2017-02-28 |url-status=live |archive-url=https://web.archive.org/web/20170227193043/http://www.hpmuseum.net/document.php?catfile=213 |archive-date=2017-02-27}}

== External links == * {{cite web |url=http://www.sxlist.com/techref/language/hpgl/commands.htm |title=Hewlett-Packard Graphics Language Commands |archive-url=https://web.archive.org/web/20170227192501/http://www.sxlist.com/techref/language/hpgl/commands.htm |archive-date=2017-02-27}} * {{cite web |url=http://cstep.luberth.com/HPGL.pdf |title=HP-GL Overview |archive-url=https://web.archive.org/web/20180613112357/http://cstep.luberth.com/HPGL.pdf |format=PDF |archive-date=2018-06-13}} * {{cite web |url=http://sites.music.columbia.edu/cmc/chiplotle/ |title=Chiplotle |access-date=2023-02-15}} (NB. A Python-based HP-GL plotter control library for using vintage pen plotters with contemporary operating systems.)

{{Hewlett-Packard software}} {{Authority control}}

[[Category:HP software]] [[Category:Printing technology]] [[Category:Vector graphics]] [[Category:Page description languages]]