pub struct LightningSettings {
pub open: bool,
pub active: bool,
pub color: Color32,
pub bolt_count: usize,
pub branch_depth: u32,
pub thickness: f32,
pub jitter: f32,
pub flash_intensity: f32,
pub duration_ms: f32,
pub ambient_interval_secs: f32,
pub layer: ParticleLayer,
}Expand description
User-facing knobs for Lightning.
The defaults are a cold white-blue bolt with one trunk, a shallow branch, moderate jitter, a moderate full-area flash and a ~420 ms strike. The ambient scheduler is off, so the effect is idle until the host strikes it.
Fields§
§open: boolSettings-window visibility. Default false (the example opens it).
active: boolWhether the effect is drawn at all.
color: Color32Bolt and flash color.
bolt_count: usizeNumber of bolts drawn per strike.
branch_depth: u32Branch recursion depth (0 draws the trunk only).
thickness: f32Bright core stroke thickness in pixels.
jitter: f32Midpoint-displacement jitter as a fraction of segment length.
flash_intensity: f32Peak alpha of the full-area flash in 0.0..=1.0.
duration_ms: f32Strike duration in milliseconds.
ambient_interval_secs: f32Ambient interval in seconds (0.0 disables the scheduler).
layer: ParticleLayerLayer the effect is painted on.
Implementations§
Source§impl LightningSettings
impl LightningSettings
Sourcepub const STRIKE_ID: &'static str = "lightning"
pub const STRIKE_ID: &'static str = "lightning"
id_source the settings window’s “Strike now” button queues a strike on.
Construct the effect with this id
(Lightning::from_settings(LightningSettings::STRIKE_ID, &settings)) so
the button drives it instead of a second, invisible state.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Knobs back to defaults; open is preserved (a reset must not close the window).
Sourcepub fn show_window(&mut self, ctx: &Context) -> Option<Response>
pub fn show_window(&mut self, ctx: &Context) -> Option<Response>
Themed floating settings window; returns the window’s outer Response when open.
Window chrome plus a vertical scroll area around Self::body_ui, so a
viewport shorter than the controls scrolls instead of clipping them.
Sourcepub fn body_ui(&mut self, ui: &mut Ui)
pub fn body_ui(&mut self, ui: &mut Ui)
Draw the settings controls into ui — no window chrome.
Render them in your own container (egui::Window, SidePanel, ScrollArea, …)
instead of using Self::show_window. If that container can be shorter than the
controls, wrap it in an egui::ScrollArea.
Trait Implementations§
Source§impl Clone for LightningSettings
impl Clone for LightningSettings
Source§impl Debug for LightningSettings
impl Debug for LightningSettings
Source§impl Default for LightningSettings
impl Default for LightningSettings
Source§impl PartialEq for LightningSettings
impl PartialEq for LightningSettings
impl StructuralPartialEq for LightningSettings
Auto Trait Implementations§
impl Freeze for LightningSettings
impl RefUnwindSafe for LightningSettings
impl Send for LightningSettings
impl Sync for LightningSettings
impl Unpin for LightningSettings
impl UnsafeUnpin for LightningSettings
impl UnwindSafe for LightningSettings
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more