Expand description
Overlays in image coordinates, edited through one handle kit.
The application owns its overlays (shapes, guides, a crop box) and
gives them to the viewport each frame; the viewport draws them and
turns drags on their handles into Signal::Handles
(begin, update, end, or cancel on Escape), which the application
applies to its own data (Overlay::apply does it for the standard
shapes). A before_handle hook may veto a move or snap it.
The same handle kinds look and behave the same everywhere: a body
(move), points and corners, edges, a size, a rotation, a feather, a
Bézier control. Their hit target is HIT_RADIUS points whatever
their drawn size. A click on a handle, or on an overlay’s outline away
from its handles (to add a point there), is a signal too.
Each overlay has a Style: an emphasis (normal, selected, faint)
and a dashed line; shapes are points, lines, boxes, circles, ellipses
and paths.
Structs§
- Handle
- A handle: an index within its overlay, a kind, a place (image pixels).
- Overlay
- An overlay: a shape with an id, its handles, and whether it is a guide (drawn, never edited).
- Style
- How an overlay is drawn.
Enums§
- Emphasis
- How an overlay stands out.
- Handle
Kind - What a handle adjusts.
- Handle
State - How a handle is drawn.
- Shape
- A shape in image pixels.
Constants§
- DRAWN_
RADIUS - The radius a handle is drawn with, in points.
- EDGE_
RADIUS - How close to an outline a click lands on it, in points.
- HIT_
RADIUS - The radius of a handle’s hit target, in points (24-point targets).
- LINE_
WIDTH - A shape’s line, its dark outline under it, a handle’s outline, in
points before snapping: each is drawn as whole physical pixels at the
window’s scale (
scale::stroke), so it never blurs at 125 % or 150 %. - OUTLINE_
WIDTH - UNDER_
WIDTH
Functions§
- hit
- The handle under
pos(points), topmost overlay first. - hit_
edge - The outline under
pos(points), topmost overlay first, guides left out: the overlay’s index, the segment (between pointsiandi + 1of a path or a line, the box’s top, right, bottom and left edges0to3,0for a circle or an ellipse) and the nearest point of it in image pixels. - paint_
handle - Draws one handle of the kit at
pos(points). - paint_
handle_ styled - Draws one handle of the kit at
pos(points), faint when its overlay is. - paint_
label - Draws
textas a label over an image, through the kit’sviewport-labelcomponent: a translucent pill (itsfill,radius,padding-xandpadding-y) holding the text in itstextcolour, at itsfont-size(theSmalltext style’s when the kit gives none).anchorsays which point of the label sits atat(points):LEFT_BOTTOMputs it above and right ofat. An overlay’s label (Overlay::label) is drawn this way; so is a HUD’s readout over an image. Returns the rectangle the label covers. - paint_
shape - Draws an overlay’s shape (and its label) through a mapping, in its style.