ColorEffects
Preview noticeβ
The MatrixOS Python API is in preview and is subject to change; it may contain errors.
Overviewβ
The ColorEffects API provides utility functions for generating dynamic lighting effects such as rainbow, breathing, strobe, and other color modulation effects based on time and phase offsets. Access these functions through ColorEffects.
The Python ColorEffects API is implemented in Applications/Python/PikaPython/MatrixOS_ColorEffects.py with type hints in Applications/Python/PikaPython/_MatrixOS_ColorEffects.pyi.
Color Generation Effectsβ
ColorEffects.Rainbowβ
def Rainbow(period: int = 1000, offset: int = 0) -> Color
Generates a rainbow color effect that cycles through the hue spectrum over the specified period.
Parameters:
period(int, optional): Duration of the full color cycle in milliseconds. Defaults to1000msoffset(int, optional): Offset to adjust the starting hue. Defaults to0
Returns:
Color: The current color in the rainbow cycle
Brightness Modulation Effectsβ
ColorEffects.Breathβ
def Breath(period: int = 1000, offset: int = 0) -> int
Generates a brightness value that smoothly transitions in a sinusoidal pattern (breathing effect).
Parameters:
period(int, optional): Duration of the breathing cycle in milliseconds. Defaults to1000msoffset(int, optional): Offset to adjust the breathing phase. Defaults to0
Returns:
int: The brightness value (0-255)
ColorEffects.BreathLowBoundβ
def BreathLowBound(low_bound: int = 64, period: int = 1000, offset: int = 0) -> int
Generates a breathing effect with a minimum brightness value.
Parameters:
low_bound(int, optional): Minimum brightness value. Defaults to64period(int, optional): Duration of the breathing cycle in milliseconds. Defaults to1000msoffset(int, optional): Offset to adjust the breathing phase. Defaults to0
Returns:
int: The brightness value (low_bound to 255)
ColorEffects.Strobeβ
def Strobe(period: int = 1000, offset: int = 0) -> int
Generates a strobe effect by alternating between full brightness and off states.
Parameters:
period(int, optional): Duration of one strobe cycle in milliseconds. Defaults to1000msoffset(int, optional): Offset to adjust the strobe phase. Defaults to0
Returns:
int: The brightness value (0 or 255)
ColorEffects.Sawβ
def Saw(period: int = 1000, offset: int = 0) -> int
Generates a sawtooth waveform for brightness, cycling from 0 to 255 linearly.
Parameters:
period(int, optional): Duration of one sawtooth cycle in milliseconds. Defaults to1000msoffset(int, optional): Offset to adjust the phase. Defaults to0
Returns:
int: The brightness value (0-255)
ColorEffects.Triangleβ
def Triangle(period: int = 1000, offset: int = 0) -> int
Generates a triangle waveform for brightness, cycling up and down between 0 and 255.
Parameters:
period(int, optional): Duration of one triangle cycle in milliseconds. Defaults to1000msoffset(int, optional): Offset to adjust the phase. Defaults to0
Returns:
int: The brightness value (0-255)
Color Modulation Effectsβ
ColorEffects.ColorBreathβ
def ColorBreath(color: Color, period: int = 1000, offset: int = 0) -> Color
Applies a breathing effect to a specific color by modulating its brightness.
Parameters:
color(Color): The base colorperiod(int, optional): Duration of the breathing cycle in milliseconds. Defaults to1000msoffset(int, optional): Offset to adjust the breathing phase. Defaults to0
Returns:
Color: The modulated color with the breathing effect applied
ColorEffects.ColorBreathLowBoundβ
def ColorBreathLowBound(color: Color, low_bound: int = 64, period: int = 1000, offset: int = 0) -> Color
Applies a breathing effect to a color, ensuring a minimum brightness value.
Parameters:
color(Color): The base colorlow_bound(int, optional): Minimum brightness value. Defaults to64period(int, optional): Duration of the breathing cycle in milliseconds. Defaults to1000msoffset(int, optional): Offset to adjust the breathing phase. Defaults to0
Returns:
Color: The modulated color with the breathing effect applied
ColorEffects.ColorStrobeβ
def ColorStrobe(color: Color, period: int = 1000, offset: int = 0) -> Color
Applies a strobe effect to a specific color.
Parameters:
color(Color): The base colorperiod(int, optional): Duration of one strobe cycle in milliseconds. Defaults to1000msoffset(int, optional): Offset to adjust the strobe phase. Defaults to0
Returns:
Color: The modulated color with the strobe effect applied
ColorEffects.ColorSawβ
def ColorSaw(color: Color, period: int = 1000, offset: int = 0) -> Color
Applies a sawtooth waveform to the brightness of a specific color.
Parameters:
color(Color): The base colorperiod(int, optional): Duration of one sawtooth cycle in milliseconds. Defaults to1000msoffset(int, optional): Offset to adjust the phase. Defaults to0
Returns:
Color: The modulated color with the sawtooth effect applied
ColorEffects.ColorTriangleβ
def ColorTriangle(color: Color, period: int = 1000, offset: int = 0) -> Color
Applies a triangle waveform to the brightness of a specific color.
Parameters:
color(Color): The base colorperiod(int, optional): Duration of one triangle cycle in milliseconds. Defaults to1000msoffset(int, optional): Offset to adjust the phase. Defaults to0
Returns:
Color: The modulated color with the triangle effect applied
Comments