pub struct HtmlCanvasElement(/* private fields */);Expand description
A canvas element (<canvas>).
Chrome equivalent: HTMLCanvasElement.
Replaced element — intrinsic size from width/height attributes.
Implementations§
Source§impl HtmlCanvasElement
impl HtmlCanvasElement
pub fn canvas_width(&self) -> f32
pub fn set_canvas_width(&self, value: impl Into<f32>)
pub fn canvas_height(&self) -> f32
pub fn set_canvas_height(&self, value: impl Into<f32>)
Trait Implementations§
Source§impl Clone for HtmlCanvasElement
impl Clone for HtmlCanvasElement
Source§fn clone(&self) -> HtmlCanvasElement
fn clone(&self) -> HtmlCanvasElement
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 moreSource§impl ContainerNode for HtmlCanvasElement
impl ContainerNode for HtmlCanvasElement
Source§fn append(&self, child: impl HasHandle)
fn append(&self, child: impl HasHandle)
Append
child as the last child of this node. Read moreSource§fn child(self, child: impl HasHandle) -> Self
fn child(self, child: impl HasHandle) -> Self
Append a child and return self for chaining (GPUI-style). Read more
Source§fn add_children<I, C>(self, items: I) -> Selfwhere
I: IntoIterator<Item = C>,
C: HasHandle,
fn add_children<I, C>(self, items: I) -> Selfwhere
I: IntoIterator<Item = C>,
C: HasHandle,
Append multiple children at once.
Source§fn insert_before(&self, child: impl HasHandle)
fn insert_before(&self, child: impl HasHandle)
Insert
child before this node in the parent’s child list.Source§fn first_child(&self) -> Option<Handle>
fn first_child(&self) -> Option<Handle>
Get the first child, or
None if empty.Source§fn last_child(&self) -> Option<Handle>
fn last_child(&self) -> Option<Handle>
Get the last child, or
None if empty.Source§impl Debug for HtmlCanvasElement
impl Debug for HtmlCanvasElement
Source§impl Element for HtmlCanvasElement
impl Element for HtmlCanvasElement
Source§const IS_FOCUSABLE: bool = false
const IS_FOCUSABLE: bool = false
Whether this element is focusable by default.
Source§type Data = CanvasData
type Data = CanvasData
Element-specific data type (e.g.,
ButtonData). Use () if none.Source§fn from_handle(handle: Handle) -> Self
fn from_handle(handle: Handle) -> Self
Wrap a raw Handle into this element’s typed handle. Read more
Source§fn tag_name(&self) -> &'static str
fn tag_name(&self) -> &'static str
Get the tag name (runtime — reads from
ElementData). Read moreSource§fn class_name(&self) -> String
fn class_name(&self) -> String
Get the
class attribute.Source§fn set_class_name(&self, class: impl Into<String>)
fn set_class_name(&self, class: impl Into<String>)
Set the
class attribute.Source§fn class_add(&self, name: &str)
fn class_add(&self, name: &str)
Add a CSS class. No-op if already present.
Chrome:
element.classList.add("name").Source§fn class_remove(&self, name: &str)
fn class_remove(&self, name: &str)
Remove a CSS class. No-op if absent.
Chrome:
element.classList.remove("name").Source§fn class_toggle(&self, name: &str) -> bool
fn class_toggle(&self, name: &str) -> bool
Toggle a CSS class. Returns true if now present.
Chrome:
element.classList.toggle("name").Source§fn class_contains(&self, name: &str) -> bool
fn class_contains(&self, name: &str) -> bool
Check if an element has a CSS class.
Chrome:
element.classList.contains("name").Source§impl EventTarget for HtmlCanvasElement
impl EventTarget for HtmlCanvasElement
Source§fn on<E: Event>(
&self,
callback: impl FnMut(&E, &EventContext) + 'static,
) -> ListenerId
fn on<E: Event>( &self, callback: impl FnMut(&E, &EventContext) + 'static, ) -> ListenerId
Add a typed event listener. Returns an ID for removal. Read more
Source§fn on_with_options<E: Event>(
&self,
callback: impl FnMut(&E, &EventContext) + 'static,
options: ListenerOptions,
) -> ListenerId
fn on_with_options<E: Event>( &self, callback: impl FnMut(&E, &EventContext) + 'static, options: ListenerOptions, ) -> ListenerId
Add a listener with explicit options. Read more
Source§fn on_capture<E: Event>(
&self,
callback: impl FnMut(&E, &EventContext) + 'static,
) -> ListenerId
fn on_capture<E: Event>( &self, callback: impl FnMut(&E, &EventContext) + 'static, ) -> ListenerId
Add a capture-phase listener. Read more
Source§fn on_once<E: Event>(
&self,
callback: impl FnMut(&E, &EventContext) + 'static,
) -> ListenerId
fn on_once<E: Event>( &self, callback: impl FnMut(&E, &EventContext) + 'static, ) -> ListenerId
Add a one-shot listener that auto-removes after first call.
Source§fn off(&self, id: ListenerId)
fn off(&self, id: ListenerId)
Remove a listener by its ID.
Source§impl HasHandle for HtmlCanvasElement
impl HasHandle for HtmlCanvasElement
Source§impl HtmlElement for HtmlCanvasElement
impl HtmlElement for HtmlCanvasElement
The
hidden attribute. Elements with hidden should not be rendered.fn set_title(&self, title: impl Into<String>)
fn set_lang(&self, lang: impl Into<String>)
fn set_dir(&self, dir: impl Into<String>)
Source§fn tab_index(&self) -> i32
fn tab_index(&self) -> i32
The
tabindex attribute. Controls focus order.
Returns the element’s default if not explicitly set.fn set_tab_index(&self, index: i32)
fn set_draggable(&self, draggable: bool)
Source§fn spellcheck(&self) -> bool
fn spellcheck(&self) -> bool
The
spellcheck attribute.fn set_spellcheck(&self, spellcheck: bool)
Source§fn collect_presentation_styles(&self)
fn collect_presentation_styles(&self)
Map presentation attributes to a
PropertyDeclarationBlock. Read moreSource§impl Node for HtmlCanvasElement
impl Node for HtmlCanvasElement
Source§fn parent(&self) -> Option<Handle>
fn parent(&self) -> Option<Handle>
Get the parent node, or
None if this is the root or detached.Source§fn next_sibling(&self) -> Option<Handle>
fn next_sibling(&self) -> Option<Handle>
Get the next sibling in the parent’s child list.
Source§fn prev_sibling(&self) -> Option<Handle>
fn prev_sibling(&self) -> Option<Handle>
Get the previous sibling in the parent’s child list.
Source§fn detach(&self)
fn detach(&self)
Detach this node from its parent. The node stays alive but is no longer in the tree.
Source§fn node_kind(&self) -> Option<NodeType>
fn node_kind(&self) -> Option<NodeType>
Get the DOM node type (Element, Text, Document, etc.).
Source§fn is_element(&self) -> bool
fn is_element(&self) -> bool
Is this an element node?
Source§fn is_document(&self) -> bool
fn is_document(&self) -> bool
Is this the document root?
Source§fn style(&self) -> StyleAccess
fn style(&self) -> StyleAccess
Per-property style access — like JavaScript’s
element.style.Source§impl ReplacedElement for HtmlCanvasElement
impl ReplacedElement for HtmlCanvasElement
Source§fn intrinsic_sizing(&self) -> IntrinsicSizing
fn intrinsic_sizing(&self) -> IntrinsicSizing
Get the element’s intrinsic (natural) dimensions. Read more
Source§fn notify_intrinsic_size_changed(&self)
fn notify_intrinsic_size_changed(&self)
Notify that intrinsic dimensions have changed. Read more
impl Copy for HtmlCanvasElement
Auto Trait Implementations§
impl Freeze for HtmlCanvasElement
impl !RefUnwindSafe for HtmlCanvasElement
impl Send for HtmlCanvasElement
impl !Sync for HtmlCanvasElement
impl Unpin for HtmlCanvasElement
impl UnsafeUnpin for HtmlCanvasElement
impl !UnwindSafe for HtmlCanvasElement
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
Source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
Source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
Source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert