Search guides and the APICtrl K
  1. API reference
  2. Native GUI

gfx/geometry.h

Points, rectangles, lines and affine transforms.

#include <sonore/gfx/geometry.h>
On this page

Design notes

Why float and not int

A knob at 63.5 pixels is a real position, not a rounding error. Every coordinate here is float, and rounding happens ONCE, in the rasteriser, where the subpixel remainder becomes antialiasing coverage. Rounding earlier throws that coverage away and the result is the jagged look that tells a user a plugin was drawn by hand.

The one place integers appear is a pixel rectangle -- a clip region or a damaged area -- and that type is spelled differently so the two cannot be confused.

Types 4

A position: x right, y DOWN, as on the screen.

The reference's Point, but always float -- see the file comment for why. What the units are depends on where it is: a component's own coordinates (logical units) in the tree and in a MouseEvent, device pixels once a transform has been applied.

A rectangle as position and SIZE, not as two corners.

Deliberate: half the rectangle bugs anyone writes come from a right/bottom that is sometimes inclusive and sometimes not. With a width there is no such question -- an empty rectangle has width 0 and there is nothing to get off by one.

A rectangle in whole pixels: a clip region, a damaged area, a buffer.

A 2x3 affine transform, in the order [a c e; b d f].

Same layout as every other 2D graphics API, so a reader who knows one knows this. Composition is then: a.then(b) applies a FIRST -- which is the order people say it in, and the opposite of matrix multiplication written left to right. Getting that backwards is the classic transform bug, so it is named rather than left to an operator.

↑↓ to move↵ to openEvery public name in the headers, and every guide