pub struct CanvasFit { /* private fields */ }Expand description
Pure adapter data for an existing ferravex_render::canvas::Canvas2D.
This crate cannot depend on the renderer, which already depends on play.
The renderer’s Canvas2D::from_fit consumes this value without recomputing
geometry; its camera() honors the asymmetric offset automatically. A custom
adapter can use size = viewport().bounds().size, screen = screen(),
scale = viewport().scale() and offset = viewport().pixels().min.
Self::camera_offset supplies normalized translation for hosts constructing
their camera directly.
Use viewport().unproject(pointer) or Canvas2D::pointer_half_open for
half-open world hit testing. Legacy Canvas2D::pointer includes its far
edges, so it can also accept a
shared HUD boundary. This adapter does not clip out-of-world draw commands;
callers keep their authored world bounds or apply their existing clipping.
See HudRegions::fit_canvas for an executable fitting/input example.
Implementations§
Source§impl CanvasFit
impl CanvasFit
Sourcepub fn viewport(self) -> Viewport
pub fn viewport(self) -> Viewport
World coordinates, displayed rectangle and matching half-open hit mapping.
Sourcepub fn screen(self) -> [f32; 2]
pub fn screen(self) -> [f32; 2]
Full host screen size, not the reserved content size; used by the camera.
Sourcepub fn camera_offset(self) -> [f32; 2]
pub fn camera_offset(self) -> [f32; 2]
Translation in normalized camera coordinates (positive Y points up).
Use for a custom camera adapter. Canvas2D::from_fit(self).camera() already
supplies the corresponding translation; no extra assignment is required.