Skip to main content

ThemePalette

Struct ThemePalette 

Source
pub struct ThemePalette { /* private fields */ }
Expand description

A set of 8 anchor colors that define a theme-relative color space.

The 8 anchors map to the standard ANSI color positions:

IndexColorCube corner
0black(0, 0, 0)
1red(1, 0, 0)
2green(0, 1, 0)
3yellow(1, 1, 0)
4blue(0, 0, 1)
5magenta(1, 0, 1)
6cyan(0, 1, 1)
7white(1, 1, 1)

Optional background/foreground overrides let the bg/fg differ from the theme’s black/white (e.g., Solarized where bg is a dark teal, not black).

Implementations§

Source§

impl ThemePalette

Source

pub fn default_xterm() -> Self

Creates a palette using the standard xterm base16 colors.

This is the default when no explicit theme palette is configured.

Source

pub fn new(anchors: [Rgb; 8]) -> Self

Creates a new palette from the 8 base ANSI colors.

The array order must be: black, red, green, yellow, blue, magenta, cyan, white. Background defaults to anchors[0] (black) and foreground to anchors[7] (white).

Source

pub fn with_bg(self, bg: Rgb) -> Self

Overrides the background color used for the (0,0,0) cube corner.

Useful for themes where the terminal background differs from ANSI black (e.g., Solarized Dark uses #002b36).

Source

pub fn with_fg(self, fg: Rgb) -> Self

Overrides the foreground color used for the (1,1,1) cube corner.

Useful for themes where the terminal foreground differs from ANSI white (e.g., Solarized Dark uses #fdf6e3).

Source

pub fn resolve(&self, coord: &CubeCoord) -> Rgb

Resolves a CubeCoord to an actual RGB color via trilinear LAB interpolation.

This is the core operation: given a position in the theme cube, compute the perceptually interpolated color between the 8 anchor corners.

Source

pub fn generate_palette(&self, subdivisions: u8) -> Vec<Rgb>

Generates the extended color palette by subdividing the theme cube.

Returns a Vec<Rgb> containing:

  • subdivisions³ colors from the cube (e.g., 216 for subdivisions=6)
  • 24 grayscale colors interpolated from background to foreground

The total is subdivisions³ + 24 colors. For subdivisions=6, this gives the 240 extended colors that fill indices 16–255 of a 256-color palette.

Trait Implementations§

Source§

impl Clone for ThemePalette

Source§

fn clone(&self) -> ThemePalette

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ThemePalette

Source§

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

Formats the value using the given formatter. Read more

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> Instrument for T

Source§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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