Skip to content

Instantly share code, notes, and snippets.

@abey79
Last active April 16, 2020 12:09
Show Gist options
  • Save abey79/45e105c12c1df5a3be49343ee4f1dc97 to your computer and use it in GitHub Desktop.
Save abey79/45e105c12c1df5a3be49343ee4f1dc97 to your computer and use it in GitHub Desktop.

vpype HPGL support

This is a design note related to the implementation of HPGL output support for vpype's write command. This WIP is tracked in this pull request.

The write command implements two related but distinct tasks:

  1. Page layout: includes the required scaling, translating and rotating to layout the geometries on a page of specified size and orientation in a predictable way.
  2. Output: generate actual SVG/HPGL output from the resulting geometries

The rest of this document describes the intended UI and behaviour once HPGL integration is completed.

Page layout

The page layout process and UI should be independent of, and consistent across, output formats. The following options currently control how its done:

  • --page-format a4|a3|...: size of the page
  • --landscape: page orientation should be landscape instead of portrait (default)
  • --center: center the geometries on the page (by default, geometries are not translated)
  • --rotate-paper (NEW): Rotate the page by 90 degrees. See below.

Plotter may have various ways to 'load' paper, and various degrees of flexibility with this depending on paper size. For example, the Axidraw V3/A3 may plot on A4 paper in either orientation but A3 paper must be 'loaded' in landscape orientation. Some tools, such as the official Axidraw Inkscape plugin, have smart auto-rotate features for situations that require it (e.g. A3 in portrait mode), while some other, such as saxi, don't. The situation may be similar with vintage plotter depending on the model and software.

To address the situation while preserving a predictable behaviour in common cases, we introduce the --rotate-paper option. When used, the page aspect ratio determined by the --paper-format/--landscape combination is swapped and the geometries are rotated by 90 degrees. The rational is that, by default, the --landscape option must be respected by the output as the user would expect (e.g. the SVG output has a landscape aspect ratio and the geometries are upright). In specific situations where hardware constraints are not appropriately dealt with by the plotter and/or its driver (eg. portrait A3 with saxi), the user can address the situation by adding the --rotate-paper option.

For the sake of clarity, here is an illustrations of the various possibilities:

In addition, there are several other avenues for improving write's page layout capabilities (see e.g. this issue), but since these changes should be independant of the actual type of output, they are beyond the scope of HPGL output implementation.

HPGL output

When the --format hpgl option is provided, or the output file has a .hpgl extension, a HPGL file should be generated. Unfortunately, in order for the final plotted output to be faithful to the page layout intent, the generated HPGL must take into account the actual model of plotter and how it will be used. For this to happen, the user must provide additional information to the write command. The following paragraphs describe the proposed UI for doing so.

Iteration 1: low-level UI

As first iteration, we implement a simple low-level interface as follows:

  • Output assumes a 0.025mm per plotter unit.
  • --offset X Y: specify the page offset. For consistency with the rest of vpype, X and Y support usual units and default to pixels. Defaulting to pixel instead of plotter unit may (or may not) be confusing for the user, but this is acceptable for the sake of consistency, easy of implementation, and this being a first iteration.

The intent is to let the user figure out the offset needed and whether or not to use --rotate-page.

Iteration 2: high-level UI

To be completed

  • --printer 7440a|...: automatically setup offsets, etc. based on model
  • Based on --page-format and --printer, automatically discover if --rotate-page is needed
  • other?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment