Crate core_animation

Crate core_animation 

Source
Expand description

Rust bindings for macOS Core Animation with builder APIs.

Core Animation is Apple’s GPU-accelerated rendering system. This crate wraps it with ergonomic builders, focusing on particle effects and layer composition.

§Quick Start

Particles burst outward from a point:

use std::f64::consts::PI;
use core_animation::prelude::*;

let emitter = CAEmitterLayerBuilder::new()
    .position(320.0, 240.0)
    .shape(EmitterShape::Point)
    .particle(|p| {
        p.birth_rate(100.0)           // spawn rate
            .lifetime(5.0)            // seconds until particle disappears
            .velocity(80.0)           // movement speed
            .emission_range(PI * 2.0) // spread angle (full circle)
            .color(Color::CYAN)
            .image(ParticleImage::soft_glow(64))
    })
    .build();

window.container().add_sublayer(&emitter);
window.show_for(10.seconds());

Simpler API for the same effect:

let burst = PointBurstBuilder::new(320.0, 240.0)
    .velocity(100.0)
    .color(Color::PINK)
    .build();

§Examples

See examples/README.md for runnable demos with screenshots.

cargo run --example emitter

§Modules

§Types

This crate:

  • [Color] - RGBA color with presets (Color::CYAN, Color::rgb(...))
  • [CALayerBuilder] - Generic layer builder
  • [CAShapeLayerBuilder] - Vector shape builder
  • [CATextLayerBuilder] - Text rendering builder with fonts and alignment
  • [DurationExt] - 5.seconds(), 500.millis() syntax

Re-exported from Apple frameworks:

Use [prelude] to import common types.