pub struct AnalyticalLight<T = Light> { /* private fields */ }
Expand description
A bundle of lighting resources representing one analytical light in a scene.
Create an AnalyticalLight
with:
Lights may be added and removed from rendering with Stage::add_light
and
Stage::remove_light
.
The GPU resources a light uses will not be released until Stage::remove_light
is called and the light is dropped.
Implementations§
Source§impl AnalyticalLight<DirectionalLight>
A DirectionalLight
comes wrapped in AnalyticalLight
, giving the
AnalyticalLight
the ability to simulate sunlight or other lights that
are “infinitely” far away.
impl AnalyticalLight<DirectionalLight>
A DirectionalLight
comes wrapped in AnalyticalLight
, giving the
AnalyticalLight
the ability to simulate sunlight or other lights that
are “infinitely” far away.
Sourcepub fn set_direction(&self, direction: Vec3) -> &Self
pub fn set_direction(&self, direction: Vec3) -> &Self
Set the direction of the directional light.
Sourcepub fn with_direction(self, direction: Vec3) -> Self
pub fn with_direction(self, direction: Vec3) -> Self
Set the direction and return the directional light.
Sourcepub fn modify_direction<T: 'static>(&self, f: impl FnOnce(&mut Vec3) -> T) -> T
pub fn modify_direction<T: 'static>(&self, f: impl FnOnce(&mut Vec3) -> T) -> T
Modify the direction of the directional light.
Sourcepub fn with_color(self, color: Vec4) -> Self
pub fn with_color(self, color: Vec4) -> Self
Set the color and return the directional light.
Sourcepub fn modify_color<T: 'static>(&self, f: impl FnOnce(&mut Vec4) -> T) -> T
pub fn modify_color<T: 'static>(&self, f: impl FnOnce(&mut Vec4) -> T) -> T
Modify the color of the directional light.
Sourcepub fn set_intensity(&self, intensity: Lux) -> &Self
pub fn set_intensity(&self, intensity: Lux) -> &Self
Set the intensity of the directional light.
Sourcepub fn with_intensity(self, intensity: Lux) -> Self
pub fn with_intensity(self, intensity: Lux) -> Self
Set the intensity and return the directional light.
Sourcepub fn modify_intensity<T: 'static>(&self, f: impl FnOnce(&mut Lux) -> T) -> T
pub fn modify_intensity<T: 'static>(&self, f: impl FnOnce(&mut Lux) -> T) -> T
Modify the intensity of the directional light.
Source§impl AnalyticalLight<PointLight>
A PointLight
comes wrapped in AnalyticalLight
, giving the
AnalyticalLight
the ability to simulate lights that
emit from a single point in space and attenuate exponentially with
distance.
impl AnalyticalLight<PointLight>
A PointLight
comes wrapped in AnalyticalLight
, giving the
AnalyticalLight
the ability to simulate lights that
emit from a single point in space and attenuate exponentially with
distance.
Sourcepub fn set_position(&self, position: Vec3) -> &Self
pub fn set_position(&self, position: Vec3) -> &Self
Set the position of the point light.
Sourcepub fn with_position(self, position: Vec3) -> Self
pub fn with_position(self, position: Vec3) -> Self
Set the position and return the point light.
Sourcepub fn modify_position<T: 'static>(&self, f: impl FnOnce(&mut Vec3) -> T) -> T
pub fn modify_position<T: 'static>(&self, f: impl FnOnce(&mut Vec3) -> T) -> T
Modify the position of the point light.
Sourcepub fn with_color(self, color: Vec4) -> Self
pub fn with_color(self, color: Vec4) -> Self
Set the color and return the point light.
Sourcepub fn modify_color<T: 'static>(&self, f: impl FnOnce(&mut Vec4) -> T) -> T
pub fn modify_color<T: 'static>(&self, f: impl FnOnce(&mut Vec4) -> T) -> T
Modify the color of the point light.
Sourcepub fn set_intensity(&self, intensity: Candela) -> &Self
pub fn set_intensity(&self, intensity: Candela) -> &Self
Set the intensity of the point light.
Sourcepub fn with_intensity(self, intensity: Candela) -> Self
pub fn with_intensity(self, intensity: Candela) -> Self
Set the intensity and return the point light.
Sourcepub fn modify_intensity<T: 'static>(
&self,
f: impl FnOnce(&mut Candela) -> T,
) -> T
pub fn modify_intensity<T: 'static>( &self, f: impl FnOnce(&mut Candela) -> T, ) -> T
Modify the intensity of the point light.
Source§impl AnalyticalLight<SpotLight>
A SpotLight
comes wrapped in AnalyticalLight
, giving the
AnalyticalLight
the ability to simulate lights that
emit from a single point in space in a specific direction, with
a specific spread.
impl AnalyticalLight<SpotLight>
A SpotLight
comes wrapped in AnalyticalLight
, giving the
AnalyticalLight
the ability to simulate lights that
emit from a single point in space in a specific direction, with
a specific spread.
Sourcepub fn set_position(&self, position: Vec3) -> &Self
pub fn set_position(&self, position: Vec3) -> &Self
Set the position of the spot light.
Sourcepub fn with_position(self, position: Vec3) -> Self
pub fn with_position(self, position: Vec3) -> Self
Set the position and return the spot light.
Sourcepub fn modify_position<T: 'static>(&self, f: impl FnOnce(&mut Vec3) -> T) -> T
pub fn modify_position<T: 'static>(&self, f: impl FnOnce(&mut Vec3) -> T) -> T
Modify the position of the spot light.
Sourcepub fn set_direction(&self, direction: Vec3) -> &Self
pub fn set_direction(&self, direction: Vec3) -> &Self
Set the direction of the spot light.
Sourcepub fn with_direction(self, direction: Vec3) -> Self
pub fn with_direction(self, direction: Vec3) -> Self
Set the direction and return the spot light.
Sourcepub fn modify_direction<T: 'static>(&self, f: impl FnOnce(&mut Vec3) -> T) -> T
pub fn modify_direction<T: 'static>(&self, f: impl FnOnce(&mut Vec3) -> T) -> T
Modify the direction of the spot light.
Sourcepub fn set_inner_cutoff(&self, inner_cutoff: f32) -> &Self
pub fn set_inner_cutoff(&self, inner_cutoff: f32) -> &Self
Set the inner cutoff of the spot light.
Sourcepub fn with_inner_cutoff(self, inner_cutoff: f32) -> Self
pub fn with_inner_cutoff(self, inner_cutoff: f32) -> Self
Set the inner cutoff and return the spot light.
Sourcepub fn modify_inner_cutoff<T: 'static>(
&self,
f: impl FnOnce(&mut f32) -> T,
) -> T
pub fn modify_inner_cutoff<T: 'static>( &self, f: impl FnOnce(&mut f32) -> T, ) -> T
Modify the inner cutoff of the spot light.
Sourcepub fn inner_cutoff(&self) -> f32
pub fn inner_cutoff(&self) -> f32
Get the inner cutoff of the spot light.
Sourcepub fn set_outer_cutoff(&self, outer_cutoff: f32) -> &Self
pub fn set_outer_cutoff(&self, outer_cutoff: f32) -> &Self
Set the outer cutoff of the spot light.
Sourcepub fn with_outer_cutoff(self, outer_cutoff: f32) -> Self
pub fn with_outer_cutoff(self, outer_cutoff: f32) -> Self
Set the outer cutoff and return the spot light.
Sourcepub fn modify_outer_cutoff<T: 'static>(
&self,
f: impl FnOnce(&mut f32) -> T,
) -> T
pub fn modify_outer_cutoff<T: 'static>( &self, f: impl FnOnce(&mut f32) -> T, ) -> T
Modify the outer cutoff of the spot light.
Sourcepub fn outer_cutoff(&self) -> f32
pub fn outer_cutoff(&self) -> f32
Get the outer cutoff of the spot light.
Sourcepub fn with_color(self, color: Vec4) -> Self
pub fn with_color(self, color: Vec4) -> Self
Set the color and return the spot light.
Sourcepub fn modify_color<T: 'static>(&self, f: impl FnOnce(&mut Vec4) -> T) -> T
pub fn modify_color<T: 'static>(&self, f: impl FnOnce(&mut Vec4) -> T) -> T
Modify the color of the spot light.
Sourcepub fn set_intensity(&self, intensity: Candela) -> &Self
pub fn set_intensity(&self, intensity: Candela) -> &Self
Set the intensity of the spot light.
Sourcepub fn with_intensity(self, intensity: Candela) -> Self
pub fn with_intensity(self, intensity: Candela) -> Self
Set the intensity and return the spot light.
Sourcepub fn modify_intensity<T: 'static>(
&self,
f: impl FnOnce(&mut Candela) -> T,
) -> T
pub fn modify_intensity<T: 'static>( &self, f: impl FnOnce(&mut Candela) -> T, ) -> T
Modify the intensity of the spot light.
Source§impl AnalyticalLight
impl AnalyticalLight
Sourcepub fn as_directional(&self) -> Option<&DirectionalLight>
pub fn as_directional(&self) -> Option<&DirectionalLight>
Returns a reference to the inner DirectionalLight
, if this light is directional.
Sourcepub fn as_point(&self) -> Option<&PointLight>
pub fn as_point(&self) -> Option<&PointLight>
Returns a reference to the inner PointLight
, if this light is a point light.
Source§impl<T: IsLight> AnalyticalLight<T>
impl<T: IsLight> AnalyticalLight<T>
Sourcepub fn id(&self) -> Id<LightDescriptor>
pub fn id(&self) -> Id<LightDescriptor>
Returns a pointer to this light on the GPU
Sourcepub fn descriptor(&self) -> LightDescriptor
pub fn descriptor(&self) -> LightDescriptor
Returns a copy of the descriptor on the GPU.
Sourcepub fn link_node_transform(&self, transform: &NestedTransform)
pub fn link_node_transform(&self, transform: &NestedTransform)
Link this light to a node’s NestedTransform
.
Sourcepub fn transform(&self) -> &Transform
pub fn transform(&self) -> &Transform
Get a reference to the light’s global transform.
This value lives in the lighting slab.
§Note
If a NestedTransform
has been linked to this light by using Self::link_node_transform
,
the transform returned by this function may be overwritten at any point by the given
NestedTransform
.
Sourcepub fn linked_node_transform(&self) -> Option<NestedTransform>
pub fn linked_node_transform(&self) -> Option<NestedTransform>
Get a reference to the light’s linked global node transform.
§Note
The returned transform, if any, is the global transform of a linked NestedTransform
.
To change this value, you should do so through the NestedTransform
, which is likely
held in the
Sourcepub fn into_generic(self) -> AnalyticalLight
pub fn into_generic(self) -> AnalyticalLight
Convert this light into a generic light, hiding the specific light type that it is.
This is useful if you want to store your lights together.
Trait Implementations§
Source§impl<T: Clone> Clone for AnalyticalLight<T>
impl<T: Clone> Clone for AnalyticalLight<T>
Source§fn clone(&self) -> AnalyticalLight<T>
fn clone(&self) -> AnalyticalLight<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T: IsLight> Display for AnalyticalLight<T>
impl<T: IsLight> Display for AnalyticalLight<T>
Source§impl<T: IsLight> IsLight for AnalyticalLight<T>
impl<T: IsLight> IsLight for AnalyticalLight<T>
Source§fn style(&self) -> LightStyle
fn style(&self) -> LightStyle
fn light_space_transforms( &self, parent_transform: &TransformDescriptor, z_near: f32, z_far: f32, ) -> Vec<Mat4>
Auto Trait Implementations§
impl<T> Freeze for AnalyticalLight<T>where
T: Freeze,
impl<T> RefUnwindSafe for AnalyticalLight<T>where
T: RefUnwindSafe,
impl<T> Send for AnalyticalLight<T>where
T: Send,
impl<T> Sync for AnalyticalLight<T>where
T: Sync,
impl<T> Unpin for AnalyticalLight<T>where
T: Unpin,
impl<T> UnwindSafe for AnalyticalLight<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute
] value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
[Quirk
] value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition
] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);