Skip to main content

motion_content/
options.rs

1//! Plain content policies available without optional text or particle preparation.
2
3/// Paragraph alignment, with start/end resolved by the paragraph direction.
4#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
7#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
8pub enum TextAlignment {
9    /// Follow paragraph start.
10    #[default]
11    Start,
12    /// Follow paragraph end.
13    End,
14    /// Center each line within the requested width.
15    Center,
16    /// Justify nonfinal lines.
17    Justified,
18}
19
20/// Units used for visibility and per-part animation.
21#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
22#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
23#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
24#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
25pub enum TextSplit {
26    /// Extended Unicode grapheme clusters, not scalar chars.
27    #[default]
28    Characters,
29    /// Unicode words, with separators attached to the preceding word.
30    Words,
31    /// Wrapped visual lines.
32    Lines,
33}
34
35/// Curated, independently configurable particle recipes.
36#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
37#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
38#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
39#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
40pub enum Preset {
41    /// Tapered HDR ballistic burst.
42    Sparks,
43    /// Cooling, upward-moving glowing embers.
44    Embers,
45    /// Slow depth-aware dust.
46    Dust,
47    /// Soft floating motes.
48    Motes,
49    /// Three parallax depth layers of wind-driven snow.
50    Snow,
51    /// Stretched rain with collision-triggered splashes.
52    Rain,
53    /// Expanding procedural smoke sprites.
54    Smoke,
55    /// Buoyant procedural fire cores.
56    Fire,
57    /// Flipping, colored falling quads.
58    Confetti,
59    /// Rocket death, spark burst, then secondary spark deaths.
60    Fireworks,
61    /// Drifting and breathing light points.
62    Fireflies,
63    /// Color-preserving vector surface dispersal.
64    LogoDissolve,
65    /// Color-preserving vector surface convergence.
66    LogoAssemble,
67}
68
69/// Scalar coordinate used by a particle color field.
70#[derive(Clone, Copy, Debug, PartialEq)]
71#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
72#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
73#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
74pub enum FieldCoordinate {
75    /// Horizontal position.
76    X,
77    /// Vertical position.
78    Y,
79    /// Velocity magnitude.
80    Speed,
81}
82
83/// Bounded normal restitution and tangential friction.
84#[derive(Clone, Copy, Debug, PartialEq)]
85#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
86#[cfg_attr(feature = "serde", serde(deny_unknown_fields))]
87#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
88pub struct CollisionResponse {
89    /// Normal velocity restitution in 0..=1.
90    pub restitution: f32,
91    /// Fraction of tangential velocity removed in 0..=1.
92    pub friction: f32,
93    /// Remove the particle at its first contact.
94    pub kill_on_hit: bool,
95}
96
97impl Default for CollisionResponse {
98    fn default() -> Self {
99        Self {
100            restitution: 1.0,
101            friction: 0.0,
102            kill_on_hit: false,
103        }
104    }
105}
106
107/// Fixed-boundary particle event.
108#[derive(Clone, Copy, Debug, PartialEq)]
109#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
110#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
111#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
112pub enum ParticleEventKind {
113    /// First admission of a live particle.
114    Birth,
115    /// Half-open lifetime expiry, including kill-on-hit.
116    Death,
117    /// Geometric or population contact.
118    Collision,
119    /// Age threshold in seconds, reported at its first simulation boundary.
120    AgeReached(f32),
121}
122
123/// Parent properties added to an emitter's local child record.
124#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
125#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
126#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
127#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
128pub enum Inherit {
129    /// Keep emitter-authored values.
130    None,
131    /// Translate local emission to the event location.
132    #[default]
133    Position,
134    /// Translate and add parent velocity.
135    Velocity,
136    /// Translate and multiply parent premultiplied color.
137    Color,
138    /// Translate, add velocity and inherit color.
139    All,
140}