Skip to main content

Module draw

Module draw 

Source
Expand description

draw:enhanced-geometry: the outline of a custom shape, worked out.

A custom shape does not state its outline as points. It states a path in a compact command language, in a coordinate space of its own, whose numbers may be references to named formulas that are themselves arithmetic over the space’s edges and over adjustment values a person dragged. A rounded rectangle is M ?f7 0 X 0 ?f8 L 0 ?f9 Y ?f7 21600 …, and none of that means anything until the formulas are evaluated.

What comes out of here is Geometry: the same outline as flat polylines in the shape’s own space, ready for a renderer to map onto a rectangle. Curves and arcs are flattened here rather than passed on, because the number of segments a curve needs depends on the size of the coordinate space and not on the size of the window, and this is where the space is known.

A draw:path states its outline the other way, in SVG’s path notation in svg:d, and comes out of here as the same Geometry. The two languages have the same shape — move, line, curve, close — and share the pen below.

§What is implemented

The whole command language except Q’s smooth variants, and the formula grammar in full. What is measured is narrower: across the twenty-three presentation templates LibreOffice ships, the commands that occur are M, L, C, Z, N, U, X, Y and V, and the formulas use the four edge constants, pi, and if, sin, cos and abs. The arc commands A, B and W occur nowhere in that set and their sweep direction is taken from the specification rather than from a document.

Structs§

Geometry
A custom shape’s outline.
SubPath
One stroke of the pen: a run of points, and what is done with them.
ViewBox
The coordinate space a shape states its outline in.