Skip to content

Commit d880ecb

Browse files
committed
added palettes() method to return sorted list of palette names
1 parent 544be41 commit d880ecb

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGES.rst

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Changelog
77
- added missing typing hint imports
88
- added ability to extend color lists and palettes with custom ones
99
- added `palette_list_to_triplets` method to convert flat list into list of R,G,B tuples
10+
- added `palettes` method for returning the sorted list of available palettes
1011

1112

1213
0.0.3 (2025-02-04)

src/simple_palette_utils/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
from ._palettes import COLOR_LISTS, COLOR_LIST_X11, COLOR_LIST_LIGHT, COLOR_LIST_DARK, COLOR_LIST_COLORBLIND8, COLOR_LIST_COLORBLIND12, COLOR_LIST_COLORBLIND15, COLOR_LIST_COLORBLIND24
33
from ._palettes import colors, x11_colors, parse_rgb, parse_rgba, ColorProvider, color_lists, add_color_list
44
from ._palettes import PALETTES, PALETTE_AUTO, PALETTE_GRAYSCALE, PALETTE_X11, PALETTE_LIGHT, PALETTE_DARK, PALETTE_COLORBLIND8, PALETTE_COLORBLIND12, PALETTE_COLORBLIND15, PALETTE_COLORBLIND24
5-
from ._palettes import default_palette, fill_palette, grayscale_palette, generate_palette_list, add_palette
6-
from ._palettes import palette_list_to_triplets
5+
from ._palettes import palettes, default_palette, fill_palette, grayscale_palette, generate_palette_list, add_palette, palette_list_to_triplets

src/simple_palette_utils/_palettes.py

+10
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,16 @@ def parse_rgba(color_list: List[str]) -> List[Tuple[int, int, int, int]]:
492492
return result
493493

494494

495+
def palettes() -> List[str]:
496+
"""
497+
Returns the sorted list of palette names.
498+
499+
:return: the list of names
500+
:rtype: list
501+
"""
502+
return sorted(PALETTES.keys())
503+
504+
495505
def color_lists() -> List[str]:
496506
"""
497507
Returns the sorted list of color list names.

0 commit comments

Comments
 (0)