Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def strobe_color(brightness=100):
"""
Rapid flashing colors.
:param int brightness: The brightness of the transition.
:returns: A list of transitions.
:rtype: list
"""
transitions = [
HSVTransition(240, 100, duration=50, brightness=brightness),
HSVTransition(60, 100, duration=50, brightness=brightness),
HSVTransition(330, 100, duration=50, brightness=brightness),
HSVTransition(0, 100, duration=50, brightness=brightness),
HSVTransition(173, 100, duration=50, brightness=brightness),
HSVTransition(30, 100, duration=50, brightness=brightness),
]
return transitions
def christmas(duration=250, brightness=100, sleep=3000):
"""
Color changes from red to green, like christmas lights.
:param int duration: The duration between red and green, in milliseconds.
:param int brightness: The brightness of the transition.
:param int sleep: The time to sleep between colors, in milliseconds.
:returns: A list of transitions.
:rtype: list
"""
transitions = [
HSVTransition(0, 100, duration=duration, brightness=brightness),
SleepTransition(duration=sleep),
HSVTransition(120, 100, duration=duration, brightness=brightness),
SleepTransition(duration=sleep),
]
return transitions
def strobe_color(brightness=100):
"""
Rapid flashing colors.
:param int brightness: The brightness of the transition.
:returns: A list of transitions.
:rtype: list
"""
transitions = [
HSVTransition(240, 100, duration=50, brightness=brightness),
HSVTransition(60, 100, duration=50, brightness=brightness),
HSVTransition(330, 100, duration=50, brightness=brightness),
HSVTransition(0, 100, duration=50, brightness=brightness),
HSVTransition(173, 100, duration=50, brightness=brightness),
HSVTransition(30, 100, duration=50, brightness=brightness),
]
return transitions
def strobe_color(brightness=100):
"""
Rapid flashing colors.
:param int brightness: The brightness of the transition.
:returns: A list of transitions.
:rtype: list
"""
transitions = [
HSVTransition(240, 100, duration=50, brightness=brightness),
HSVTransition(60, 100, duration=50, brightness=brightness),
HSVTransition(330, 100, duration=50, brightness=brightness),
HSVTransition(0, 100, duration=50, brightness=brightness),
HSVTransition(173, 100, duration=50, brightness=brightness),
HSVTransition(30, 100, duration=50, brightness=brightness),
]
return transitions
def rgb(duration=250, brightness=100, sleep=3000):
"""
Color changes from red to green to blue.
:param int duration: The duration to fade to next color, in milliseconds.
:param int brightness: The brightness of the transition.
:param int sleep: The time to sleep between colors, in milliseconds
:returns: A list of transitions.
:rtype: list
"""
transitions = [
HSVTransition(0, 100, duration=duration, brightness=brightness),
SleepTransition(duration=sleep),
HSVTransition(120, 100, duration=duration, brightness=brightness),
SleepTransition(duration=sleep),
HSVTransition(240, 100, duration=duration, brightness=brightness),
SleepTransition(duration=sleep),
]
return transitions
def randomloop(duration=750, brightness=100, count=9):
"""
Color changes between `count` randomly chosen colors.
:param int duration: The duration to fade to next color, in milliseconds.
:param int brightness: The brightness of the transition.
:param int count: The number of random chosen colors in transition.
:returns: A list of transitions.
:rtype: list
"""
count = _clamp(count, 1, 9)
transitions = [HSVTransition(random.randint(0, 360), 100, duration=duration) for _ in range(count)]
return transitions
"""
Color changes to the beat.
:param int bpm: The beats per minute to pulse to.
:returns: A list of transitions.
:rtype: list
"""
duration = int(60000 / bpm)
transitions = [
HSVTransition(0, 100, duration=duration, brightness=100),
HSVTransition(0, 100, duration=duration, brightness=1),
HSVTransition(90, 100, duration=duration, brightness=100),
HSVTransition(90, 100, duration=duration, brightness=1),
HSVTransition(180, 100, duration=duration, brightness=100),
HSVTransition(180, 100, duration=duration, brightness=1),
HSVTransition(270, 100, duration=duration, brightness=100),
HSVTransition(270, 100, duration=duration, brightness=1),
]
return transitions
"""
Color changes from red to green to blue.
:param int duration: The duration to fade to next color, in milliseconds.
:param int brightness: The brightness of the transition.
:param int sleep: The time to sleep between colors, in milliseconds
:returns: A list of transitions.
:rtype: list
"""
transitions = [
HSVTransition(0, 100, duration=duration, brightness=brightness),
SleepTransition(duration=sleep),
HSVTransition(120, 100, duration=duration, brightness=brightness),
SleepTransition(duration=sleep),
HSVTransition(240, 100, duration=duration, brightness=brightness),
SleepTransition(duration=sleep),
]
return transitions
def strobe_color(brightness=100):
"""
Rapid flashing colors.
:param int brightness: The brightness of the transition.
:returns: A list of transitions.
:rtype: list
"""
transitions = [
HSVTransition(240, 100, duration=50, brightness=brightness),
HSVTransition(60, 100, duration=50, brightness=brightness),
HSVTransition(330, 100, duration=50, brightness=brightness),
HSVTransition(0, 100, duration=50, brightness=brightness),
HSVTransition(173, 100, duration=50, brightness=brightness),
HSVTransition(30, 100, duration=50, brightness=brightness),
]
return transitions
def strobe_color(brightness=100):
"""
Rapid flashing colors.
:param int brightness: The brightness of the transition.
:returns: A list of transitions.
:rtype: list
"""
transitions = [
HSVTransition(240, 100, duration=50, brightness=brightness),
HSVTransition(60, 100, duration=50, brightness=brightness),
HSVTransition(330, 100, duration=50, brightness=brightness),
HSVTransition(0, 100, duration=50, brightness=brightness),
HSVTransition(173, 100, duration=50, brightness=brightness),
HSVTransition(30, 100, duration=50, brightness=brightness),
]
return transitions