catppuccin.models
Dataclass definitions for the Catppuccin palette data structure.
1"""Dataclass definitions for the Catppuccin palette data structure.""" 2 3from collections.abc import Iterator 4from dataclasses import dataclass 5 6__all__ = ["Palette", "Flavor", "FlavorColors", "Color", "RGB", "HSL"] 7 8 9@dataclass(frozen=True) 10class RGB: 11 """Color represented as red, green, and blue (all 0-255).""" 12 13 r: int 14 """@public""" 15 g: int 16 """@public""" 17 b: int 18 """@public""" 19 20 21@dataclass(frozen=True) 22class HSL: 23 """Color represented as hue (0-359), saturation (0-1), and lightness (0-1).""" 24 25 h: float 26 """@public""" 27 s: float 28 """@public""" 29 l: float # noqa: E741 30 """@public""" 31 32 33@dataclass(frozen=True) 34class Color: 35 """A single color in the Catppuccin palette.""" 36 37 name: str 38 """A human-readable name such as `Pink` or `Surface0`.""" 39 identifier: str 40 """The lowercase key used to identify the color. This differs from `name` in 41 that it's intended for machine usage rather than presentation.""" 42 accent: bool 43 """Whether the color is considered an accent color. Accent colors are the 44 first 14 colors in the palette, also called the analogous colours. The 45 remaining 12 non-accent colors are also referred to as the monochromatic 46 colors.""" 47 order: int 48 """Order of the color in the palette spec.""" 49 hex: str 50 """The color represented as a six-digit hex string with a leading hash (#).""" 51 rgb: RGB 52 """The color represented as individual red, green, and blue channels. (0-255)""" 53 hsl: HSL 54 """The color represented as individual hue (0-359), saturation (0-1), and 55 lightness (0-1) channels.""" 56 57 58@dataclass(frozen=True) 59class FlavorColors: 60 """All of the colors for a particular flavor of Catppuccin. 61 62 Can be iterated over, in which case the colors are yielded in order. 63 """ 64 65 rosewater: Color 66 """@public""" 67 flamingo: Color 68 """@public""" 69 pink: Color 70 """@public""" 71 mauve: Color 72 """@public""" 73 red: Color 74 """@public""" 75 maroon: Color 76 """@public""" 77 peach: Color 78 """@public""" 79 yellow: Color 80 """@public""" 81 green: Color 82 """@public""" 83 teal: Color 84 """@public""" 85 sky: Color 86 """@public""" 87 sapphire: Color 88 """@public""" 89 blue: Color 90 """@public""" 91 lavender: Color 92 """@public""" 93 text: Color 94 """@public""" 95 subtext1: Color 96 """@public""" 97 subtext0: Color 98 """@public""" 99 overlay2: Color 100 """@public""" 101 overlay1: Color 102 """@public""" 103 overlay0: Color 104 """@public""" 105 surface2: Color 106 """@public""" 107 surface1: Color 108 """@public""" 109 surface0: Color 110 """@public""" 111 base: Color 112 """@public""" 113 mantle: Color 114 """@public""" 115 crust: Color 116 """@public""" 117 118 def __iter__(self) -> Iterator[Color]: 119 """Iterate over colors in the flavor.""" 120 yield from [ 121 self.rosewater, 122 self.flamingo, 123 self.pink, 124 self.mauve, 125 self.red, 126 self.maroon, 127 self.peach, 128 self.yellow, 129 self.green, 130 self.teal, 131 self.sky, 132 self.sapphire, 133 self.blue, 134 self.lavender, 135 self.text, 136 self.subtext1, 137 self.subtext0, 138 self.overlay2, 139 self.overlay1, 140 self.overlay0, 141 self.surface2, 142 self.surface1, 143 self.surface0, 144 self.base, 145 self.mantle, 146 self.crust, 147 ] 148 149 150@dataclass(frozen=True) 151class Flavor: 152 """A flavor is a collection of colors. 153 154 Catppuccin has four flavors; Latte, Frappé, Macchiato, and Mocha. 155 """ 156 157 name: str 158 """A human-readable name such as `Latte` or `Mocha`.""" 159 identifier: str 160 """The lowercase key used to identify the flavor. This differs from `name` 161 in that it's intended for machine usage rather than presentation""" 162 order: int 163 """Order of the flavor in the palette spec.""" 164 dark: bool 165 """Whether this flavor is dark or light oriented. Latte is light, the other 166 three flavors are dark.""" 167 colors: FlavorColors 168 """@public""" 169 170 171@dataclass(frozen=True) 172class Palette: 173 """The top-level type that encompasses the Catppuccin palette data structure. 174 175 Primarily used via the `PALETTE` constant. 176 Can be iterated over, in which case the flavors are yielded in the canonical 177 order: Latte, Frappé, Macchiato, Mocha. 178 """ 179 180 latte: Flavor 181 """The light flavor.""" 182 frappe: Flavor 183 """The lightest dark flavor.""" 184 macchiato: Flavor 185 """The medium dark flavor.""" 186 mocha: Flavor 187 """The darkest dark flavor.""" 188 189 def __iter__(self) -> Iterator[Flavor]: 190 """Iterate over flavors in the palette.""" 191 yield from [self.latte, self.frappe, self.macchiato, self.mocha]
172@dataclass(frozen=True) 173class Palette: 174 """The top-level type that encompasses the Catppuccin palette data structure. 175 176 Primarily used via the `PALETTE` constant. 177 Can be iterated over, in which case the flavors are yielded in the canonical 178 order: Latte, Frappé, Macchiato, Mocha. 179 """ 180 181 latte: Flavor 182 """The light flavor.""" 183 frappe: Flavor 184 """The lightest dark flavor.""" 185 macchiato: Flavor 186 """The medium dark flavor.""" 187 mocha: Flavor 188 """The darkest dark flavor.""" 189 190 def __iter__(self) -> Iterator[Flavor]: 191 """Iterate over flavors in the palette.""" 192 yield from [self.latte, self.frappe, self.macchiato, self.mocha]
The top-level type that encompasses the Catppuccin palette data structure.
Primarily used via the PALETTE
constant.
Can be iterated over, in which case the flavors are yielded in the canonical
order: Latte, Frappé, Macchiato, Mocha.
151@dataclass(frozen=True) 152class Flavor: 153 """A flavor is a collection of colors. 154 155 Catppuccin has four flavors; Latte, Frappé, Macchiato, and Mocha. 156 """ 157 158 name: str 159 """A human-readable name such as `Latte` or `Mocha`.""" 160 identifier: str 161 """The lowercase key used to identify the flavor. This differs from `name` 162 in that it's intended for machine usage rather than presentation""" 163 order: int 164 """Order of the flavor in the palette spec.""" 165 dark: bool 166 """Whether this flavor is dark or light oriented. Latte is light, the other 167 three flavors are dark.""" 168 colors: FlavorColors 169 """@public"""
A flavor is a collection of colors.
Catppuccin has four flavors; Latte, Frappé, Macchiato, and Mocha.
The lowercase key used to identify the flavor. This differs from name
in that it's intended for machine usage rather than presentation
59@dataclass(frozen=True) 60class FlavorColors: 61 """All of the colors for a particular flavor of Catppuccin. 62 63 Can be iterated over, in which case the colors are yielded in order. 64 """ 65 66 rosewater: Color 67 """@public""" 68 flamingo: Color 69 """@public""" 70 pink: Color 71 """@public""" 72 mauve: Color 73 """@public""" 74 red: Color 75 """@public""" 76 maroon: Color 77 """@public""" 78 peach: Color 79 """@public""" 80 yellow: Color 81 """@public""" 82 green: Color 83 """@public""" 84 teal: Color 85 """@public""" 86 sky: Color 87 """@public""" 88 sapphire: Color 89 """@public""" 90 blue: Color 91 """@public""" 92 lavender: Color 93 """@public""" 94 text: Color 95 """@public""" 96 subtext1: Color 97 """@public""" 98 subtext0: Color 99 """@public""" 100 overlay2: Color 101 """@public""" 102 overlay1: Color 103 """@public""" 104 overlay0: Color 105 """@public""" 106 surface2: Color 107 """@public""" 108 surface1: Color 109 """@public""" 110 surface0: Color 111 """@public""" 112 base: Color 113 """@public""" 114 mantle: Color 115 """@public""" 116 crust: Color 117 """@public""" 118 119 def __iter__(self) -> Iterator[Color]: 120 """Iterate over colors in the flavor.""" 121 yield from [ 122 self.rosewater, 123 self.flamingo, 124 self.pink, 125 self.mauve, 126 self.red, 127 self.maroon, 128 self.peach, 129 self.yellow, 130 self.green, 131 self.teal, 132 self.sky, 133 self.sapphire, 134 self.blue, 135 self.lavender, 136 self.text, 137 self.subtext1, 138 self.subtext0, 139 self.overlay2, 140 self.overlay1, 141 self.overlay0, 142 self.surface2, 143 self.surface1, 144 self.surface0, 145 self.base, 146 self.mantle, 147 self.crust, 148 ]
All of the colors for a particular flavor of Catppuccin.
Can be iterated over, in which case the colors are yielded in order.
34@dataclass(frozen=True) 35class Color: 36 """A single color in the Catppuccin palette.""" 37 38 name: str 39 """A human-readable name such as `Pink` or `Surface0`.""" 40 identifier: str 41 """The lowercase key used to identify the color. This differs from `name` in 42 that it's intended for machine usage rather than presentation.""" 43 accent: bool 44 """Whether the color is considered an accent color. Accent colors are the 45 first 14 colors in the palette, also called the analogous colours. The 46 remaining 12 non-accent colors are also referred to as the monochromatic 47 colors.""" 48 order: int 49 """Order of the color in the palette spec.""" 50 hex: str 51 """The color represented as a six-digit hex string with a leading hash (#).""" 52 rgb: RGB 53 """The color represented as individual red, green, and blue channels. (0-255)""" 54 hsl: HSL 55 """The color represented as individual hue (0-359), saturation (0-1), and 56 lightness (0-1) channels."""
A single color in the Catppuccin palette.
The lowercase key used to identify the color. This differs from name
in
that it's intended for machine usage rather than presentation.
Whether the color is considered an accent color. Accent colors are the first 14 colors in the palette, also called the analogous colours. The remaining 12 non-accent colors are also referred to as the monochromatic colors.
The color represented as individual hue (0-359), saturation (0-1), and lightness (0-1) channels.
10@dataclass(frozen=True) 11class RGB: 12 """Color represented as red, green, and blue (all 0-255).""" 13 14 r: int 15 """@public""" 16 g: int 17 """@public""" 18 b: int 19 """@public"""
Color represented as red, green, and blue (all 0-255).
22@dataclass(frozen=True) 23class HSL: 24 """Color represented as hue (0-359), saturation (0-1), and lightness (0-1).""" 25 26 h: float 27 """@public""" 28 s: float 29 """@public""" 30 l: float # noqa: E741 31 """@public"""
Color represented as hue (0-359), saturation (0-1), and lightness (0-1).