Skip to main content

Colors

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: Palette

The palette these colours were made from.

§emphasis: Emphasis

How primary actions, selection and “on” states show.

§you: PresenceHue

The local person’s own colour.

§neutral: ColorRamp§semantic: SemanticColors§surfaces: Surfaces§intent: Intents§presence: PresencePalette§media: MediaColors

Ink, 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

pub fn as_authored( palette: &Palette, emphasis: Emphasis, presence: Tone, you: PresenceHue, ) -> 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

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

A palette with its stock presence tone, inverted emphasis and the default person’s colour.

pub fn dark() -> Colors

The default dark palette.

pub fn light() -> Colors

The light palette.

pub fn high_contrast() -> Colors

The dark high-contrast palette.

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)

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)

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>

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

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>

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>

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

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

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

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>

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>

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

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>

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>

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>

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

Whether this material’s surfaces lift by getting brighter.

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>

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>

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>)

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 Clone for Colors

§

fn clone(&self) -> Colors

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Colors

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for Colors

§

fn eq(&self, other: &Colors) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl StructuralPartialEq for Colors

Auto Trait Implementations§

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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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

§

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

§

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

§

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,