pub struct CursorImage { /* private fields */ }Expand description
Represents a generic cursor image.
Implementations§
Source§impl CursorImage
impl CursorImage
Sourcepub fn new(
width: u32,
height: u32,
hotspot_x: u32,
hotspot_y: u32,
rgba: Vec<u8>,
delay: u32,
) -> Result<Self>
pub fn new( width: u32, height: u32, hotspot_x: u32, hotspot_y: u32, rgba: Vec<u8>, delay: u32, ) -> Result<Self>
Contructor for a CursorImage.
§Errors
- If
TryIntoconversions fail. - If
hotspot_x > widthand ditto for y. - If
width * height * 4 != rgba.len().
Sourcepub fn from_entry(entry: &IconDirEntry, delay: u32) -> Result<Self>
pub fn from_entry(entry: &IconDirEntry, delay: u32) -> Result<Self>
Helper function for constructing from an entry.
Entries don’t store delay unlike Xcursor, so it’s a separate parameter.
§Errors
If the entry isn’t a cursor (no hotspot), or RGBA fails to decode.
Sourcepub fn scaled_to(&self, scale_factor: f64, algorithm: ResizeAlg) -> Result<Self>
pub fn scaled_to(&self, scale_factor: f64, algorithm: ResizeAlg) -> Result<Self>
Returns a new CursorImage scaled to scale_factor.
§Errors
Sourcepub fn scale_point(point: (u32, u32), scale_factor: f64) -> (u32, u32)
pub fn scale_point(point: (u32, u32), scale_factor: f64) -> (u32, u32)
Helper function for Self::scaled_to.
Sourcepub const fn dimensions(&self) -> (u32, u32)
pub const fn dimensions(&self) -> (u32, u32)
Returns image dimensions as (width, height).
Sourcepub fn nominal_size(&self) -> u32
pub fn nominal_size(&self) -> u32
Returns the max of width and height.
Trait Implementations§
Source§impl Clone for CursorImage
impl Clone for CursorImage
Source§fn clone(&self) -> CursorImage
fn clone(&self) -> CursorImage
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 moreAuto Trait Implementations§
impl Freeze for CursorImage
impl RefUnwindSafe for CursorImage
impl Send for CursorImage
impl Sync for CursorImage
impl Unpin for CursorImage
impl UnsafeUnpin for CursorImage
impl UnwindSafe for CursorImage
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 more