pub struct Shadow {
pub offset: (f32, f32),
pub blur: f32,
pub spread: f32,
pub color: Color,
}Expand description
Shadow configuration for shapes
Fields§
§offset: (f32, f32)Shadow offset in logical pixels (x, y)
blur: f32Blur radius in logical pixels
spread: f32Spread amount in logical pixels (expands shadow)
color: ColorShadow color
Implementations§
Source§impl Shadow
impl Shadow
Sourcepub fn extent(&self) -> f32
pub fn extent(&self) -> f32
How far this shadow reaches past the box that casts it.
The amount the damage rect has to grow by, so repainting the box also
re-composites the shadow instead of leaving the old one behind:
signed_extent floored at zero, since a shadow
pulled inside its box reaches nothing past it.
Sourcepub fn scaled(self, k: f32) -> Self
pub fn scaled(self, k: f32) -> Self
The same shadow, every length multiplied by k.
The colour does not scale — a shadow made smaller should be smaller, not
fainter — and neither does the alpha extent gates on, so
scaled(k).extent() == extent() * k for any k >= 0. That identity is
what shrunk_to rests on, and it is why the two live
beside extent rather than beside either caller: add a
constant term to extent and both stop holding, here, where it is
tested.
Two callers, one rule: the HiDPI pass multiplies a shadow by the surface scale before it reaches the instance buffer, and a container shrinks one to fit the damage rect its layout reserved.
Sourcepub fn shrunk_to(self, reach: f32) -> Self
pub fn shrunk_to(self, reach: f32) -> Self
This shadow, shrunk until it reaches no further than reach past its
box.
Uniform, so the shape survives rather than the shadow collapsing along
one axis. A shadow already inside the rect is returned untouched, and so
is one whose extent is not a positive number — which is what answers a
NaN field, since every comparison against it is false. A reach below
zero counts as zero, so the factor is never above one or below zero.
Trait Implementations§
Source§impl Animatable for Shadow
impl Animatable for Shadow
Source§fn is_reverse(from: &Self, to: &Self) -> bool
fn is_reverse(from: &Self, to: &Self) -> bool
Shrinking, and then fading at a constant size.
Shadow::signed_extent is the same reduction the
damage rect is sized by, so “reverse” here means the same thing it means
to everything downstream: the shadow is giving ground back. Alpha breaks
the tie because the extent reports the full reach at any alpha above zero,
so a shadow fading out at a constant geometry would otherwise read as
forward in both directions.
The ties this keeps are the ones that trade one dimension for another — a blur of 4 becoming a spread of 8, an offset moving from down to sideways. Both reduce to the same extent, and neither is larger.
Showing comes before size: a transparent shadow measures zero, which is above every shadow pulled inside its box, so by extent alone fading one of those out would read as growing.
impl Copy for Shadow
impl StructuralPartialEq for Shadow
Auto Trait Implementations§
impl Freeze for Shadow
impl RefUnwindSafe for Shadow
impl Send for Shadow
impl Sync for Shadow
impl Unpin for Shadow
impl UnsafeUnpin for Shadow
impl UnwindSafe for Shadow
Blanket Implementations§
Source§impl<T, M, S> Animate<T, M> for Swhere
T: Clone + 'static,
S: IntoSignal<T, M>,
impl<T, M, S> Animate<T, M> for Swhere
T: Clone + 'static,
S: IntoSignal<T, M>,
Source§fn transition(self, transition: impl Into<TransitionConfig>) -> Animated<T>
fn transition(self, transition: impl Into<TransitionConfig>) -> Animated<T>
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.