Skip to content

Commit

Permalink
Change use of HPGL-2 command 'EA' into 'PA' so that older plotters an…
Browse files Browse the repository at this point in the history
…d HPGL conversion programs will work properly. In particular, HPGL-to-PostScript was failing to recognise 'EA', which led to rectangles being omitted from the converted drawings.
  • Loading branch information
anachrocomputer committed Jul 3, 2018
1 parent 39ac98f commit ed9de12
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
38 changes: 20 additions & 18 deletions hpgllib.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,29 +409,31 @@ void closelinesequence (int closePoly)
}


void rectangle (double x1, double y1, double x2, double y2)
void rectangle (const double x1, const double y1, const double x2, const double y2)
{
int ix1, iy1, ix2, iy2;

ix1 = (int)(x1 + Minx);
iy1 = (int)(y1 + Miny);
ix2 = (int)(x2 + Minx);
iy2 = (int)(y2 + Miny);

fprintf (Plt, "PU%d,%d;EA%d,%d;\n", ix1, iy1, ix2, iy2);
/* Use 'PA' here instead of 'EA' (available in HPGL-2) because
some conversion programs (notably HPGL-to-PostScript) fail
to recognise 'EA'. */
const int ix1 = (int)(x1 + Minx);
const int iy1 = (int)(y1 + Miny);
const int ix2 = (int)(x2 + Minx);
const int iy2 = (int)(y2 + Miny);

fprintf (Plt, "PU%d,%d;PD;PA%d,%d,%d,%d,%d,%d,%d,%d;\n", ix1, iy1,
ix1, iy2, ix2, iy2, ix2, iy1, ix1, iy1);
}


void fillrectangle (double x1, double y1, double x2, double y2)
void fillrectangle (const double x1, const double y1, const double x2, const double y2)
{
int ix1, iy1, ix2, iy2;

ix1 = (int)(x1 + Minx);
iy1 = (int)(y1 + Miny);
ix2 = (int)(x2 + Minx);
iy2 = (int)(y2 + Miny);

fprintf (Plt, "PU%d,%d;RA%d,%d;\n", ix1, iy1, ix2, iy2);
/* Note that 'RA' is an HPGL-2 command and may not be recognised
by all plotters and all HPGL conversion programs */
const int ix1 = (int)(x1 + Minx);
const int iy1 = (int)(y1 + Miny);
const int ix2 = (int)(x2 + Minx);
const int iy2 = (int)(y2 + Miny);

fprintf (Plt, "PU%d,%d;RA%d,%d;\n", ix1, iy1, ix2, iy2);
}


Expand Down
4 changes: 2 additions & 2 deletions hpgllib.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ void lineto (double x, double y);
void openlinesequence (double x, double y);
void linesegmentto (double x, double y);
void closelinesequence (int closePoly);
void rectangle (double x1, double y1, double x2, double y2);
void fillrectangle (double x1, double y1, double x2, double y2);
void rectangle (const double x1, const double y1, const double x2, const double y2);
void fillrectangle (const double x1, const double y1, const double x2, const double y2);
void circle (double x, double y, double r);
void circle2 (double x, double y, double r, double tol);
void arc (double x, double y, double a);
Expand Down
2 changes: 2 additions & 0 deletions spiro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ void Spiro::setup()
// printf ("LBhttp://www.dorkbot.org/dorkbotbristol%c;\n", 3);
printf ("LBBristol Hackspace%c;\n", 3);
printf ("PU%d,%d;EA%d,%d\n", MINX, MINY, MAXX, MAXY);
printf ("PU%d,%d;PD;PA%d,%d,%d,%d,%d,%d,%d,%d\n", MINX, MINY,
MINX, MAXY, MAXX, MAXY, MAXX, MINY, MINX, MINY);
}

void Spiro::close()
Expand Down

0 comments on commit ed9de12

Please sign in to comment.