Skip to main content

SeedScheme

Struct SeedScheme 

Source
pub struct SeedScheme {
    pub seed: u32,
    pub variant: Variant,
    pub dark: bool,
    pub contrast: f64,
    pub spec: SpecVersion,
}
Expand description

What a generated theme is made from.

use gpui_kit_material_color::dynamic::{SeedScheme, Variant};
use gpui_kit_material_color::{Color, ColorRole};

let scheme = SeedScheme::new(0x6750a4).variant(Variant::TonalSpot).scheme();
assert_eq!(scheme.get(ColorRole::PRIMARY), Color::hex(0x65558f));
assert!(!scheme.is_dark());

Fields§

§seed: u32

The seed as 0xRRGGBB.

§variant: Variant

The style.

§dark: bool

Dark mode.

§contrast: f64

-1 is minimum contrast, 0 standard, 0.5 medium, 1 high.

§spec: SpecVersion

The color spec. Variants without a 2025 spec resolve as 2021.

Implementations§

Source§

impl SeedScheme

Source

pub const fn new(seed: u32) -> Self

A light tonal-spot scheme at standard contrast on the 2021 spec.

Source

pub const fn variant(self, variant: Variant) -> Self

Set the style.

Source

pub const fn dark(self, dark: bool) -> Self

Set the mode.

Source

pub const fn contrast(self, contrast: f64) -> Self

Set the contrast level, from -1 to 1.

Source

pub const fn spec(self, spec: SpecVersion) -> Self

Set the color spec.

Source

pub fn parse_hex(text: &str) -> Option<u32>

Parse #RRGGBB, RRGGBB, #RGB or RGB.

Source

pub fn dynamic(&self) -> DynamicScheme

The resolved palettes and roles.

Source

pub fn scheme(&self) -> Scheme

Every ColorRole of the generated theme.

Trait Implementations§

Source§

impl Clone for SeedScheme

Source§

fn clone(&self) -> SeedScheme

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

impl Copy for SeedScheme

Source§

impl Debug for SeedScheme

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SeedScheme

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SeedScheme

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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