forked from LiveCarta/BookConverter
Change package names of webcolors
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
FROM python:3.10.0
|
FROM python:3.11.0
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y software-properties-common
|
apt-get install -y software-properties-common
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import re
|
import re
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
from colorsys import hls_to_rgb
|
from colorsys import hls_to_rgb
|
||||||
from webcolors import HTML4_HEX_TO_NAMES, hex_to_rgb, rgb_to_name, rgb_percent_to_hex, rgb_to_hex, CSS3_NAMES_TO_HEX
|
from webcolors import html4_hex_to_names, hex_to_rgb, rgb_to_name, rgb_percent_to_hex, rgb_to_hex, css3_hex_to_names
|
||||||
|
|
||||||
|
|
||||||
def closest_colour_rgb(requested_color: Tuple[int, ...]) -> str:
|
def closest_colour_rgb(requested_color: Tuple[int, ...]) -> str:
|
||||||
""" Function finds closes colour rgb """
|
""" Function finds closes colour rgb """
|
||||||
min_colours = {}
|
min_colours = {}
|
||||||
for key, name in HTML4_HEX_TO_NAMES.items():
|
for key, name in html4_hex_to_names.items():
|
||||||
r_c, g_c, b_c = hex_to_rgb(key)
|
r_c, g_c, b_c = hex_to_rgb(key)
|
||||||
rd = (r_c - requested_color[0]) ** 2
|
rd = (r_c - requested_color[0]) ** 2
|
||||||
gd = (g_c - requested_color[1]) ** 2
|
gd = (g_c - requested_color[1]) ** 2
|
||||||
@@ -76,7 +76,7 @@ def str2closest_html_color_name(s: str) -> str:
|
|||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
elif s in HTML4_HEX_TO_NAMES.items():
|
elif s in html4_hex_to_names.items():
|
||||||
return s
|
return s
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
@@ -124,8 +124,8 @@ def str2hex(s: str) -> str:
|
|||||||
rgb = rgba2rgb(*rgb, alpha)
|
rgb = rgba2rgb(*rgb, alpha)
|
||||||
return rgb_to_hex(rgb)
|
return rgb_to_hex(rgb)
|
||||||
|
|
||||||
if s.lower() in CSS3_NAMES_TO_HEX:
|
if s.lower() in css3_hex_to_names:
|
||||||
return CSS3_NAMES_TO_HEX[s.lower()]
|
return css3_hex_to_names[s.lower()]
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user