Skip to main content

WebCanvasApp

Struct WebCanvasApp 

Source
pub struct WebCanvasApp {
    pub engine: VeloxEngine,
    /* private fields */
}
Expand description

面向自适应网页窗口的动态分辨率 WebAssembly <canvas> 应用实例。

Fields§

§engine: VeloxEngine

Implementations§

Source§

impl WebCanvasApp

Source

pub fn new(width: i16, height: i16) -> Self

创建指定初始画布宽高 (width, height) 的 WebAssembly 应用宿主。

Source

pub fn set_dpi_scale(&mut self, scale: i16)

设置物理像素 HiDPI 缩放倍率(如 Retina 2x / 3x),布局与点击事件保持逻辑坐标 (width, height)。

Source

pub const fn dpi_scale(&self) -> i16

获取当前 HiDPI 缩放倍率。

Source

pub fn resize(&mut self, width: i16, height: i16)

响应浏览器 ResizeObserver 或 window.onresize 动态调整画布分辨率。

Source

pub fn set_safe_area(&mut self, top: i16, right: i16, bottom: i16, left: i16)

同步浏览器 env(safe-area-inset-*) 安全区边距。

Source

pub fn set_async_waker(&mut self, waker: impl Fn() + Send + Sync + 'static)

注入 Web 宿主唤醒回调(例如 queueMicrotask / requestAnimationFrame 触发器)。

Source

pub fn poll_async_tasks(&mut self) -> bool

排空浏览器主线程中所有已就绪的前景异步协程与 defer 回调。

Source

pub fn needs_redraw(&self) -> bool

是否存在待重绘脏视图、动画或已就绪异步任务(用于决定浏览器是否按需暂停 requestAnimationFrame)。

Source

pub fn step_frame(&mut self, dt_ms: u16) -> usize

推进一帧渲染并光栅化所有脏矩形,返回本帧脏矩形个数。

Source

pub fn rgba_bytes(&self) -> &[u8] ⓘ

获取供浏览器 ImageData 零拷贝读取的 RGBA8888 字节切片。

Source

pub fn dirty_rects(&self) -> &[CDirtyRect]

获取本帧脏矩形切片。

Source

pub fn cursor_shape(&self) -> CursorShape

获取当前指针下方组件要求的鼠标光标形状(供 <canvas> 实时同步 canvas.style.cursor)。

Source

pub fn cursor_css(&self) -> &'static str

获取当前鼠标光标对应的标准 CSS cursor 字符串。

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> FluentBuilder for T

Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self

当 condition 为 true 时执行闭包修饰自身,否则原样返回。
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.