Juice/tools.py

21 lines
536 B
Python
Raw Normal View History

2019-06-22 18:37:16 -04:00
#!/usr/bin/env python3
"""
Miscellaneous tools and helper functions.
"""
2019-11-18 13:05:37 -05:00
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
2019-06-22 18:37:16 -04:00
2019-11-18 13:05:37 -05:00
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