pub struct ImageLayer {
pub id: String,
pub name: String,
pub width: u32,
pub height: u32,
pub pixels: Vec<[u8; 4]>,
pub opacity: f32,
pub blend_mode: BlendMode,
pub visible: bool,
pub offset_x: i32,
pub offset_y: i32,
pub mask: Option<Vec<u8>>,
}Expand description
A layer in an image document.
Fields§
§id: String§name: String§width: u32§height: u32§pixels: Vec<[u8; 4]>§opacity: f32§blend_mode: BlendMode§visible: bool§offset_x: i32§offset_y: i32§mask: Option<Vec<u8>>Implementations§
Source§impl ImageLayer
impl ImageLayer
Sourcepub fn new(id: &str, name: &str, width: u32, height: u32) -> Self
pub fn new(id: &str, name: &str, width: u32, height: u32) -> Self
Creates a widthxheight layer with transparent pixels, full opacity, Normal blend, and zero offset.
Sourcepub fn set_pixel(&mut self, x: u32, y: u32, rgba: [u8; 4])
pub fn set_pixel(&mut self, x: u32, y: u32, rgba: [u8; 4])
Sets the RGBA pixel at (x,y) — no-op when out of bounds.
Sourcepub fn get_pixel(&self, x: u32, y: u32) -> [u8; 4]
pub fn get_pixel(&self, x: u32, y: u32) -> [u8; 4]
RGBA pixel at (x,y); transparent [0;4] when out of bounds.
Sourcepub fn set_opacity(&mut self, opacity: f32)
pub fn set_opacity(&mut self, opacity: f32)
Sets layer opacity (callers supply 0..1).
Sourcepub fn set_blend_mode(&mut self, mode: BlendMode)
pub fn set_blend_mode(&mut self, mode: BlendMode)
Sets the layer blend mode.
Sourcepub fn set_visible(&mut self, visible: bool)
pub fn set_visible(&mut self, visible: bool)
Toggles layer visibility.
Sourcepub fn set_offset(&mut self, x: i32, y: i32)
pub fn set_offset(&mut self, x: i32, y: i32)
Sets the layer pixel offset within the document.
Sourcepub fn set_rect_mask(&mut self, x: u32, y: u32, w: u32, h: u32)
pub fn set_rect_mask(&mut self, x: u32, y: u32, w: u32, h: u32)
Apply a rectangular selection mask.
Sourcepub fn clear_mask(&mut self)
pub fn clear_mask(&mut self)
Removes the layer mask.
Trait Implementations§
Source§impl Clone for ImageLayer
impl Clone for ImageLayer
Auto Trait Implementations§
impl Freeze for ImageLayer
impl RefUnwindSafe for ImageLayer
impl Send for ImageLayer
impl Sync for ImageLayer
impl Unpin for ImageLayer
impl UnsafeUnpin for ImageLayer
impl UnwindSafe for ImageLayer
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Aggregate shares in an MPC protocol.
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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