pub struct SpriteTint {
pub mask: Tint,
pub tint: Tint,
}Expand description
The complete recolouring one sprite goes through in one cell: the sheet’s own treatment, then the cell’s tint.
Two stages rather than one because they do not always fold together. A SheetColor::Mask
sheet is a multiply by the cell’s foreground, and a multiply composes with another multiply,
but not with a Tint::Mix: “colour this mask red, then flash it half-way to white” is two
operations and cannot be written as one.
Both pixel backends resolve through here, so a sprite recoloured on the software rasteriser
and the same sprite recoloured in the GL fragment shader cannot disagree. The GL side uploads
the two stages as instance attributes and mirrors apply’s order.
Fields§
§mask: TintThe sheet’s own treatment, applied first.
Tint::Multiply by the cell’s resolved foreground colour for a SheetColor::Mask
sheet, Tint::None for SheetColor::Art.
tint: TintThe cell’s own tint, applied second.
Implementations§
Source§impl SpriteTint
impl SpriteTint
Sourcepub const fn resolve(
sheet: SheetColor,
fg: Color,
tint: Tint,
default_fg: (u8, u8, u8),
) -> Self
pub const fn resolve( sheet: SheetColor, fg: Color, tint: Tint, default_fg: (u8, u8, u8), ) -> Self
Resolves what a sprite from a sheet-coloured tileset should look like in a cell with
foreground fg and tint tint.
Takes the sheet’s declaration rather than the Sprite itself, because that is all the
answer depends on: the GPU backend resolves against an atlas slot and never holds the
pixels at draw time.
default_fg is the palette fallback for Color::Default, which has no reading as a
modulation value on its own (see Tint); palette::DEFAULT_FG is
what both backends pass.
Sourcepub const fn is_identity(&self) -> bool
pub const fn is_identity(&self) -> bool
Whether this leaves every pixel exactly as authored, so a renderer can take its untinted path.
Trait Implementations§
Source§impl Clone for SpriteTint
impl Clone for SpriteTint
Source§fn clone(&self) -> SpriteTint
fn clone(&self) -> SpriteTint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SpriteTint
impl Debug for SpriteTint
Source§impl Default for SpriteTint
impl Default for SpriteTint
Source§fn default() -> SpriteTint
fn default() -> SpriteTint
Source§impl PartialEq for SpriteTint
impl PartialEq for SpriteTint
Source§fn eq(&self, other: &SpriteTint) -> bool
fn eq(&self, other: &SpriteTint) -> bool
self and other values to be equal, and is used by ==.impl Copy for SpriteTint
impl Eq for SpriteTint
impl StructuralPartialEq for SpriteTint
Auto Trait Implementations§
impl Freeze for SpriteTint
impl RefUnwindSafe for SpriteTint
impl Send for SpriteTint
impl Sync for SpriteTint
impl Unpin for SpriteTint
impl UnsafeUnpin for SpriteTint
impl UnwindSafe for SpriteTint
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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>
§impl<C> WithAlpha for Cwhere
C: Copy,
impl<C> WithAlpha for Cwhere
C: Copy,
§fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
self with alpha, storing alpha before the color in memory
(see [AlphaFirst]).§fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
self with alpha, storing alpha after the color in memory
(see [AlphaLast]).