Module src.utils.colors
Color utilities module.
Provides a perceptually uniform 12-step HSV palette (derived from HSLuv with L=50)
for mapping 12 note indices around the circle of fourths to RGB.
Requires a “dream” object exposing an HSVtoRGB(h, s, v)
method.
Functions
init (dream) | Initialize the color module with a Dream instance. |
getNoteColor (index) | Get the RGB color corresponding to a note index. |
Functions
- init (dream)
-
Initialize the color module with a Dream instance.
The Dream instance must implement
HSVtoRGB(h, s, v)
which returns either three numeric values (r, g, b) or a table{r, g, b}
.Parameters:
- dream
table
Object providing
HSVtoRGB(h, s, v)
Returns:
-
nil
- dream
table
Object providing
- getNoteColor (index)
-
Get the RGB color corresponding to a note index.
Wraps the index into the range 1..12, looks up the HSV entry,
and converts it to RGB via the Dream instance.
Parameters:
- index number 1-based note index (any integer, wraps modulo 12)
Returns:
- number r Red channel in [0..1]
- number g Green channel in [0..1]
-
number
b Blue channel in [0..1]
or @treturn table rgb Table with keys
r
,g
,b
if Dream returns a table.