CAEmitterLayerBuilder

Struct CAEmitterLayerBuilder 

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

Builder for a particle emitter layer.

let emitter = CAEmitterLayerBuilder::new()
    .position(320.0, 320.0)
    .shape(EmitterShape::Point)
    .particle(|p| p
        .birth_rate(100.0)
        .lifetime(5.0)
        .velocity(80.0)
        .color(Color::CYAN)
    )
    .build();

Implementations§

Source§

impl CAEmitterLayerBuilder

Source

pub fn new() -> Self

Create a new emitter layer builder.

Source

pub fn position(self, x: f64, y: f64) -> Self

Set the emitter position.

Source

pub fn size(self, width: f64, height: f64) -> Self

Set the emitter size (for Line, Rectangle, etc.).

Source

pub fn shape(self, shape: EmitterShape) -> Self

Set the emitter shape.

Source

pub fn mode(self, mode: EmitterMode) -> Self

Set the emitter mode.

Source

pub fn render_mode(self, mode: RenderMode) -> Self

Set the render mode.

Source

pub fn birth_rate(self, rate: f32) -> Self

Set the overall birth rate multiplier.

This multiplies the birth rate of all cells. Use 0.0 to pause emission, 1.0 for normal rate.

Source

pub fn particle<F>(self, configure: F) -> Self

Add a particle type using a closure to configure it.

§Example
.particle(|p| p
    .birth_rate(100.0)
    .lifetime(10.0)
    .velocity(100.0)
)
Source

pub fn cell(self, cell: Retained<CAEmitterCell>) -> Self

Add a pre-built cell directly.

Prefer using .particle() for most cases.

Source

pub fn build(self) -> Retained<CAEmitterLayer>

Build the CAEmitterLayer.

Trait Implementations§

Source§

impl Default for CAEmitterLayerBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> 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, 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> AutoreleaseSafe for T
where T: ?Sized,