CAEmitterCellBuilder

Struct CAEmitterCellBuilder 

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

Builder for a particle type.

Used via CAEmitterLayerBuilder::particle(|p| p.birth_rate(...)).

Implementations§

Source§

impl CAEmitterCellBuilder

Source

pub fn new() -> Self

Create a new cell builder with default values.

Source

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

Set the number of particles spawned per second.

Source

pub fn lifetime(self, seconds: f32) -> Self

Set how long each particle lives (in seconds).

Source

pub fn lifetime_range(self, range: f32) -> Self

Set random variation in lifetime (+/- seconds).

Source

pub fn velocity(self, v: f64) -> Self

Set initial velocity (points per second).

Source

pub fn velocity_range(self, range: f64) -> Self

Set random variation in velocity.

Source

pub fn emission_longitude(self, radians: f64) -> Self

Set the direction of emission (radians, 0 = right, PI/2 = up).

Source

pub fn emission_toward(self, from: (f64, f64), target: (f64, f64)) -> Self

Set emission direction to point toward a target position.

The from parameter is the emitter position.

Source

pub fn emission_range(self, radians: f64) -> Self

Set the spread of emission (radians).

Use PI * 2.0 for emission in all directions (360°). Use PI / 6.0 for a 30° spread.

Source

pub fn scale(self, s: f64) -> Self

Set the scale of particles (1.0 = original size).

Source

pub fn scale_range(self, range: f64) -> Self

Set random variation in scale.

Source

pub fn scale_speed(self, speed: f64) -> Self

Set rate of scale change per second.

Source

pub fn alpha_speed(self, speed: f32) -> Self

Set rate of alpha change per second (negative = fade out).

Source

pub fn spin(self, radians_per_sec: f64) -> Self

Set rotation speed (radians per second).

Source

pub fn spin_range(self, range: f64) -> Self

Set random variation in spin.

Source

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

Set acceleration (points per second squared).

Use negative y for gravity effect.

Source

pub fn color(self, color: impl Into<Color>) -> Self

Set particle color using a Color value.

§Example
.color(Color::RED)
.color(Color::rgb(0.3, 0.8, 1.0))
.color(Color::WHITE.with_alpha(0.5))
Source

pub fn color_rgb(self, r: f64, g: f64, b: f64) -> Self

Set particle color (RGB, 0.0-1.0).

Source

pub fn color_rgba(self, r: f64, g: f64, b: f64, a: f64) -> Self

Set particle color (RGBA, 0.0-1.0).

Source

pub fn image(self, img: ParticleImage) -> Self

Set the particle image.

Source

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

Build the CAEmitterCell.

Trait Implementations§

Source§

impl Default for CAEmitterCellBuilder

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,