21 lines
536 B
Python
21 lines
536 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Miscellaneous tools and helper functions.
|
|
"""
|
|
|
|
def to_html_color(color):
|
|
"""Converts a decimal color code to HTML format."""
|
|
html_color = "#"
|
|
for i in range(3):
|
|
html_color += hex(color[i])[2:].zfill(2)
|
|
return html_color
|
|
|
|
def from_html_color(html_color):
|
|
"""Converts an HTML color code to decimal list format."""
|
|
html_color = html_color[1:]
|
|
color = []
|
|
color.append(int(html_color[0:2], base=16))
|
|
color.append(int(html_color[2:4], base=16))
|
|
color.append(int(html_color[4:6], base=16))
|
|
return color
|