gfx/path.h
Path: the shape everything is drawn from.
#include <sonore/gfx/path.h>- 2types
- 1other declaration
- Guides: The native editor
On this page
Design notes
One primitive, not many
A rounded rectangle, a knob's pointer, a meter's cap and a piece of text are all the same thing to the rasteriser: a set of closed contours to be filled. Having one primitive means one rasteriser, one clipping rule, one antialiasing quality, and one place where a bug can be.
Flattening, and the tolerance that decides quality
Curves are subdivided into line segments before rasterising. How finely is the only quality knob that matters: too coarse and a knob's arc becomes a visible polygon, too fine and a UI redraw costs more than the audio.
The tolerance is in DEVICE pixels, not path units, so it has to be applied after the transform. A path scaled up four times needs four times the segments to look the same -- which is why flattening takes the transform rather than being done once when the path is built.
Types 2
A flattened contour, and whether the author closed it.
The FILL path does not care -- an open contour has an inside and gets one. The STROKE path cares completely: an open contour gets end caps and a closed one gets a join where it meets itself. Losing that distinction during flattening is why this carries a flag rather than a bare point list.
A shape as contours of lines and curves: what Graphics fills, strokes and clips to, and what glyphs and SVG shapes become. The reference's Path, in this SDK's terms; the file comment explains why it is the one primitive and why flattening waits for the transform.
Built with moveTo / lineTo / quadTo / cubicTo / close, or the add* shapes. Angles are in radians from twelve o'clock, clockwise (see addArc). Drawing with no moveTo first starts a contour where asked rather than joining the previous one. A plain value: copy it, keep it across paints, build it on any thread -- it holds no reference to a Graphics or a Bitmap.
Enums 1
- enum
enum class FillRuleWhich parts of a self-overlapping path are inside.gfx::FillRule · path.h:47