Struct forma_render::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§

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

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

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

Returns true if the layer is enabled.

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

let layer = composition.create_layer();

assert!(layer.is_enabled());

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

Disables the layer.

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

let mut layer = composition.create_layer();

layer.disable();

assert!(!layer.is_enabled());

Enables the layer.

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

let mut layer = composition.create_layer();

layer.disable();
layer.enable();

assert!(layer.is_enabled());

Returns the layer’s transform.

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

let layer = composition.create_layer();

assert!(layer.transform().is_identity());

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

Returns the layer’s properties.

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

let layer = composition.create_layer();

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

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§

Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.