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:
- 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.
- 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.
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.
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.
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
andY
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
.
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?