Struct Layer

Source
pub struct Layer { /* private fields */ }
Expand description

A layer is a reusable collection of geometry (i.e. Paths) 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

Source

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);
Source

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);
Source

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));
Source

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());
Source

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());
Source

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());
Source

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());
Source

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());
Source

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());
Source

pub fn props(&self) -> &Props

Returns the layer’s properties.

§Examples
let mut composition = Composition::new();

let layer = composition.create_layer();

assert_eq!(layer.props().fill_rule, FillRule::NonZero);
Source

pub fn set_props(&mut self, props: Props) -> &mut Self

Sets the layer’s properties.

§Examples
let mut composition = Composition::new();

let mut layer = composition.create_layer();

layer.set_props(Props {
    fill_rule: FillRule::EvenOdd,
    ..Default::default()
});

Trait Implementations§

Source§

impl Debug for Layer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Layer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> 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<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>