mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 03:26:16 +00:00
Add colour contrast filter
Make colours on images yoinkable
This commit is contained in:
parent
76cc8456d2
commit
13a0b21710
4 changed files with 41 additions and 5 deletions
22
onlylegs/filters.py
Normal file
22
onlylegs/filters.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
"""
|
||||
OnlyLegs filters
|
||||
Custom Jinja2 filters
|
||||
"""
|
||||
from flask import Blueprint
|
||||
from onlylegs.utils import contrast
|
||||
|
||||
|
||||
blueprint = Blueprint('filters', __name__)
|
||||
|
||||
|
||||
@blueprint.app_template_filter()
|
||||
def colour_contrast(colour):
|
||||
"""
|
||||
Pass in the colour of the background and will return
|
||||
a css variable based on the contrast of text required to be readable
|
||||
"color: var(--fg-white);" or "color: var(--fg-black);"
|
||||
"""
|
||||
bright = "var(--fg-white)"
|
||||
dark = "var(--fg-black)"
|
||||
|
||||
return "color: RGB(" + contrast.contrast(colour, dark, bright) + ");"
|
Loading…
Add table
Add a link
Reference in a new issue