Current section

Files

Jump to
catppuccin src catppuccin.gleam
Raw

src/catppuccin.gleam

import gleam/int
import gleam/result
import gleam_community/colour.{type Colour, white}
pub type CatppuccinColor {
CatppuccinColor(name: String, order: Int, accent: Bool, color: Colour)
}
/// Converts rgb values to a `Colour`.
/// returns white as a fallback color, if the conversion fails.
/// this is used by the lib (probably should've been a private function)
///
pub fn to_community_colour(r r: Int, g g: Int, b b: Int) -> Colour {
colour.from_rgb(
r: int.to_float(r / 1000),
g: int.to_float(g / 1000),
b: int.to_float(b / 1000),
)
|> result.unwrap(white)
}