pub struct Recording<L: TextLayout> {Show 13 fields
palette: Palette,
layout: L,
vantage: Vantage,
viewport: Rect,
easing: Rc<RefCell<Easing>>,
tick: Tick,
pointer: Option<Pos2>,
pointer_kind: PointerKind,
draw_list: RefCell<DrawList>,
assets: RefCell<BTreeMap<AssetHash, Asset>>,
cursor: Option<Cursor>,
edit_text: Option<EditText>,
repaint: Cell<Option<Duration>>,
}Expand description
A Canvas that records. layout is the host’s text engine, so the
recorder measures the run the backend would draw; easing is the
session’s table, so an animation that started on one frame is read back on
the next.
Fields§
§palette: Palette§layout: L§vantage: Vantage§viewport: Rect§easing: Rc<RefCell<Easing>>§tick: Tick§pointer: Option<Pos2>§pointer_kind: PointerKind§draw_list: RefCell<DrawList>§assets: RefCell<BTreeMap<AssetHash, Asset>>§cursor: Option<Cursor>§edit_text: Option<EditText>§repaint: Cell<Option<Duration>>Implementations§
Source§impl<L: TextLayout> Recording<L>
impl<L: TextLayout> Recording<L>
pub fn new(frame: Frame<L>) -> Self
pub fn finish(self) -> Recorded
Sourcepub fn take_edit_text(&mut self) -> Option<EditText>
pub fn take_edit_text(&mut self) -> Option<EditText>
The editor a tool asked for so far this frame, taken off the recording
— for a driver that reads it mid-frame, where Self::finish would
end the frame.
fn record(&self, op: DrawOp)
fn w2s(&self, world: Pos2) -> Pos2
fn color(&self, swatch: impl Into<Swatch>) -> Color
fn ink(&self, stroke: impl Into<PaletteStroke>) -> Stroke
Sourcefn measure(&self, text: &str, font: &Font, wrap: WorldPx) -> Vec2
fn measure(&self, text: &str, font: &Font, wrap: WorldPx) -> Vec2
The run’s size in world units, laid out at the size it is drawn — the
backend rasterizes at font.size * zoom, so the recorder measures
there too and divides back.
Trait Implementations§
Source§impl<L: TextLayout> Animator for Recording<L>
impl<L: TextLayout> Animator for Recording<L>
Source§fn animate(&self, key: AnimKey, goal: f32, over: Duration) -> f32
fn animate(&self, key: AnimKey, goal: f32, over: Duration) -> f32
The current value of the easing keyed by
key, moving toward goal over
over. Polled every frame: the host holds the value between frames and
interpolates it by however long the last frame took.Source§fn pointer_world(&self) -> Option<Pos2>
fn pointer_world(&self) -> Option<Pos2>
The pointer in world space, if it is over the canvas.
Source§impl<L: TextLayout> Canvas for Recording<L>
impl<L: TextLayout> Canvas for Recording<L>
fn set_cursor(&mut self, cursor: Cursor)
Source§fn cursor(&self) -> Option<Cursor>
fn cursor(&self) -> Option<Cursor>
The cursor set on this canvas so far this frame, which the shell
publishes once the frame is done.
Source§fn set_edit_text(&mut self, edit: EditText)
fn set_edit_text(&mut self, edit: EditText)
Ask for an in-place text editor: the host runs one over
edit, and
how it ends reaches the next frame’s
Interaction as a
TextOutcome.Source§fn remap_rect(&self, world: Rect) -> Rect
fn remap_rect(&self, world: Rect) -> Rect
World-space rect → screen-space rect, for placing screen-space chrome
(the selection overlay) relative to on-canvas bounds.
fn request_repaint(&self)
fn request_repaint_after(&self, after: Duration)
Source§fn now(&self) -> Duration
fn now(&self) -> Duration
The frame clock: monotonic time since the host started, for what is
timed rather than eased toward a goal (the spotlight’s fade).
fn pointer_kind(&self) -> PointerKind
Source§impl<L: TextLayout> Renderer for Recording<L>
impl<L: TextLayout> Renderer for Recording<L>
fn rect( &self, rect: Rect, rounding: WorldPx, fill: impl Into<Swatch>, stroke: impl Into<PaletteStroke>, )
fn line_segment(&self, points: [Pos2; 2], stroke: impl Into<PaletteStroke>)
fn line(&self, points: Vec<Pos2>, stroke: impl Into<PaletteStroke>)
fn circle( &self, center: Pos2, radius: WorldPx, fill: impl Into<Swatch>, stroke: impl Into<PaletteStroke>, )
fn add_convex_polygon( &self, points: Vec<Pos2>, fill: impl Into<Swatch>, stroke: impl Into<PaletteStroke>, )
fn text( &self, pos: Pos2, anchor: Align2, text: impl ToString, font: &Font, color: impl Into<Swatch>, ) -> Rect
Source§fn text_wrapped(
&self,
pos: Pos2,
anchor: Align2,
text: impl ToString,
font: &Font,
color: impl Into<Swatch>,
max_width: WorldPx,
) -> Rect
fn text_wrapped( &self, pos: Pos2, anchor: Align2, text: impl ToString, font: &Font, color: impl Into<Swatch>, max_width: WorldPx, ) -> Rect
Like
Renderer::text but wraps to max_width (word wrap);
WorldPx::UNBOUNDED draws unwrapped. The default ignores max_width
and draws unwrapped; backends that lay text out override it. Both the
on-screen and the SVG backend break the text with the same layout
engine, so they agree on the break points.fn rotated_text( &self, pos: Pos2, anchor: Align2, text: impl ToString, font: &Font, color: impl Into<Swatch>, angle: Angle, )
fn text_size(&self, text: impl ToString, font: &Font) -> Vec2
Source§fn text_layout(&self, text: &str, font: &Font, max_width: WorldPx) -> Layout
fn text_layout(&self, text: &str, font: &Font, max_width: WorldPx) -> Layout
text laid out in font and word-wrapped at max_width, in world
units: the rows Self::text_size_wrapped measures.Source§fn draw_image(&self, rect: Rect, image: &Asset)
fn draw_image(&self, rect: Rect, image: &Asset)
Draw
image (an SVG or PNG payload) filling the world-space rect. The
caller sizes rect to honor the image’s aspect ratio (see
Renderer::image_intrinsic_size), so each backend simply fills rect:
the on-screen painter caches the bytes in its own hash → handle table
and polls the toolkit’s loader, while the SVG exporter embeds the bytes
as a base64 data URI.Source§fn image_intrinsic_size(&self, image: &Asset) -> Option<Vec2>
fn image_intrinsic_size(&self, image: &Asset) -> Option<Vec2>
The intrinsic point size of
image (always strictly positive), used by
the caller for aspect-fit and the resize-ring geometry. None if the
bytes are not a valid SVG/PNG.Source§fn animator(&self) -> Option<&dyn Animator>
fn animator(&self) -> Option<&dyn Animator>
The frame animation this backend drives, for interactive overlays drawn
on the generic render path. The on-screen canvas supplies itself;
offline backends (the SVG exporter) return
None, so those overlays
fall back to a static draw.Source§fn visible_world_bounds(&self) -> Option<Rect>
fn visible_world_bounds(&self) -> Option<Rect>
The world-space rect currently visible on screen, if this backend paints
into a bounded viewport. The render path uses it to viewport-cull the
scene: shapes outside it are skipped.
None (the default) means “no
viewport — draw everything”, which is what offline backends (the SVG
exporter) want, so an export is never culled.Auto Trait Implementations§
impl<L> !Freeze for Recording<L>
impl<L> !RefUnwindSafe for Recording<L>
impl<L> !Send for Recording<L>
impl<L> !Sync for Recording<L>
impl<L> Unpin for Recording<L>where
L: Unpin,
impl<L> UnsafeUnpin for Recording<L>where
L: UnsafeUnpin,
impl<L> !UnwindSafe for Recording<L>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more