[+] Random custom coloring
This commit is contained in:
parent
7bd96e422f
commit
a1d687d3bd
3 changed files with 184 additions and 45 deletions
|
|
@ -1,10 +1,21 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Iterable
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .color_util import RGB
|
||||
|
||||
|
||||
def remove_duplicates(seq: Iterable) -> list:
|
||||
"""
|
||||
Remove duplicate items from a sequence while preserving the order
|
||||
"""
|
||||
seen = set()
|
||||
seen_add = seen.add
|
||||
return [x for x in seq if not (x in seen or seen_add(x))]
|
||||
|
||||
|
||||
class ColorProfile:
|
||||
raw: list[str]
|
||||
colors: list[RGB]
|
||||
|
|
@ -98,6 +109,12 @@ class ColorProfile:
|
|||
"""
|
||||
return ColorProfile([c.set_light(light) for c in self.colors])
|
||||
|
||||
def unique_colors(self) -> ColorProfile:
|
||||
"""
|
||||
Create another color profile with only the unique colors
|
||||
"""
|
||||
return ColorProfile(remove_duplicates(self.colors))
|
||||
|
||||
|
||||
PRESETS: dict[str, ColorProfile] = {
|
||||
'rainbow': ColorProfile([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue