pub struct Layer { /* private fields */ }
Expand description
A layer is a reusable collection of geometry (i.e. Path
s) with common properties and
order in the paint stack.
They are created by calling Composition::create_layer
or
Composition::get_mut_or_insert_default
.
§Examples
let mut composition = Composition::new();
let _layer = composition.get_mut_or_insert_default(Order::new(0).unwrap());
Implementations§
Source§impl Layer
impl Layer
Sourcepub fn insert(&mut self, path: &Path) -> &mut Self
pub fn insert(&mut self, path: &Path) -> &mut Self
Inserts path
into the geometry of the layer.
The inserted paths basically contribute to a single internal path containing the geometry of all the paths.
§Examples
let mut composition = Composition::new();
let line0 = PathBuilder::new().line_to(Point::new(10.0, 10.0)).build();
let line1 = PathBuilder::new().line_to(Point::new(10.0, 0.0)).build();
composition
.get_mut_or_insert_default(Order::new(0).unwrap())
.insert(&line0)
.insert(&line1);
Sourcepub fn clear(&mut self) -> &mut Self
pub fn clear(&mut self) -> &mut Self
Clears the geometry stored in the layer and resets its geometry ID.
§Examples
let mut composition = Composition::new();
let mut layer = composition.create_layer();
let initial_id = layer.geom_id();
layer.clear();
assert_ne!(layer.geom_id(), initial_id);
Sourcepub fn geom_id(&self) -> GeomId
pub fn geom_id(&self) -> GeomId
Returns the layer’s geometry ID.
Used to retrieve the layer’s Order
if stored in a Composition
.
§Examples
let mut composition = Composition::new();
let order = Order::new(0).unwrap();
let layer = composition.get_mut_or_insert_default(order);
let id = layer.geom_id();
assert_eq!(composition.get_order_if_stored(id), Some(order));
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns true
if the layer is enabled.
§Examples
let mut composition = Composition::new();
let layer = composition.create_layer();
assert!(layer.is_enabled());
Sourcepub fn set_is_enabled(&mut self, is_enabled: bool) -> &mut Self
pub fn set_is_enabled(&mut self, is_enabled: bool) -> &mut Self
Sets the layer’s enabled state.
§Examples
let mut composition = Composition::new();
let mut layer = composition.create_layer();
layer.set_is_enabled(false);
assert!(!layer.is_enabled());
Sourcepub fn disable(&mut self) -> &mut Self
pub fn disable(&mut self) -> &mut Self
Disables the layer.
§Examples
let mut composition = Composition::new();
let mut layer = composition.create_layer();
layer.disable();
assert!(!layer.is_enabled());
Sourcepub fn enable(&mut self) -> &mut Self
pub fn enable(&mut self) -> &mut Self
Enables the layer.
§Examples
let mut composition = Composition::new();
let mut layer = composition.create_layer();
layer.disable();
layer.enable();
assert!(layer.is_enabled());
Sourcepub fn transform(&self) -> GeomPresTransform
pub fn transform(&self) -> GeomPresTransform
Returns the layer’s transform.
§Examples
let mut composition = Composition::new();
let layer = composition.create_layer();
assert!(layer.transform().is_identity());
Sourcepub fn set_transform(&mut self, transform: GeomPresTransform) -> &mut Self
pub fn set_transform(&mut self, transform: GeomPresTransform) -> &mut Self
Sets the layer’s transform.
§Examples
let mut composition = Composition::new();
let mut layer = composition.create_layer();
layer.set_transform(AffineTransform::from([1.0, 0.0, 0.0, 1.0, 1.0, 0.0]).try_into().unwrap());
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Layer
impl !RefUnwindSafe for Layer
impl !Send for Layer
impl Sync for Layer
impl Unpin for Layer
impl !UnwindSafe for Layer
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> 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