mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 03:26:16 +00:00
Move colours to HSL, probably a mistake
This commit is contained in:
parent
9821db72c6
commit
1a59e413a9
29 changed files with 852 additions and 730 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue