pub struct Canvas { /* private fields */ }Implementations§
Source§impl Canvas
impl Canvas
pub fn new() -> Self
pub fn background(self, fill: impl Into<Fill>) -> Self
pub fn no_background(self) -> Self
pub fn focusable(self, focusable: bool) -> Self
pub fn capture(self, capturable: bool) -> Self
pub fn cursor(self, cursor: CursorIcon) -> Self
pub fn width(self, width: impl Into<Length>) -> Self
pub fn height(self, height: impl Into<Length>) -> Self
pub fn min_width(self, v: f32) -> Self
pub fn max_width(self, v: f32) -> Self
pub fn min_height(self, v: f32) -> Self
pub fn max_height(self, v: f32) -> Self
pub fn flex(self, weight: f32) -> Self
pub fn expand(self) -> Self
pub fn fill_width(self) -> Self
pub fn fill_height(self) -> Self
pub fn fill_size(self) -> Self
pub fn on_draw(self, draw: impl Fn(&mut Painter<'_, '_>) + 'static) -> Self
Sourcepub fn with_effect<E>(
self,
shader: E,
content: impl Fn(&mut Painter<'_, '_>) + 'static,
) -> Selfwhere
E: SequoiShader + Copy + 'static,
pub fn with_effect<E>(
self,
shader: E,
content: impl Fn(&mut Painter<'_, '_>) + 'static,
) -> Selfwhere
E: SequoiShader + Copy + 'static,
Replaces the canvas draw with content piped through shader.
content renders into an offscreen target and shader is drawn over the
whole canvas with that target bound as its content input. The shader
must be registered (see App::shader_type).
Sourcepub fn with_shader_pass<S>(self, pass: ShaderPass<S>) -> Selfwhere
S: SequoiShader + Copy + 'static,
pub fn with_shader_pass<S>(self, pass: ShaderPass<S>) -> Selfwhere
S: SequoiShader + Copy + 'static,
Replaces the canvas draw with a configured shader pass.
The pass draws over the canvas bounds unless ShaderPass::at was
used. Missing registrations log a warning and skip the draw.
Sourcepub fn with_effect_pass<S>(
self,
pass: ShaderPass<S>,
content: impl Fn(&mut Painter<'_, '_>) + 'static,
) -> Selfwhere
S: SequoiShader + Copy + 'static,
pub fn with_effect_pass<S>(
self,
pass: ShaderPass<S>,
content: impl Fn(&mut Painter<'_, '_>) + 'static,
) -> Selfwhere
S: SequoiShader + Copy + 'static,
Replaces the canvas draw with content piped through a configured pass.
The pass’s first declared texture is bound to the captured content unless
the pass already binds it explicitly. Use this instead of with_effect
when the effect has extra uniforms, a blend mode, or a UV window.
Sourcepub fn with_layer_effect<S>(
self,
pass: ShaderPass<S>,
first: impl Fn(&mut Painter<'_, '_>) + 'static,
second: impl Fn(&mut Painter<'_, '_>) + 'static,
) -> Selfwhere
S: SequoiShader + Copy + 'static,
pub fn with_layer_effect<S>(
self,
pass: ShaderPass<S>,
first: impl Fn(&mut Painter<'_, '_>) + 'static,
second: impl Fn(&mut Painter<'_, '_>) + 'static,
) -> Selfwhere
S: SequoiShader + Copy + 'static,
Captures two layers and feeds them to the pass in declaration order.
This is the convenient form of a transition or a two-input composite:
the first shader texture receives first, the second receives second.
Sourcepub fn with_effect_chain(
self,
content: impl Fn(&mut Painter<'_, '_>) + 'static,
chain: ShaderChain,
) -> Self
pub fn with_effect_chain( self, content: impl Fn(&mut Painter<'_, '_>) + 'static, chain: ShaderChain, ) -> Self
Pipes content through every pass in chain.
Intermediate results live in offscreen targets; the final pass draws into the canvas. A pass that is not registered is skipped and its input is forwarded, so an optional effect does not blank the layer.
Sourcepub fn with_mask(
self,
mask: impl Fn(&mut Painter<'_, '_>) + 'static,
content: impl Fn(&mut Painter<'_, '_>) + 'static,
) -> Self
pub fn with_mask( self, mask: impl Fn(&mut Painter<'_, '_>) + 'static, content: impl Fn(&mut Painter<'_, '_>) + 'static, ) -> Self
Replaces the canvas draw with content masked by mask.
Both closures render into their own offscreen target; the built-in
apply_mask shader keeps the layer color and multiplies its alpha by the
mask alpha.
pub fn on_pointer( self, handler: impl Fn(Point, &PointerEvent, &mut EventCtx<'_>) + 'static, ) -> Self
pub fn key( self, key: Key, modifiers: Modifiers, action: impl Fn() + 'static, ) -> Self
pub fn on_key(self, handler: impl Fn(&KeyEvent) -> bool + 'static) -> Self
pub fn track(self, track: impl Fn() + 'static) -> Self
pub fn clip(self, clip: bool) -> Self
pub fn allow_overflow(self, px: f32) -> Self
pub fn overflow_px(self, px: f32) -> Self
pub fn paint_overflow(&self) -> f32
pub fn grid(self, step: f32) -> Self
pub fn grid_colored(self, step: f32, color: Color) -> Self
pub fn axes(self) -> Self
pub fn axes_colored(self, color: Color) -> Self
pub fn snap_every(self, step: f32) -> Self
pub fn snap_step(&self) -> Option<f32>
pub fn snap_value(&self, value: f32) -> f32
pub fn camera(self, pos: Vec2, zoom: f32) -> Self
pub fn no_camera(self) -> Self
pub fn camera_value(&self) -> Option<Camera>
pub fn background_fill(&self) -> Option<&Fill>
pub fn is_focusable(&self) -> bool
pub fn cursor_icon_value(&self) -> CursorIcon
pub fn binding_count(&self) -> usize
pub fn world_to_local(world: Point, cam: Vec2, zoom: f32) -> Point
pub fn local_to_world(local: Point, cam: Vec2, zoom: f32) -> Point
pub fn view_bounds(size: Size, cam: Vec2, zoom: f32) -> Rect
pub fn fit_view(content: Rect, size: Size, padding: f32) -> (Vec2, f32)
pub fn snap(value: f32, step: f32) -> f32
pub fn snap_point(p: Point, step: f32) -> Point
pub fn lod_banded(zoom: f32, breaks: &[f32]) -> usize
pub fn show_detail(zoom: f32, world: f32, min_px: f32) -> bool
pub fn detail_alpha(zoom: f32, world: f32, min_px: f32, fade_px: f32) -> f32
Trait Implementations§
Source§impl View for Canvas
impl View for Canvas
fn body(&self) -> impl View + 'static
fn clip_self(&self) -> bool
fn layout_style_ctx(&self, _rt: &Runtime, _el: ElementId) -> LayoutStyle
fn accessibility(&self) -> Option<Accessible>
fn arrange_override( &self, _rt: &Runtime, _el: ElementId, _rect: Rect, _ctx: &mut LayoutCtx<'_>, ) -> bool
fn clip_radius(&self) -> f32
fn paint_opacity(&self) -> Option<f32>
Source§fn cache_layer(&self) -> bool
fn cache_layer(&self) -> bool
fn paint_opacity_ctx(&self, _rt: &Runtime, _el: ElementId) -> Option<f32>
fn paint_offset(&self) -> Vec2
fn paint_offset_ctx(&self, _rt: &Runtime, _el: ElementId) -> Vec2
fn paint_scale(&self) -> f32
fn paint_scale_ctx(&self, _rt: &Runtime, _el: ElementId) -> f32
fn paint_rotation(&self) -> f32
fn paint_rotation_ctx(&self, _rt: &Runtime, _el: ElementId) -> f32
fn foreground_filter(&self) -> Option<Filter>
fn captures_pointer_ctx(&self, _rt: &Runtime, _el: ElementId) -> bool
fn reuse_state(&self, _old: &Self)
fn hit_testable(&self) -> bool
fn test_id(&self) -> Option<String>
fn focus_trap(&self) -> bool
fn accepts_tab(&self) -> bool
Source§fn accepts_text_input(&self) -> bool
fn accepts_text_input(&self) -> bool
Source§fn ime_caret_rect(&self) -> Option<Rect>
fn ime_caret_rect(&self) -> Option<Rect>
None.