pub struct Canvas { /* private fields */ }Expand description
The interface of one frame plus what the player did with the previous one.
Implementations§
Source§impl Canvas
impl Canvas
Sourcepub fn set_style(&self, style: ButtonStyle)
pub fn set_style(&self, style: ButtonStyle)
Sets the look of the following buttons and sliders.
Sourcepub fn style(&self) -> ButtonStyle
pub fn style(&self) -> ButtonStyle
The current button style.
Sourcepub fn frame(
&self,
rect: [f32; 4],
color: [f32; 4],
outline: [f32; 4],
radius: f32,
)
pub fn frame( &self, rect: [f32; 4], color: [f32; 4], outline: [f32; 4], radius: f32, )
A panel with an outline.
Sourcepub fn text(
&self,
text: &str,
pos: [f32; 2],
size: f32,
color: [f32; 4],
font: &str,
align: Align,
)
pub fn text( &self, text: &str, pos: [f32; 2], size: f32, color: [f32; 4], font: &str, align: Align, )
One line (or a wrapped paragraph when wrap > 0 is given via Self::paragraph) of text.
Sourcepub fn paragraph(
&self,
text: &str,
pos: [f32; 2],
width: f32,
size: f32,
color: [f32; 4],
font: &str,
)
pub fn paragraph( &self, text: &str, pos: [f32; 2], width: f32, size: f32, color: [f32; 4], font: &str, )
Text wrapped to width units.
Sourcepub fn image(&self, path: &str, rect: [f32; 4], tint: [f32; 4])
pub fn image(&self, path: &str, rect: [f32; 4], tint: [f32; 4])
An image (PNG/JPG from the assets).
A button; returns true on the frame after it was clicked.
Sourcepub fn slider(&self, id: &str, rect: [f32; 4], value: f32) -> f32
pub fn slider(&self, id: &str, rect: [f32; 4], value: f32) -> f32
A slider showing value (0..1); returns the value after the player’s change.
Sourcepub fn toggle(&self, id: &str, rect: [f32; 4], label: &str, on: bool) -> bool
pub fn toggle(&self, id: &str, rect: [f32; 4], label: &str, on: bool) -> bool
A toggle drawn as a button with ON / OFF; returns the new state.
Sourcepub fn wants_mouse(&self) -> bool
pub fn wants_mouse(&self) -> bool
Whether any interactive element is on screen (the host then shows the cursor).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Canvas
impl !RefUnwindSafe for Canvas
impl !Sync for Canvas
impl Send for Canvas
impl Unpin for Canvas
impl UnsafeUnpin for Canvas
impl UnwindSafe for Canvas
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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 more§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.