mirror of
https://github.com/haidaraM/ansible-playbook-grapher
synced 2024-11-10 06:04:15 +00:00
fix: Explicitly set color luminance to avoid bright colors
This commit is contained in:
parent
f600eed512
commit
708175caf2
2 changed files with 5 additions and 4 deletions
|
@ -18,6 +18,7 @@
|
|||
- Use the correct tooltip for edges
|
||||
- style: Do not use bold style by default and apply color on nodes border
|
||||
- Merge when condition with `and`
|
||||
- fix: Explicitly set color luminance to avoid bright colors
|
||||
- test:
|
||||
- Add Ansible 2.10.7 in the test matrix
|
||||
- Make test verbose by default with `-vv` in the args
|
||||
|
|
|
@ -4,6 +4,7 @@ from typing import Tuple, List
|
|||
|
||||
from ansible.parsing.dataloader import DataLoader
|
||||
from ansible.parsing.yaml.objects import AnsibleUnicode
|
||||
from ansible.playbook import Play
|
||||
from ansible.playbook.role_include import IncludeRole
|
||||
from ansible.playbook.task import Task
|
||||
from ansible.playbook.task_include import TaskInclude
|
||||
|
@ -42,15 +43,14 @@ def clean_name(name: str):
|
|||
return name.strip().replace('"', """)
|
||||
|
||||
|
||||
def get_play_colors(play) -> Tuple[str, str]:
|
||||
def get_play_colors(play: Play) -> Tuple[str, str]:
|
||||
"""
|
||||
Generate two colors (in hex) for a given play: the main color and the color to use as a font color
|
||||
:param play
|
||||
:return:
|
||||
"""
|
||||
# TODO: Check the if the picked color is (almost) white. We can't see a white edge on the graph
|
||||
picked_color = Color(pick_for=play)
|
||||
play_font_color = "#000000" if picked_color.get_luminance() > 0.6 else "#ffffff"
|
||||
picked_color = Color(pick_for=play, luminance=0.4)
|
||||
play_font_color = "#ffffff"
|
||||
|
||||
return picked_color.get_hex_l(), play_font_color
|
||||
|
||||
|
|
Loading…
Reference in a new issue