Skip to content

Compat with webcolors v24.6.0 #619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/tikzplotlib/_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@
def _get_closest_colour_name(rgb):
match = None
mindiff = 1.0e15
for h, name in webcolors.CSS3_HEX_TO_NAMES.items():
if hasattr(webcolors, "names"):
hex_names_dict = {
webcolors.name_to_hex(name, spec=webcolors.CSS3): name
for name in webcolors.names(spec=webcolors.CSS3)
}
elif hasattr(webcolors, "CSS3_HEX_TO_NAMES"):
hex_names_dict = webcolors.CSS3_HEX_TO_NAMES
else:
hex_names_dict = webcolors._definitions._CSS3_HEX_TO_NAMES
for h, name in hex_names_dict.items():
r = int(h[1:3], 16)
g = int(h[3:5], 16)
b = int(h[5:7], 16)
Expand Down