|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
particle.h — particles in a caller-owned pool: spawn from an emitter descriptor with a caller-owned generator, step with physics, paint as rects, streaks or dots. More...
#include <stddef.h>#include <stdint.h>#include "draw.h"#include "fb.h"#include "geom.h"#include "motion.h"Data Structures | |
| struct | rmgui_particle_t |
| One slot. More... | |
| struct | rmgui_particle_emitter_t |
| What one emit spawns; every range is inclusive and drawn uniformly. More... | |
| struct | rmgui_particle_physics_t |
| Forces on a pool. More... | |
Enumerations | |
| enum | rmgui_particle_shape_t { RMGUI_PARTICLE_SHAPE_RECT , RMGUI_PARTICLE_SHAPE_STREAK , RMGUI_PARTICLE_SHAPE_DOT } |
| How a particle is painted. More... | |
Functions | |
| size_t | rmgui_particle_emit (rmgui_particle_t *pool, size_t capacity, const rmgui_particle_emitter_t *emitter, rmgui_motion_rng_t *rng, size_t count) |
| Spawns up to count particles into the free slots of pool[0, capacity), lowest index first, drawing from rng in a fixed order per particle (position x, y, angle, speed, life, spin rate, w, h, colour). | |
| int | rmgui_particle_step (rmgui_particle_t *pool, size_t capacity, const rmgui_particle_physics_t *physics, uint16_t dt_ms) |
| Advances every live particle by dt_ms 1 ms substeps: velocity += gravity and -= drag share, position += velocity, spin += spin_rate, age += 1; a particle whose age reaches life_ms becomes a free (all-zero) slot. | |
| void | rmgui_particle_paint (rmgui_fb_t *fb, rmgui_rect_t clip, const rmgui_particle_t *pool, size_t capacity, rmgui_draw_mode_t mode, rmgui_motion_ease_t fade, uint16_t streak_ms) |
| Paints every live particle inside clip with mode, its colour's alpha scaled by ONE - rmgui_motion_ease(fade, age_ms, life_ms). | |
particle.h — particles in a caller-owned pool: spawn from an emitter descriptor with a caller-owned generator, step with physics, paint as rects, streaks or dots.
A pool is an array of capacity slots the caller owns; a zero slot is free. Nothing is ever written past capacity.
| size_t rmgui_particle_emit | ( | rmgui_particle_t * | pool, |
| size_t | capacity, | ||
| const rmgui_particle_emitter_t * | emitter, | ||
| rmgui_motion_rng_t * | rng, | ||
| size_t | count ) |
Spawns up to count particles into the free slots of pool[0, capacity), lowest index first, drawing from rng in a fixed order per particle (position x, y, angle, speed, life, spin rate, w, h, colour).
Returns how many it spawned: min(count, free slots). 0, changing nothing, when an argument is NULL, colors is NULL, its byte extent overflows size_t, or the emitter breaks a range above. Emitted slots copy the chosen color and never retain the borrowed palette.
| int rmgui_particle_step | ( | rmgui_particle_t * | pool, |
| size_t | capacity, | ||
| const rmgui_particle_physics_t * | physics, | ||
| uint16_t | dt_ms ) |
Advances every live particle by dt_ms 1 ms substeps: velocity += gravity and -= drag share, position += velocity, spin += spin_rate, age += 1; a particle whose age reaches life_ms becomes a free (all-zero) slot.
Velocity and position saturate at the int32 range; spin is kept in [0, 65536). Returns 1 when dt_ms > 0 and any slot was live at the start (it changed), 0 otherwise.
| void rmgui_particle_paint | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | clip, | ||
| const rmgui_particle_t * | pool, | ||
| size_t | capacity, | ||
| rmgui_draw_mode_t | mode, | ||
| rmgui_motion_ease_t | fade, | ||
| uint16_t | streak_ms ) |
Paints every live particle inside clip with mode, its colour's alpha scaled by ONE - rmgui_motion_ease(fade, age_ms, life_ms).
A STREAK runs from the position back streak_ms of travel (rmgui_draw_line's point set).