Skip to main content

Canvas

Struct Canvas 

Source
pub struct Canvas { /* private fields */ }

Implementations§

Source§

impl Canvas

Source

pub fn new() -> Canvas

Source

pub fn background(self, fill: impl Into<Fill>) -> Canvas

Source

pub fn no_background(self) -> Canvas

Source

pub fn focusable(self, focusable: bool) -> Canvas

Source

pub fn capture(self, capturable: bool) -> Canvas

Source

pub fn cursor(self, cursor: CursorIcon) -> Canvas

Source

pub fn width(self, width: impl Into<Length>) -> Canvas

Source

pub fn height(self, height: impl Into<Length>) -> Canvas

Source

pub fn min_width(self, v: f32) -> Canvas

Source

pub fn max_width(self, v: f32) -> Canvas

Source

pub fn min_height(self, v: f32) -> Canvas

Source

pub fn max_height(self, v: f32) -> Canvas

Source

pub fn flex(self, weight: f32) -> Canvas

Source

pub fn expand(self) -> Canvas

Source

pub fn fill_width(self) -> Canvas

Source

pub fn fill_height(self) -> Canvas

Source

pub fn fill_size(self) -> Canvas

Source

pub fn on_draw(self, draw: impl Fn(&mut Painter<'_, '_>) + 'static) -> Canvas

Source

pub fn with_effect<E>( self, shader: E, content: impl Fn(&mut Painter<'_, '_>) + 'static, ) -> Canvas
where 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).

Source

pub fn with_shader_pass<S>(self, pass: ShaderPass<S>) -> Canvas
where 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.

Source

pub fn with_effect_pass<S>( self, pass: ShaderPass<S>, content: impl Fn(&mut Painter<'_, '_>) + 'static, ) -> Canvas
where 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.

Source

pub fn with_layer_effect<S>( self, pass: ShaderPass<S>, first: impl Fn(&mut Painter<'_, '_>) + 'static, second: impl Fn(&mut Painter<'_, '_>) + 'static, ) -> Canvas
where 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.

Source

pub fn with_effect_chain( self, content: impl Fn(&mut Painter<'_, '_>) + 'static, chain: ShaderChain, ) -> Canvas

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.

Source

pub fn with_mask( self, mask: impl Fn(&mut Painter<'_, '_>) + 'static, content: impl Fn(&mut Painter<'_, '_>) + 'static, ) -> Canvas

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.

Source

pub fn on_pointer( self, handler: impl Fn(Point, &PointerEvent, &mut EventCtx<'_>) + 'static, ) -> Canvas

Source

pub fn key( self, key: Key, modifiers: Modifiers, action: impl Fn() + 'static, ) -> Canvas

Source

pub fn on_key(self, handler: impl Fn(&KeyEvent) -> bool + 'static) -> Canvas

Source

pub fn track(self, track: impl Fn() + 'static) -> Canvas

Source

pub fn clip(self, clip: bool) -> Canvas

Source

pub fn allow_overflow(self, px: f32) -> Canvas

Source

pub fn overflow_px(self, px: f32) -> Canvas

Source

pub fn paint_overflow(&self) -> f32

Source

pub fn grid(self, step: f32) -> Canvas

Source

pub fn grid_colored(self, step: f32, color: Color) -> Canvas

Source

pub fn axes(self) -> Canvas

Source

pub fn axes_colored(self, color: Color) -> Canvas

Source

pub fn snap_every(self, step: f32) -> Canvas

Source

pub fn snap_step(&self) -> Option<f32>

Source

pub fn snap_value(&self, value: f32) -> f32

Source

pub fn camera(self, pos: Vec2, zoom: f32) -> Canvas

Source

pub fn no_camera(self) -> Canvas

Source

pub fn camera_value(&self) -> Option<Camera>

Source

pub fn background_fill(&self) -> Option<&Fill>

Source

pub fn is_focusable(&self) -> bool

Source

pub fn cursor_icon_value(&self) -> CursorIcon

Source

pub fn binding_count(&self) -> usize

Source

pub fn world_to_local(world: Point, cam: Vec2, zoom: f32) -> Point

Source

pub fn local_to_world(local: Point, cam: Vec2, zoom: f32) -> Point

Source

pub fn view_bounds(size: Size, cam: Vec2, zoom: f32) -> Rect

Source

pub fn fit_view(content: Rect, size: Size, padding: f32) -> (Vec2, f32)

Source

pub fn snap(value: f32, step: f32) -> f32

Source

pub fn snap_point(p: Point, step: f32) -> Point

Source

pub fn lod_banded(zoom: f32, breaks: &[f32]) -> usize

Source

pub fn show_detail(zoom: f32, world: f32, min_px: f32) -> bool

Source

pub fn detail_alpha(zoom: f32, world: f32, min_px: f32, fade_px: f32) -> f32

Trait Implementations§

Source§

impl Clone for Canvas

Source§

fn clone(&self) -> Canvas

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Canvas

Source§

fn default() -> Canvas

Returns the “default value” for a type. Read more
Source§

impl View for Canvas

Source§

fn body(&self) -> impl View + 'static

Source§

fn clip_self(&self) -> bool

Source§

fn layout_style_ctx(&self, _rt: &Runtime, _el: ElementId) -> LayoutStyle

Source§

fn accessibility(&self) -> Option<Accessible>

Source§

fn arrange_override( &self, _rt: &Runtime, _el: ElementId, _rect: Rect, _ctx: &mut LayoutCtx<'_>, ) -> bool

Source§

fn clip_radius(&self) -> f32

Source§

fn paint_opacity(&self) -> Option<f32>

Source§

fn cache_layer(&self) -> bool

Allows the runtime to replay this element’s painted subtree from cache while its element revision and absolute paint context stay unchanged. Read more
Source§

fn paint_opacity_ctx(&self, _rt: &Runtime, _el: ElementId) -> Option<f32>

Source§

fn paint_offset(&self) -> Vec2

Source§

fn paint_offset_ctx(&self, _rt: &Runtime, _el: ElementId) -> Vec2

Source§

fn paint_scale(&self) -> f32

Source§

fn paint_scale_ctx(&self, _rt: &Runtime, _el: ElementId) -> f32

Source§

fn paint_rotation(&self) -> f32

Source§

fn paint_rotation_ctx(&self, _rt: &Runtime, _el: ElementId) -> f32

Source§

fn foreground_filter(&self) -> Option<Filter>

Source§

fn captures_pointer_ctx(&self, _rt: &Runtime, _el: ElementId) -> bool

Source§

fn reuse_state(&self, _old: &Self)

Source§

fn hit_testable(&self) -> bool

Source§

fn test_id(&self) -> Option<String>

Source§

fn focus_trap(&self) -> bool

Source§

fn accepts_tab(&self) -> bool

Source§

fn accepts_text_input(&self) -> bool

Whether this view edits text when focused. Read more
Source§

fn ime_caret_rect(&self) -> Option<Rect>

Caret rectangle in window coordinates, used to place the platform IME candidate window. Widgets with a text caret return the box the caret occupies; hosts fall back to the focused element’s bounds when this is None.
Source§

fn paint_foreground(&self, _ctx: &mut PaintCtx<'_>)

Source§

fn accepts_drop(&self, _payload: &DragPayload) -> bool

Source§

fn on_drag_over(&self, _pos: DropPosition, _ctx: &mut EventCtx<'_>)

Source§

fn on_drop(&self, _pos: DropPosition, _ctx: &mut EventCtx<'_>)

Source§

fn on_drag_start(&self, _ctx: &mut EventCtx<'_>)

Source§

fn on_drag_end(&self, _end: DragEnd, _ctx: &mut EventCtx<'_>)

Auto Trait Implementations§

§

impl !RefUnwindSafe for Canvas

§

impl !Send for Canvas

§

impl !Sync for Canvas

§

impl !UnwindSafe for Canvas

§

impl Freeze for Canvas

§

impl Unpin for Canvas

§

impl UnsafeUnpin for Canvas

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> FilterExt for T
where T: View + 'static,

Source§

fn blur_own(self, radius: f32) -> Filtered

Source§

fn blur_own_with(self, build: impl FnOnce(Filter) -> Filter) -> Filtered

Source§

fn blur_behind(self, radius: f32) -> BackdropFiltered

Source§

fn blur_behind_with( self, build: impl FnOnce(Backdrop) -> Backdrop, ) -> BackdropFiltered

Source§

fn effect(self, effect: Effect) -> EffectNode

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> LiveExt for T
where T: View + 'static,

Source§

fn opacity_live(self, live: impl Into<Live<f32>>) -> LiveOpacity

Source§

fn offset_live(self, live: impl Into<Live<Vec2>>) -> LiveOffset

Source§

fn background_live(self, live: impl Into<Live<Color>>) -> LiveBackground

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> ViewModifiers for T
where T: View + 'static,

Source§

fn opacity(self, opacity: impl Into<Live<f32>>) -> LiveOpacity

Source§

fn offset(self, dx: f32, dy: f32) -> LiveOffset

Source§

fn offset_by(self, offset: impl Into<Live<Vec2>>) -> LiveOffset

Source§

fn background(self, color: impl Into<Live<Color>>) -> LiveBackground

Source§

fn bg(self, color: impl Into<Live<Color>>) -> LiveBackground

Source§

fn blur(self, px: f32) -> Filtered

Source§

fn shadow(self, spec: ShadowSpec) -> EffectNode

Wraps the view in an EffectNode that paints spec behind it. Read more
Source§

fn clip(self) -> Clip

Source§

fn clip_rounded(self, radius: f32) -> Clip

Source§

fn scale(self, scale: impl Into<Live<f32>>) -> Scaled

Source§

fn rotate(self, degrees: impl Into<Live<f32>>) -> Rotated

Source§

fn width_live(self, width: impl Into<Live<f32>>) -> AnimatedSize

Source§

fn height_live(self, height: impl Into<Live<f32>>) -> AnimatedSize

Source§

fn size_live( self, width: impl Into<Live<f32>>, height: impl Into<Live<f32>>, ) -> AnimatedSize

Source§

fn animate(self, spec: impl Into<AnimSpec>) -> Enter

Source§

fn enter(self, motion: impl Into<Motion>) -> Enter

Source§

fn hover(self, build: impl FnOnce(StatePatch) -> StatePatch) -> States

Source§

fn pressed(self, build: impl FnOnce(StatePatch) -> StatePatch) -> States

Source§

fn focused(self, build: impl FnOnce(StatePatch) -> StatePatch) -> States

Source§

fn selected(self, build: impl FnOnce(StatePatch) -> StatePatch) -> States

Source§

fn disabled(self, build: impl FnOnce(StatePatch) -> StatePatch) -> States

Source§

fn state(self, build: impl FnOnce(States) -> States) -> States

Source§

fn margin(self, margin: impl Into<Edges>) -> Margined

Source§

fn margin_xy(self, x: f32, y: f32) -> Margined

Source§

fn margin_x(self, x: f32) -> Margined

Source§

fn margin_y(self, y: f32) -> Margined

Source§

fn margin_left(self, v: f32) -> Margined

Source§

fn margin_right(self, v: f32) -> Margined

Source§

fn margin_top(self, v: f32) -> Margined

Source§

fn margin_bottom(self, v: f32) -> Margined

Source§

fn indent_top(self, v: f32) -> Margined

Source§

fn indent_bottom(self, v: f32) -> Margined

Source§

fn indent_left(self, v: f32) -> Margined

Source§

fn indent_right(self, v: f32) -> Margined

Source§

fn indent(self, indents: Indents) -> Margined

Source§

fn indent_all(self, v: f32) -> Margined

Source§

fn indent_xy(self, x: f32, y: f32) -> Margined

Source§

fn indent_axes(self, horizontal: f32, vertical: f32) -> Margined

Source§

impl<T> ViewState for T
where T: Default + 'static,