Expand description
What a drawing is made of, and how it reaches a host.
Above the coordinates a mark is placed at (blockworx_geom) sits
everything the render path and the tools need in order to draw: the colour
a mark is filled with, the font a glyph is selected from, the palette and
theme those resolve through, the Renderer every backend implements, and
the Canvas a live backend adds on top of it — pointer, cursor, keyed
easings, an in-place text editor, repaint requests.
Like blockworx_geom, this crate names no UI toolkit: not as a normal
dependency, not optionally behind a feature, not as a dev-dependency. The
conversions to a toolkit’s own types live at the backend boundary, so the
next backend is a set of trait impls rather than a rewrite.
Color is ecolor’s Color32 reimplemented: premultiplied sRGBA in eight
bits a channel, with the operations the palette and the SVG writer use
copied from ecolor (© Rerun / emilk, dual-licensed MIT OR Apache-2.0) so the
two agree byte for byte. Property tests beside the conversions hold them to
that.
Re-exports§
pub use canvas::AnimKey;pub use canvas::Animator;pub use canvas::Canvas;pub use canvas::Cursor;pub use canvas::EditColors;pub use canvas::EditId;pub use canvas::EditText;pub use canvas::PointerKind;pub use edit::EditField;pub use edit::TextEvent;pub use edit::TextOutcome;pub use extent::Extent;pub use ground::GridLine;pub use ground::Ground;pub use image::ImageImportError;pub use interaction::Button;pub use interaction::Camera;pub use interaction::Chord;pub use interaction::Event;pub use interaction::Input;pub use interaction::Interaction;pub use interaction::Key;pub use interaction::Keys;pub use interaction::Modifiers;pub use interaction::Press;pub use interaction::Raw;pub use palette::Base;pub use palette::Luminance;pub use palette::Palette;pub use palette::PaletteStroke;pub use palette::Saturation;pub use palette::Swatch;pub use record::DrawList;pub use record::DrawOp;pub use record::Recorded;pub use record::Recording;pub use text::TextLayout;
Modules§
- canvas
- What the core needs from a host that is live: a pointer, a cursor, a keyed easing, an in-place text editor, and a repaint request.
- color 🔒
- easing 🔒
- The keyed easings the render path polls, as a table the host ticks.
- edit
- The in-place editor as the kernel asks for it and the front end answers.
- extent
- How big the diagram is — measured from what a render actually painted.
- font 🔒
- ground
- What lies under the diagram: the canvas fill and the grid over it.
- image
- The intrinsic size a placement is fitted to, read off an image’s bytes without decoding them.
- interaction
- palette
- progress 🔒
- Unit-interval progress through an animation or gesture, clamped to
[0, 1]. The saturating arithmetic and total ordering come fromBounded; construction from a ratio of durations is the common case. - record
- The
Canvasthat keeps the diagram instead of showing it. - renderer 🔒
- scheme 🔒
- What the user picks about appearance: the colour scheme family, the light/dark mode, and the bundled typeface. Pure choices — how they are persisted, and how the typeface is installed with the host, belong to the shell.
- text
- Text layout: the one thing a drawing cannot do for itself.
- theme
- vantage 🔒
- Where the camera stands, and the transform it puts the world under.
- zoom 🔒
- The canvas world→screen scale, constrained to the range the view ever
legitimately reaches: framing clamps to
[0.1, 10]and wheel zoom to a narrower band inside it. The type guarantees the scale is positive, so screen↔world division is always sound.
Structs§
- Animated
- What one poll of an easing answered.
- Color
- An sRGBA color, 8 bits per channel, with premultiplied alpha — the
non-linear (“gamma”) values are the ones multiplied by the alpha, matching
ecolor’s
Color32byte for byte so the two convert without a color shift. - Easing
- Every keyed easing in the session.
- Factor
- What a zoom is multiplied by: a wheel notch, a pinch, a keyboard step. Above one magnifies.
- Font
- A sized font selection.
- Progress
- A newtype rather than a
Bounded<ProgressBounds>alias so the domain methods below can be inherent: the clamping and the total order areBounded’s, everything a progress means is here. - Scroll
Px - A wheel notch as a host reports it: the screen pixels the diagram was asked to scroll up by. Hosts disagree on the sign of a wheel, so each states its own in this type’s terms and none of them states the rate.
- Tick
- The frame clock an easing is read against: when this frame is, and how long the next one is expected to take.
- Vantage
- The whole of what a
view-kind undo entry restores. - Zoom
- A newtype rather than a
Bounded<ZoomBounds>alias soZoom::unitycan be inherent; the clamping and the total order areBounded’s.
Enums§
- Font
Choice - The four bundled UI fonts. Each maps to an embedded face (see
FontChoice::bytes) and a family name used both to install it with the host and to preview the menu entry in its own typeface. - Font
Family - Which typeface to select, independent of size.
- Mode
- Whether to use a scheme’s light or dark variant.
Systemfollows the OS light/dark preference. The glyphs are the ones a theme switcher conventionally shows (☀ / 🌙 / 💻). - Move
- A move of the camera a host read off its pointer, in screen space: a drag pan, a wheel notch, a pinch. Manual control, which is why the session abandons any framing still easing when one arrives.
- Scheme
- A color scheme family. Every scheme has both a dark and a light variant, so
the
Modechooses which one is shown. Values are the canonical tinted-theming base16 palettes. - Zoom
Step - One keyboard zoom step’s direction — the parameter form of “which way”,
so a call site reads
ZoomStep::Inrather than a bare sign or factor.
Constants§
- CANVAS_
FAMILY - The family a diagram glyph is drawn in. Repointed to the user’s selected font when the fonts are installed, so switching fonts restyles the drawing and leaves the UI chrome alone.