pub struct Palette(pub [RgbColor; 256]);Expand description
A 256-color palette.
Tuple Fields§
§0: [RgbColor; 256]Implementations§
Source§impl Palette
impl Palette
Sourcepub fn get(&self, index: PaletteIndex) -> RgbColor
pub fn get(&self, index: PaletteIndex) -> RgbColor
Get the color at the given palette index.
Sourcepub fn set(&mut self, index: PaletteIndex, color: RgbColor)
pub fn set(&mut self, index: PaletteIndex, color: RgbColor)
Set the color at the given palette index.
Sourcepub fn parse_palette_entry(value: &str) -> Result<(PaletteIndex, RgbColor)>
pub fn parse_palette_entry(value: &str) -> Result<(PaletteIndex, RgbColor)>
Parse a Ghostty palette entry.
Accepts Ghostty palette config syntax: N=COLOR. N is a palette index
from 0 to 255 in decimal or in 0x, 0o, or 0b-prefixed form. Spaces and
tabs around N and COLOR are ignored. COLOR accepts the same syntax as
RgbColor::parse.
Sourcepub fn generate(
base: Option<&Self>,
skip: Option<&PaletteMask>,
background: RgbColor,
foreground: RgbColor,
harmonious: bool,
) -> Self
pub fn generate( base: Option<&Self>, skip: Option<&PaletteMask>, background: RgbColor, foreground: RgbColor, harmonious: bool, ) -> Self
Generate a 256-color palette from base colors.
The base palette supplies indices 0-15, which are always preserved. If
base is None, Ghostty’s default palette is used. If skip is
None, no extra indices are skipped. Set bits in skip preserve those
indices from base. The 216-color cube at indices 16-231 is generated with
trilinear CIELAB interpolation, and the grayscale ramp at indices 232-255 is
interpolated from the background to the foreground.
For light themes, harmonious controls whether the generated palette keeps
the background-to-foreground orientation. When false, Ghostty swaps the
light background and dark foreground so the cube and ramp run dark-to-light.