Skip to content

Commit

Permalink
Generate one fixed color per character based on their id, and update …
Browse files Browse the repository at this point in the history
…default colors, closes #1424
  • Loading branch information
zkovari committed Oct 16, 2024
1 parent 6baf9ed commit 45f8cd0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
47 changes: 39 additions & 8 deletions src/main/python/plotlyst/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,43 @@ def set_worldbuilding_editor_max_width(self, value: int):
}

CHARACTER_INITIAL_AVATAR_COLOR_CODES: List[str] = [
'#03396c',
'#0e9aa7',
'#62c370',
'#cc3363',
'#f5e960',
'#3c4f76',
'#b388eb',
'#8093f1',
'#03396c', # Deep navy blue
'#0e9aa7', # Bright teal
'#62c370', # Fresh green
'#cc3363', # Deep magenta
'#4db6ac', # Light teal
'#1b5e20', # Forest green
'#00796b', # Muted green-teal
'#62a6e5', # Sky blue
'#007bb8', # Bright blue
'#81c784', # Light green

'#4e342e', # Dark brown
'#6f9b5a', # Olive green
'#e57373', # Warm muted red
'#b388eb', # Soft lavender
'#ff6f61', # Coral red
'#795548', # Brown

'#9575cd', # Muted purple
'#26a69a', # Teal
'#7986cb', # Periwinkle
'#ccff90', # Light lime green
'#4caf50', # Medium green

'#f06292', # Hot pink
'#ffccbc', # Light pink
'#81d4fa', # Light blue
'#ef5350', # Light red
'#7b1fa2', # Dark magenta
'#455a64', # Dark cyan
'#bdbdbd', # Gray
'#90a4ae', # Cool gray
'#9c27b0', # Rich purple

'#c2185b', # Dark pink
'#ff9800', # Bright orange
'#e1bee7', # Pale violet
'#8bc34a', # Lime green
'#ffc107', # Soft amber
]
15 changes: 8 additions & 7 deletions src/main/python/plotlyst/view/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,16 +786,17 @@ def has_name_initial_icon(self, character: Character) -> bool:
return False

def name_initial_icon(self, character: Character, fallback: bool = True) -> QIcon:
_sum = sum([ord(x) for x in character.name])
color = CHARACTER_INITIAL_AVATAR_COLOR_CODES[_sum % len(CHARACTER_INITIAL_AVATAR_COLOR_CODES)]

if not character.name:
return self._dummy_avatar()

if character.name[0].isnumeric():
icon = f'mdi.numeric-{int(character.name[0])}-circle-outline'
elif character.name[0].isalpha():
icon = f'mdi.alpha-{character.name[0].lower()}-circle-outline'
_uuid_int = character.id.int
color = CHARACTER_INITIAL_AVATAR_COLOR_CODES[_uuid_int % len(CHARACTER_INITIAL_AVATAR_COLOR_CODES)]

first_char = character.name[0]
if first_char.isnumeric():
icon = f'mdi.numeric-{int(first_char)}-circle-outline'
elif 'a' <= first_char.lower() <= 'z':
icon = f'mdi.alpha-{first_char.lower()}-circle-outline'
elif fallback:
return self._dummy_avatar()
else:
Expand Down

0 comments on commit 45f8cd0

Please sign in to comment.