Skip to main content

Light

Struct Light 

Source
pub struct Light { /* private fields */ }
Expand description

A configurable radial-glow effect for egui.

Light paints soft, flickering motes — drifting haze or rising embers — on an egui layer. It maintains its state between frames using egui’s temporary data storage and never disturbs the host layout.

All motes are appended into a single triangle mesh per frame, so stacking order is preserved and the effect costs one shape.

Implementations§

Source§

impl Light

Source

pub fn new(id_source: impl Hash + Debug) -> Self

Creates a new light effect with a unique ID.

Source

pub fn from_settings( id_source: impl Hash + Debug, settings: &LightSettings, ) -> Self

Builds a light effect from LightSettings.

Inverted ranges are normalized (swapped) so a host can never hand the spawner an empty range.

Source

pub fn color(self, color: Color32) -> Self

Sets the mote color.

Source

pub fn density(self, density: usize) -> Self

Sets the number of motes.

Source

pub fn radius(self, range: RangeInclusive<f32>) -> Self

Sets the mote radius range (min..=max) in pixels.

Source

pub fn intensity(self, intensity: f32) -> Self

Sets the global intensity multiplier in 0.0..=1.0.

Source

pub fn motion(self, motion: LightMotion) -> Self

Sets the motion model.

Source

pub fn wind(self, wind: impl Into<Vec2>) -> Self

Sets the wind vector.

Source

pub fn flicker(self, flicker: f32) -> Self

Sets the flicker depth in 0.0..=1.0 (0 disables flicker).

Source

pub fn lifetime(self, range: RangeInclusive<f32>) -> Self

Sets the mote lifetime range (min..=max) in seconds.

Source

pub fn on_top(self) -> Self

Places the light on the Debug layer (on top of everything).

Source

pub fn on_foreground(self) -> Self

Places the light on the Foreground layer.

Source

pub fn on_background(self) -> Self

Places the light on the Background layer.

Source

pub fn layer(self, layer_id: LayerId) -> Self

Provides full control over the rendering layer.

This overrides on_top, on_foreground, and on_background.

Source

pub fn area(self, area: Rect) -> Self

Restricts the light effect to a specific area.

If not set, it defaults to ctx.content_rect().

Source

pub fn show(self, ctx: &Context)

Updates and renders the light effect.

This should be called every frame. It automatically requests a repaint.

Trait Implementations§

Source§

impl Debug for Light

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Light

§

impl RefUnwindSafe for Light

§

impl Send for Light

§

impl Sync for Light

§

impl Unpin for Light

§

impl UnsafeUnpin for Light

§

impl UnwindSafe for Light

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.