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: BoundsImplementations§
Trait Implementations§
Source§impl<R: Renderer> Renderer for Extent<'_, R>
impl<R: Renderer> Renderer for Extent<'_, R>
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<'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> 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