From a7fa84cb35d176b92f0de731caa85585d9019e45 Mon Sep 17 00:00:00 2001 From: John Honniball Date: Sat, 22 Aug 2020 14:15:37 +0100 Subject: [PATCH] Update library tester. Add guidelines for arcs, add a rectangle and a rounded rectangle. --- TODO.md | 11 ++++++++++- libtest.c | 23 ++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index f304c69..64392f2 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,8 @@ # Things To Do ## HPGL library -* Add support for non-ISO paper sizes (i.e. U.S. paper sizes, origami square paper) +* Add support for non-ISO paper sizes (i.e. U.S. paper sizes, +origami square paper, postcard sizes, photographic sizes). * Add support for plot scaling. We should be able to plot directly in millimetres (and possibly in inches) as well as in device coordinates and maybe in other units. @@ -30,6 +31,11 @@ lines in reverse directions. * Remove 'openlinesequence()', 'linesegmentto()' and 'closelinesequence()' from the library. They were a bit of a kludge anyway, and inconvenient for the user. +* Optimise HPGL by not emitting 'PU;PA' in response to a 'moveto()' +if the pen is already at that location. Will probably reduce the number +of zero line segments that we get in 'hp2xx'. +* Change 'rectangle()' to call 'moveto()'/'lineto()'. Let those +functions handle optimisation. * Draw circles using Arc Absolute 'AA;' and choose arc starting-point that's closest to current pen position. * Add support for the front-panel LCD on the HP 7550A. Use the 'WD' @@ -45,6 +51,9 @@ arc tolerance of 72 chords. Make this a settable parameter somehow. comma-separated list of pens. Plot programs could then call for the next (or previous) pen and make simple multi-colour plots. Plots that might benefit from that: dala2, morphpoly, sutpent. +* Can we tell 'hp2xx' about pen width via the HPGL? If we can, we'd +be able to get previews with bold or fine pens. +* Should we set pen speeds separately for each pen? * Eliminate 'hpglout()' if at all possible. It breaks the abstraction that the library tries to maintain. * Support non-HPGL output. Maybe PostScript, BMC plotter commands, diff --git a/libtest.c b/libtest.c index 6b90e98..c5f8ca6 100644 --- a/libtest.c +++ b/libtest.c @@ -84,6 +84,8 @@ int main(int argc, char * const argv[]) void lineTest(const double xc, const double yc, const double wd, const double ht, const PlotInfo_t *const info) { const double len = wd / 16.0; + double hside = wd * 0.8; + double vside = ht * 0.8; moveto(xc - len, yc); lineto(xc + len, yc); @@ -91,6 +93,13 @@ void lineTest(const double xc, const double yc, const double wd, const double ht moveto(xc, yc - len); lineto(xc, yc + len); + rectangle(xc - hside, yc - vside, xc + hside, yc + vside); + + hside = wd * 0.7; + vside = ht * 0.7; + + roundrect(xc - hside, yc - vside, xc + hside, yc + vside, wd / 8); + hlabel(xc - (wd / 2.0), yc - (ht / 2.0), 5.0, info->plotterName); hlabel(xc + (wd / 2.0), yc - (ht / 2.0), 5.0, info->paperName); } @@ -116,10 +125,18 @@ void arcTest(const double xc, const double yc, const double wd, const double ht, double angle; int i; - moveto(xc - (wd / 2.0), yc); - lineto(xc, yc); - lineto(xc, yc + (wd / 2.0)); + moveto(xc - radius, yc); + lineto(xc + radius, yc); + + moveto(xc + radius, yc - radius); + lineto(xc - radius, yc + radius); + + moveto(xc, yc + radius); + lineto(xc, yc - radius); + moveto(xc - radius, yc - radius); + lineto(xc + radius, yc + radius); + for (i = 0; i < 7; i++) { radius = (wd / 16.0) * (i + 1); angle = 45.0 * (i + 1);