pub enum CanvasBackground {
None,
Dots(PatternConfig),
Grid(PatternConfig),
Crosshatch(PatternConfig),
}Expand description
Background pattern for an infinite canvas.
Set via kit.set_background() or kit.with_background().
Drawn automatically by kit.element() before the user’s render callback.
Variants§
None
No background pattern.
Dots(PatternConfig)
Dot grid at regular spacing.
Grid(PatternConfig)
Horizontal + vertical lines.
Crosshatch(PatternConfig)
Diagonal lines at ±45°.
Implementations§
Source§impl CanvasBackground
impl CanvasBackground
Sourcepub fn crosshatch() -> Self
pub fn crosshatch() -> Self
Crosshatch with defaults: spacing=40, light gray, size=1.
Sourcepub fn with_spacing(self, spacing: f32) -> Self
pub fn with_spacing(self, spacing: f32) -> Self
Customize spacing.
Sourcepub fn with_color(self, color: Color) -> Self
pub fn with_color(self, color: Color) -> Self
Customize color.
Sourcepub fn with_zoom_adaptive(self, threshold: f32, coarse_factor: u32) -> Self
pub fn with_zoom_adaptive(self, threshold: f32, coarse_factor: u32) -> Self
Enable zoom-adaptive rendering.
Below threshold zoom, show every coarse_factor-th element.
Source§impl CanvasBackground
impl CanvasBackground
Sourcepub fn draw(
&self,
ctx: &mut dyn DrawContext,
viewport: &CanvasViewport,
screen_w: f32,
screen_h: f32,
)
pub fn draw( &self, ctx: &mut dyn DrawContext, viewport: &CanvasViewport, screen_w: f32, screen_h: f32, )
Draw the background pattern for the visible viewport region.
Called with the viewport transform already pushed on DrawContext.
screen_w / screen_h come from CanvasBounds.
Trait Implementations§
Source§impl Clone for CanvasBackground
impl Clone for CanvasBackground
Source§fn clone(&self) -> CanvasBackground
fn clone(&self) -> CanvasBackground
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CanvasBackground
impl RefUnwindSafe for CanvasBackground
impl Send for CanvasBackground
impl Sync for CanvasBackground
impl Unpin for CanvasBackground
impl UnsafeUnpin for CanvasBackground
impl UnwindSafe for CanvasBackground
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