Move colours to HSL, probably a mistake

This commit is contained in:
Michał Gdula 2023-09-26 19:36:49 +01:00
parent 9821db72c6
commit 1a59e413a9
29 changed files with 852 additions and 730 deletions

View file

@ -4,6 +4,7 @@ Custom Jinja2 filters
"""
from flask import Blueprint
from onlylegs.utils import colour as colour_utils
import colorsys
blueprint = Blueprint("filters", __name__)
@ -18,3 +19,27 @@ def colour_contrast(colour):
"""
colour_obj = colour_utils.Colour(colour)
return "rgb(var(--fg-black));" if colour_obj.is_light() else "rgb(var(--fg-white));"
@blueprint.app_template_filter()
def hsl_hue(rgb):
"""
Pass in a rgb value and will return the hue value
"""
r, g, b = rgb
r /= 255
g /= 255
b /= 255
return colorsys.rgb_to_hls(r, g, b)[0] * 360
@blueprint.app_template_filter()
def hsl_saturation(rgb):
"""
Pass in a rgb value and will return the saturation value
"""
r, g, b = rgb
r /= 255
g /= 255
b /= 255
return colorsys.rgb_to_hls(r, g, b)[1] * 100