Skip to main content

Program

Trait Program 

Source
pub trait Program {
    // Required method
    fn fragment(&self, x: f32, y: f32) -> (Vec3, f32);

    // Provided methods
    fn advance(&mut self, now: Duration, width: f32, height: f32) { ... }
    fn particles(&self, emit: &mut dyn FnMut(f32, f32, Vec3, f32)) { ... }
}
Expand description

A fullscreen effect: per-frame state plus a shader for every pixel.

fragment returns a unit-range color and a coverage alpha. Coverage decides whether a pixel lights; color, scaled by coverage, is composited over black. particles splats point sprites over the shaded field — the CPU stand-in for an instanced sprite pass. Any Fn(f32, f32) -> (Vec3, f32) closure is a still, particle-free program.

Required Methods§

Source

fn fragment(&self, x: f32, y: f32) -> (Vec3, f32)

Shades the pixel centered at (x, y): (color, coverage), both in unit range.

Provided Methods§

Source

fn advance(&mut self, now: Duration, width: f32, height: f32)

Advances animation state to now for a width × height pixel target. Runs once per frame before any sampling.

Source

fn particles(&self, emit: &mut dyn FnMut(f32, f32, Vec3, f32))

Emits point sprites as emit(x, y, color, alpha); each blends over the shaded field at its nearest pixel. Off-target sprites are ignored.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Program for Eclipse

Source§

impl<F: Fn(f32, f32) -> (Vec3, f32)> Program for F