Skip to main content

Extent

Struct Extent 

Source
pub struct Extent<'r, R: Renderer> {
    inner: &'r R,
    bounds: Bounds,
}
Expand description

A Renderer that draws nothing and only measures: hand it the same draw passes the canvas runs and Extent::finish is the world-space rect they covered. Text and image sizes come from inner, the backend that would have drawn them.

Fields§

§inner: &'r R§bounds: Bounds

Implementations§

Source§

impl<'r, R: Renderer> Extent<'r, R>

Source

pub fn measuring_through(inner: &'r R) -> Self

Source

pub fn finish(self) -> Option<Rect>

The union of everything the passes drew, or None if they drew nothing.

Trait Implementations§

Source§

impl<R: Renderer> Renderer for Extent<'_, R>

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<'r, R> !Freeze for Extent<'r, R>

§

impl<'r, R> !RefUnwindSafe for Extent<'r, R>

§

impl<'r, R> Send for Extent<'r, R>
where R: Sync,

§

impl<'r, R> !Sync for Extent<'r, R>

§

impl<'r, R> Unpin for Extent<'r, R>

§

impl<'r, R> UnsafeUnpin for Extent<'r, R>

§

impl<'r, R> UnwindSafe for Extent<'r, R>
where R: RefUnwindSafe,

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