Skip to main content

Recording

Struct Recording 

Source
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>

Source

pub fn new(frame: Frame<L>) -> Self

Source

pub fn finish(self) -> Recorded

Source

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.

Source

fn record(&self, op: DrawOp)

Source

fn w2s(&self, world: Pos2) -> Pos2

Source

fn color(&self, swatch: impl Into<Swatch>) -> Color

Source

fn ink(&self, stroke: impl Into<PaletteStroke>) -> Stroke

Source

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.

Source

fn laid(&self, text: &str, font: &Font, wrap: WorldPx) -> Vec2

The run’s screen-space size.

Source

fn laid_out(&self, text: &str, font: &Font, wrap: WorldPx) -> Layout

The run laid out in screen space.

Source

fn write( &self, pos: Pos2, anchor: Align2, text: &str, font: &Font, color: Color, max_width: WorldPx, ) -> Rect

Record one run and answer the screen-space rect it occupies — the same answer the on-screen painter gives, since it is the same layout.

Trait Implementations§

Source§

impl<L: TextLayout> Animator for Recording<L>

Source§

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>

The pointer in world space, if it is over the canvas.
Source§

impl<L: TextLayout> Canvas for Recording<L>

Source§

fn set_cursor(&mut self, cursor: Cursor)

Source§

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)

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

World-space rect → screen-space rect, for placing screen-space chrome (the selection overlay) relative to on-canvas bounds.
Source§

fn request_repaint(&self)

Source§

fn request_repaint_after(&self, after: Duration)

Source§

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).
Source§

fn pointer_kind(&self) -> PointerKind

Source§

impl<L: TextLayout> Renderer for Recording<L>

Source§

fn rect( &self, rect: Rect, rounding: WorldPx, fill: impl Into<Swatch>, stroke: impl Into<PaletteStroke>, )

Source§

fn line_segment(&self, points: [Pos2; 2], stroke: impl Into<PaletteStroke>)

Source§

fn line(&self, points: Vec<Pos2>, stroke: impl Into<PaletteStroke>)

Source§

fn circle( &self, center: Pos2, radius: WorldPx, fill: impl Into<Swatch>, stroke: impl Into<PaletteStroke>, )

Source§

fn add_convex_polygon( &self, points: Vec<Pos2>, fill: impl Into<Swatch>, stroke: impl Into<PaletteStroke>, )

Source§

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

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.
Source§

fn rotated_text( &self, pos: Pos2, anchor: Align2, text: impl ToString, font: &Font, color: impl Into<Swatch>, angle: Angle, )

Source§

fn text_size(&self, text: impl ToString, font: &Font) -> Vec2

Source§

fn text_size_wrapped( &self, text: impl ToString, font: &Font, max_width: WorldPx, ) -> Vec2

Like Renderer::text_size but measured with word wrap at max_width. The default ignores max_width.
Source§

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)

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>

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>

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>

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more