Add support for arbitrary polygons in pic

Last-Updated: 2024-12-19

Sources

Existing capabilites of pic

pic(1) is a powerful program but not many different types of shapes are implemented (as per groff version 1.22.4). The availables shapes are circles, ellipses and boxes and slanted rectangles. For any other shape, one would have to use a combination of lines or splines.

The issues with using lines to draw polygons is the resulting shape will not be recognised as closed and thus cannot be filled. You also cannot refer to the center of the shape with .c or to any of it's cardinal points.

Solution

Duncan Losin wrote a patch to pic which solves all these issues for any polygon. The patch and documentation have been shared on the mailing list (2024-09/msg00085). It should also be available with groff version 1.24.0 (2024-11/msg00163).

Common pitfalls

The documentation for this patch is excellent and reading it you will find this important sentence:

.v and .p locate the vertices and mid-points of the edges, respectively. They can be used in the forms .v expr , or .v `expr'. The latter is required when the vertex/point expression is followed by an additional expression, as pic will otherwise attempt to reduce them to a single expression.

The enclosing of expr in quotes is not something a pic user would be used to, so be aware.

← Go back