Struct Colors
pub struct Colors {Show 19 fields
pub palette: Palette,
pub emphasis: Emphasis,
pub you: PresenceHue,
pub neutral: ColorRamp,
pub semantic: SemanticColors,
pub surfaces: Surfaces,
pub intent: Intents,
pub presence: PresencePalette,
pub media: MediaColors,
pub text_primary: AlphaColor<Srgb>,
pub text_dim: AlphaColor<Srgb>,
pub text_tertiary: AlphaColor<Srgb>,
pub border_standard: AlphaColor<Srgb>,
pub border_focus: AlphaColor<Srgb>,
pub overlay_subtle: AlphaColor<Srgb>,
pub overlay_medium: AlphaColor<Srgb>,
pub overlay_strong: AlphaColor<Srgb>,
pub overlay_border_subtle: AlphaColor<Srgb>,
pub overlay_border_strong: AlphaColor<Srgb>,
}Fields§
§palette: PaletteThe palette these colours were made from.
emphasis: EmphasisHow primary actions, selection and “on” states show.
you: PresenceHueThe local person’s own colour.
neutral: ColorRamp§semantic: SemanticColors§surfaces: Surfaces§intent: Intents§presence: PresencePalette§media: MediaColorsInk, scrim and letterbox for what is drawn straight onto media.
text_primary: AlphaColor<Srgb>Primary ink on Surfaces::content.
text_dim: AlphaColor<Srgb>Secondary ink on Surfaces::content.
text_tertiary: AlphaColor<Srgb>Tertiary ink: still clears large-text contrast against every surface, so it reads as “quiet”, never “broken”.
border_standard: AlphaColor<Srgb>A hairline where two equal surfaces meet. Nowhere else: groups are separated by space.
border_focus: AlphaColor<Srgb>The focus ring: always Intents::you.
overlay_subtle: AlphaColor<Srgb>The quietest veneer — a “barely there” hover wash or faint divider.
overlay_medium: AlphaColor<Srgb>The middle veneer — a settled hover, a resting chip.
overlay_strong: AlphaColor<Srgb>The strongest veneer — pressed states and emphatic fills.
overlay_border_subtle: AlphaColor<Srgb>Hairline structure that has to read against the local surface rather than against the theme ground (a divider inside a tinted panel).
overlay_border_strong: AlphaColor<Srgb>The more assertive hairline — an active tab’s outline, a focused chip.
Implementations§
§impl Colors
impl Colors
The whole colour token set for a palette, as authored: nothing is
measured or repaired. Self::of_palette is what a theme paints
with; this is what Theme Studio audits.
pub fn of_palette(
palette: &Palette,
emphasis: Emphasis,
presence: Tone,
you: PresenceHue,
) -> Colors
pub fn of_palette( palette: &Palette, emphasis: Emphasis, presence: Tone, you: PresenceHue, ) -> Colors
The colour token set a theme paints with: Self::as_authored,
with any pairing that misses a contrast floor stepped out until it
holds (crate::tokens::contrast::repair). The shipped palettes need
no repair; a hand-edited document that slipped past Theme Studio
still renders legibly.
pub fn stock(palette: &Palette) -> Colors
pub fn stock(palette: &Palette) -> Colors
A palette with its stock presence tone, inverted emphasis and the default person’s colour.
pub fn high_contrast() -> Colors
pub fn high_contrast() -> Colors
The dark high-contrast palette.
pub fn with_neutral_hue(&self, hue: f32) -> Colors
pub fn with_neutral_hue(&self, hue: f32) -> Colors
The same colours with the neutral material at temperature hue:
presence, status, emphasis and the person’s own colour keep their
hues. A palette with no chroma shows no temperature and is returned
unchanged.
pub fn set_you(&mut self, hue: PresenceHue)
pub fn set_you(&mut self, hue: PresenceHue)
Make hue the person’s colour: focus ring, caret and text-selection
tint, painted at this palette’s presence lightness and chroma.
pub fn set_material(&mut self, blur_px: f32, opacity: f32)
pub fn set_material(&mut self, blur_px: f32, opacity: f32)
The floating material: backdrop blur (logical pixels) and the opacity of the overlay tint over it. A high-contrast palette stays opaque whatever it is asked.
pub fn lift_on(&self, ground: AlphaColor<Srgb>, t: f32) -> AlphaColor<Srgb>
pub fn lift_on(&self, ground: AlphaColor<Srgb>, t: f32) -> AlphaColor<Srgb>
The selection lift on any ground: t 1.0 is one surface step
(lighter on a dark palette, darker on a light one), 0.5 the hover
halfway. Colourless under inverted emphasis; faintly the tint under
tinted emphasis.
The step goes the palette’s way unless the ground has no room for a whole step there (a white well on a dark palette, a near-black one on a light palette); then it goes the other way, so the lift always moves a full step away from the ground it stands on and stays visible.
pub fn wash_on(
&self,
ground: AlphaColor<Srgb>,
tone: Tone,
strength: WashStrength,
) -> Wash
pub fn wash_on( &self, ground: AlphaColor<Srgb>, tone: Tone, strength: WashStrength, ) -> Wash
A status wash of tone over ground: an added or removed line, a
failed row, a reviewer’s band. Selected takes the selection lift
of ground and keeps the wash’s hue on it, where
Self::lift_on alone would drop to the neutral. The inks clear
body-text contrast on the composited body, so text keeps reading
under every strength on every ground.
pub fn inverted_pressed(&self) -> AlphaColor<Srgb>
pub fn inverted_pressed(&self) -> AlphaColor<Srgb>
Intents::inverted while pressed: the hover step taken twice, so
a press reads past the hover instead of matching it.
pub fn raised_on(&self, ground: AlphaColor<Srgb>) -> AlphaColor<Srgb>
pub fn raised_on(&self, ground: AlphaColor<Srgb>) -> AlphaColor<Srgb>
What Surfaces::raised is on ground: the raised tier itself
while it stands off ground the same way it stands off the content
surface, by at least half that step (so on every region of the
window); otherwise that step taken from ground (the other way where
the ground has no room). A field, a secondary button or a checkbox on
a floating panel lighter than the raised tier stands off it as it
does off content, instead of sinking into it.
pub fn on_content(&self) -> OnSurface
pub fn on_content(&self) -> OnSurface
Ink tiers for content on Surfaces::content — the theme’s own text
tiers, since those are defined there.
pub fn on_surface(&self, surface: AlphaColor<Srgb>) -> OnSurface
pub fn on_surface(&self, surface: AlphaColor<Srgb>) -> OnSurface
Self::on_content for any surface a widget paints on. Measured
against that surface rather than darkened a fixed fraction, which
yields roughly the same ratio whatever the material.
pub fn on_surface_at(
&self,
surface: AlphaColor<Srgb>,
min_ratio: f64,
) -> OnSurface
pub fn on_surface_at( &self, surface: AlphaColor<Srgb>, min_ratio: f64, ) -> OnSurface
Self::on_surface against a caller-chosen floor. OnSurface::ink
and ink_dim step out until they clear min_ratio;
OnSurface::ink_tertiary passes through as authored — how quiet
the quietest tier is belongs to the material (held to 3:1 on every
surface by contrast::FLOORS), and forcing a body-text floor would
erase the tier.
pub fn ink_on(
&self,
ground: AlphaColor<Srgb>,
tone: AlphaColor<Srgb>,
min_ratio: f64,
) -> AlphaColor<Srgb>
pub fn ink_on( &self, ground: AlphaColor<Srgb>, tone: AlphaColor<Srgb>, min_ratio: f64, ) -> AlphaColor<Srgb>
An authored tone made legible on ground: untouched if it already
clears min_ratio, otherwise stepped toward the contrasting extreme.
pub fn ink_on_any(
&self,
grounds: &[AlphaColor<Srgb>],
tone: AlphaColor<Srgb>,
min_ratio: f64,
) -> AlphaColor<Srgb>
pub fn ink_on_any( &self, grounds: &[AlphaColor<Srgb>], tone: AlphaColor<Srgb>, min_ratio: f64, ) -> AlphaColor<Srgb>
One tone, made legible on every ground in grounds at once.
Resolving a control’s label separately per state (rest/hover/press)
lets it flip polarity mid-range, so ink is chosen once, against the
worst ground, and held for the whole set.
pub fn tinted_chip_on(
&self,
ground: AlphaColor<Srgb>,
tint: AlphaColor<Srgb>,
wash: f32,
min_ratio: f64,
) -> TintedChip
pub fn tinted_chip_on( &self, ground: AlphaColor<Srgb>, tint: AlphaColor<Srgb>, wash: f32, min_ratio: f64, ) -> TintedChip
A tint washed over ground at wash strength (a status pill, a
presence chip), resolved into an opaque body, an edge and a label.
The body composites first, so ink is measured against what the screen holds, not the token the wash was made from. Ink walks out of the tint only as far as the floor demands. The edge is measured against the ground, since its job is separating pill from row.
pub fn hairline_on(ground: AlphaColor<Srgb>, alpha: u8) -> AlphaColor<Srgb>
pub fn hairline_on(ground: AlphaColor<Srgb>, alpha: u8) -> AlphaColor<Srgb>
A hairline visible on ground whichever side of the light/dark line
it falls on. Tries both polarities at alpha, keeps whichever moves
ground further.
pub fn lift(&self, t: f32) -> AlphaColor<Srgb>
pub fn lift(&self, t: f32) -> AlphaColor<Srgb>
The body a chrome control takes when lifted off the desktop
ground (hovered tab pill, active workspace chip). t runs 0.0 (flat)
to 1.0 (full lift), interpolating surfaces.base toward
surfaces.raised. Where a material has no raised tier (high contrast
paints everything black) falls back to a wash polarity chosen the
same way Colors::hairline_on picks one. Rows inside a window lift
with Intents::selection / Self::lift_on instead.
pub fn lift_target(&self) -> AlphaColor<Srgb>
pub fn lift_target(&self) -> AlphaColor<Srgb>
The colour a lift moves toward. Named apart from Colors::lift
because it also anchors Colors::glass_film: a material and a flat
wash must agree which way is “away from the ground”.
pub fn lifts_bright(&self) -> bool
pub fn lifts_bright(&self) -> bool
Whether this material’s surfaces lift by getting brighter.
pub fn glass_film(&self) -> AlphaColor<Srgb>
pub fn glass_film(&self) -> AlphaColor<Srgb>
The colour of the film a glass selector is made of: the raised tier
carried one derived step further (GLASS_FILM_LIFT), opaque (alpha
belongs to the state painting it, not the material).
pub fn window_edge(&self) -> AlphaColor<Srgb>
pub fn window_edge(&self) -> AlphaColor<Srgb>
The hairline separating a window tile from the desktop. Painted
outside the tile’s silhouette since the shell never samples the app’s
pixels inside it. crate::widget::tile_host::TileHost owns the
matching geometry.
The declared Surfaces::content_edge is honoured wherever it
registers; only a declaration the ground would swallow gets its
polarity flipped.
pub fn readable_on(
&self,
bg: AlphaColor<Srgb>,
preferred: AlphaColor<Srgb>,
) -> AlphaColor<Srgb>
pub fn readable_on( &self, bg: AlphaColor<Srgb>, preferred: AlphaColor<Srgb>, ) -> AlphaColor<Srgb>
Pick a foreground colour that stays legible on bg.
Returns preferred whenever it already clears WCAG AA for body text
(4.5:1) against bg. Where it does not, this falls back to the
theme’s primary text, and finally to plain white or black, whichever
wins — one of the two always clears 4.5:1 against any colour.
bg must be the colour that will actually be seen: composite any
translucent fill over its ground before passing it in.
pub fn legible_fill(
&self,
fill: AlphaColor<Srgb>,
preferred_label: AlphaColor<Srgb>,
) -> (AlphaColor<Srgb>, AlphaColor<Srgb>)
pub fn legible_fill( &self, fill: AlphaColor<Srgb>, preferred_label: AlphaColor<Srgb>, ) -> (AlphaColor<Srgb>, AlphaColor<Srgb>)
Resolve a filled chip — the destructive fill inside a
confirmation step, a status badge — into a (fill, label) pair whose
label clears WCAG AA (4.5:1) against the fill.
If preferred_label already clears AA the pair is returned
untouched; otherwise the fill is deepened toward black until the
label clears, up to MAX_CHIP_DEEPEN. Past that the fill is kept
and the label re-picked via Self::readable_on.
fill must be opaque: it is what the label will actually sit on.
Trait Implementations§
impl StructuralPartialEq for Colors
Auto Trait Implementations§
impl Freeze for Colors
impl RefUnwindSafe for Colors
impl Send for Colors
impl Sync for Colors
impl Unpin for Colors
impl UnsafeUnpin for Colors
impl UnwindSafe for Colors
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for 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
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>
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