Skip to content

Commit

Permalink
0.2.0, add get_color_json()
Browse files Browse the repository at this point in the history
  • Loading branch information
dantasse committed Oct 30, 2020
1 parent edbbee5 commit 1bbaf06
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions colornamer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .colornamer import get_color_from_rgb
from .colornamer import get_color_from_lab
from .colornamer import get_color_json
9 changes: 9 additions & 0 deletions colornamer/colornamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,12 @@ def get_color_from_lab(lab_color: List[float]) -> Dict:
)
xkcd_name = color_data["xkcd_names"][dists.argmin()]
return color_data["color_hierarchy"][xkcd_name]

def get_color_json() -> Dict:
""" Just return the whole json from color_hierarchy.json; you can then use
it however you like. For example, pd.DataFrame(color_json) if a pandas
DataFrame is useful to you."""
hierarchy_txt = pkg_resources.read_text("static", HIERARCHY_JSON_FILE)
color_json = json.loads(hierarchy_txt)
return color_json

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="colornamer",
version="0.1.3",
version="0.2.0",
description="Given a color, return a hierarchy of names.",
long_description="Turns an RGB or LAB point into a hierarchical list of "
"names: color family, common color, design color, and xkcd color, as "
Expand Down

0 comments on commit 1bbaf06

Please sign in to comment.