-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0509d8
commit 20ca409
Showing
3 changed files
with
17 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
from importlib import import_module | ||
from typing import Union | ||
|
||
from .modes.hex import HEX | ||
from .modes.name import Name | ||
from .modes.rgb import RGB | ||
from termspark.painter.modes.mode import Mode | ||
|
||
|
||
class ModeManager: | ||
__mode: Union[RGB, HEX, Name] | ||
|
||
def __init__(self, color: Union[str, tuple]): | ||
self._color = color | ||
|
||
if RGB.check(color): | ||
self.__mode = RGB(color) | ||
elif HEX.check(color): | ||
self.__mode = HEX(color) | ||
else: | ||
self.__mode = Name(color) | ||
for mode in Mode.__subclasses__(): | ||
_module = import_module(f"termspark.painter.modes.{mode.__name__.lower()}") | ||
_class = getattr(_module, mode.__name__) | ||
if _class.check(color): | ||
self.__mode = _class(color) | ||
break | ||
|
||
def format(self): | ||
return self.__mode.format() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters