ManimCommunity / ManimCommunity/manim
Color palette format and builder
- Dominant language
- Python
- Stars
- 40.9k
- Forks
- 3.1k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 25
Description
## Description of proposed feature
This idea spawned from discord messages about adding support for additional color palletes and how it is not that easy to use/find those that already are in.
This is rough draft of model that could hold color information and transfer it to internal format only when needed first time (decreasing Construction calls at import for colors which will never used for individual animation).
In Addittion, global namespace can be much cleaner if there is not floating all default colors like RED, WHITE, BLACK, etc.
```python
# IDE see this information:
class AS2700_UI():
Y14_GOLDEN_YELLOW:ManimColor ="#DDDDDD"
#could also be only with annotation
B13_NAVY_BLUE : ManimColor
DICTIONARY = {
"Y14_GOLDEN_YELLOW": "GOLDEN YELLOW",
}
# Runtime sees instances of this class:
class ColorBuilder:
def __init__(self, dictionary:dict) -> None:
self.dictionary = dictionary
def __getattr__(self, name: str) -> Any:
item = self.dictionary.get(name, "DEFAULT")
# Calls transformer to internal color format
color_object = ManimColor(item)
#builds proper attribute, so next call returns color_object directly
setattr(self, name, color_object)
return color_object
#namespace substitution at import:
AS2700_UI = ColorBuilder(AS2700_API.DICTIONARY)
# Global namespace could start Colors, ColorsX11, etc.
# Or Pallette
ColorsAS2700 = AS2700_UI
PalletteAS2700 = AS2700_UI
````
## How can the new feature be used?
```python
#end user call:
yellow = ColorAS2700.Y14_GOLDEN_YELLOW
#or:
colors = ColorAS2700
colors = PalletteAS2700
yellow = colors.Y14_GOLDEN_YELLOW
````
Contributor guide
Research direction
Start by locating the existing ManimColor implementation and current global color definitions, then compare them with the proposed ColorBuilder and palette namespaces. The issue provides no file or test entry point, so first establish where color construction and exports are defined. Done should include an agreed palette API, lazy conversion behavior, and coverage for the demonstrated palette access.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100