-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create Palette.md * Update Palette.md * Update HydraMenu.md * Update Playing-Sound.md * Update popup.md * Update userinput.md * Update Home.md
- Loading branch information
1 parent
df99773
commit ef69a9d
Showing
6 changed files
with
249 additions
and
156 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
## lib.display.palette.Palette | ||
|
||
This Palette class is designed to be used for storing a list of RGB565 colors, | ||
and for returning the apropriate colors by index to be used with MicroHydra's display module. | ||
|
||
When `Config` from `lib.hydra.config` is initialized, it reads the user set color data from `config.json` and creates a 16-color palette from it. | ||
|
||
<br /> | ||
|
||
Key notes on Palette: | ||
- Has a static length of 16 colors | ||
|
||
- Is used by both `lib.hydra.config.Config` and `lib.display.Display` (it is the same Palette in both) | ||
|
||
- uses a bytearray to store color information, | ||
this is intended for fast/easy use with Viper's ptr16. | ||
|
||
- Returns an RGB565 color when using normal framebuffer, or an index when Display is initialized with `use_tiny_buf`. | ||
(This makes it so that you can pass a `Palette[i]` to the Display class in either mode.) | ||
|
||
- Palette is a singleton, which is important so that different MH classes can modify and share it's data | ||
(without initializing the Display). | ||
|
||
|
||
Retrieving a color from the Palette is fairly fast, but if you want to maximize your speed, it's probably smart to read and store the colors you need as local variables (after initializing the `Display` and `Config`). | ||
|
||
<br /> | ||
|
||
For your reference, here is a complete list of the colors, by index, contained in the palette: | ||
<ol start="0"> | ||
<li>Black</li> | ||
<li>Darker bg_color</li> | ||
<li>bg_color</li> | ||
</ol> | ||
|
||
<ol start="3"> | ||
<li>84% bg_color 16% ui_color</li> | ||
<li>67% bg_color 33% ui_color</li> | ||
<li>50% bg_color 50% ui_color (mid_color)</li> | ||
<li>33% bg_color 67% ui_color</li> | ||
<li>16% bg_color 84% ui_color</li> | ||
</ol> | ||
|
||
<ol start="8"> | ||
<li>ui_color</li> | ||
<li>Lighter ui_color</li> | ||
<li>white</li> | ||
</ol> | ||
|
||
<ol start="11"> | ||
<li>reddish bg_color</li> | ||
<li>greenish mid_color</li> | ||
<li>bluish ui_color</li> | ||
</ol> | ||
|
||
<ol start="14"> | ||
<li>compliment bg_color (opposite hue)</li> | ||
<li>compliment ui_color</li> | ||
</ol> | ||
|
||
<br /><br /><br /><br /> | ||
|
||
|
||
## lib.display.namedpalette.NamedPalette | ||
|
||
As an alternative, for improved readability and simplicity, you can import the optional `NamedPalette` class, which works similarly to the normal `Palette`, but also accepts strings containing color names. | ||
|
||
``` Py | ||
names = { | ||
'black':0, | ||
'bg_dark':1, | ||
'bg_color':2, | ||
'mid_color':5, | ||
'ui_color':8, | ||
'ui_light':9, | ||
'white':10, | ||
'red':11, | ||
'green':12, | ||
'blue':13, | ||
'bg_complement':14, | ||
'ui_complement':15, | ||
} | ||
``` | ||
|
||
<br /> |
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
Oops, something went wrong.