Raxol.Style.Colors.Palette (Raxol v0.2.0)
View SourceManages collections of related colors as palettes. Provides standard palettes and custom palette creation.
Examples
# Using standard palettes
palette = Raxol.Style.Colors.Palette.standard_16()
solarized = Raxol.Style.Colors.Palette.solarized()
# Creating a custom palette from a base color
base_color = Raxol.Style.Colors.Color.from_hex("#4285F4") # Google Blue
custom_palette = Raxol.Style.Colors.Palette.from_base_color(base_color)
# Accessing colors from a palette
primary = Raxol.Style.Colors.Palette.get_color(palette, :primary)
background = Raxol.Style.Colors.Palette.get_color(palette, :background)
Summary
Functions
Adds a color to a palette with the given name.
Creates an analogous color palette based on a base color.
Creates an ANSI 256 color palette. Currently this is a placeholder that returns the standard 16 colors.
Creates a complementary palette based on a base color.
Creates a Dracula color palette.
Creates a new palette from a base color.
Gets a color from a palette by name.
Merges two palettes, with the second palette's colors taking precedence.
Creates a monochromatic color palette with specified number of steps.
Creates a Nord color palette.
Removes a color from a palette by name.
Creates a Solarized color palette.
Creates a standard 16-color ANSI palette.
Creates a triadic color palette based on a base color.
Types
Functions
Adds a color to a palette with the given name.
Examples
iex> palette = Raxol.Style.Colors.Palette.standard_16()
iex> color = Raxol.Style.Colors.Color.from_hex("#FF00FF")
iex> updated = Raxol.Style.Colors.Palette.add_color(palette, :hot_pink, color)
iex> Raxol.Style.Colors.Palette.get_color(updated, :hot_pink) == color
true
Creates an analogous color palette based on a base color.
Examples
iex> base = Raxol.Style.Colors.Color.from_hex("#4285F4")
iex> palette = Raxol.Style.Colors.Palette.analogous(base)
iex> palette.name
"Analogous"
Creates an ANSI 256 color palette. Currently this is a placeholder that returns the standard 16 colors.
Examples
iex> palette = Raxol.Style.Colors.Palette.ansi_256()
iex> palette.name
"ANSI 256"
Creates a complementary palette based on a base color.
Examples
iex> base = Raxol.Style.Colors.Color.from_hex("#4285F4")
iex> palette = Raxol.Style.Colors.Palette.complementary(base)
iex> palette.name
"Complementary"
Creates a Dracula color palette.
Examples
iex> palette = Raxol.Style.Colors.Palette.dracula()
iex> palette.name
"Dracula"
Creates a new palette from a base color.
Examples
iex> base = Raxol.Style.Colors.Color.from_hex("#4285F4")
iex> palette = Raxol.Style.Colors.Palette.from_base_color(base)
iex> palette.name
"Custom"
Gets a color from a palette by name.
Examples
iex> palette = Raxol.Style.Colors.Palette.standard_16()
iex> color = Raxol.Style.Colors.Palette.get_color(palette, :red)
iex> color.hex
"#800000"
Merges two palettes, with the second palette's colors taking precedence.
Examples
iex> p1 = Raxol.Style.Colors.Palette.standard_16()
iex> p2 = Raxol.Style.Colors.Palette.solarized()
iex> merged = Raxol.Style.Colors.Palette.merge_palettes(p1, p2)
iex> merged.name
"ANSI 16 + Solarized"
Creates a monochromatic color palette with specified number of steps.
Examples
iex> base = Raxol.Style.Colors.Color.from_hex("#4285F4")
iex> palette = Raxol.Style.Colors.Palette.monochromatic(base, 5)
iex> palette.name
"Monochromatic"
Creates a Nord color palette.
Examples
iex> palette = Raxol.Style.Colors.Palette.nord()
iex> palette.name
"Nord"
Removes a color from a palette by name.
Examples
iex> palette = Raxol.Style.Colors.Palette.standard_16()
iex> updated = Raxol.Style.Colors.Palette.remove_color(palette, :red)
iex> Raxol.Style.Colors.Palette.get_color(updated, :red)
nil
Creates a Solarized color palette.
Examples
iex> palette = Raxol.Style.Colors.Palette.solarized()
iex> palette.name
"Solarized"
Creates a standard 16-color ANSI palette.
Examples
iex> palette = Raxol.Style.Colors.Palette.standard_16()
iex> Map.keys(palette.colors) |> length()
16
Creates a triadic color palette based on a base color.
Examples
iex> base = Raxol.Style.Colors.Color.from_hex("#4285F4")
iex> palette = Raxol.Style.Colors.Palette.triadic(base)
iex> palette.name
"Triadic"