57 lines
1.9 KiB
Python
57 lines
1.9 KiB
Python
from colormath.color_objects import HSVColor, sRGBColor
|
|
from colormath.color_conversions import convert_color
|
|
import time
|
|
import math
|
|
|
|
def hsv_to_target(hsv, target):
|
|
rgb = [ x for x in convert_color(hsv, sRGBColor).get_upscaled_value_tuple() ]
|
|
target[0] = rgb[0]
|
|
target[1] = rgb[1]
|
|
target[2] = rgb[2]
|
|
|
|
def rainbow_whole(framecount, index, target):
|
|
current_degree = framecount % 360
|
|
hsv = HSVColor(current_degree, 1, 1)
|
|
hsv_to_target(hsv, target)
|
|
|
|
def rainbow_whole_offset_stat(framecount, index, target):
|
|
offset = index*90
|
|
current_degree = (framecount + offset) % 360
|
|
hsv = HSVColor(current_degree, 1, 1)
|
|
hsv_to_target(hsv, target)
|
|
|
|
def rainbow_whole_offset_dyn(framecount, index, target):
|
|
offset_hue_pixel = math.sin(framecount / 10000)*90*(index+1)
|
|
saturation_pixel = math.fabs(math.cos(framecount / 5000))*70
|
|
current_hue_degree = (framecount / 1000 + offset_hue_pixel) % 360
|
|
current_sat = (30+saturation_pixel) / 100
|
|
hsv = HSVColor(current_hue_degree, current_sat, 1)
|
|
hsv_to_target(hsv, target)
|
|
|
|
def two_colors(framecount, index, target, hue1, hue2):
|
|
saturation_pixel = 1
|
|
hue_min = min(hue1, hue2)
|
|
hue_max = max(hue1, hue2)
|
|
current_hue_degree = hue_min + (hue_max - hue_min) / 2 + math.sin(framecount / 400 + index*100)*(hue_max - hue_min)/2
|
|
current_sat = 1
|
|
hsv = HSVColor(current_hue_degree, current_sat, 1)
|
|
hsv_to_target(hsv, target)
|
|
|
|
def two_colors_red_blue(framecount, index, target):
|
|
two_colors(framecount, index, target, 210, 359)
|
|
|
|
def two_colors_red_red(framecount, index, target):
|
|
two_colors(framecount, index, target, 0, 30)
|
|
|
|
def two_colors_cyan_blue(framecount, index, target):
|
|
two_colors(framecount, index, target, 180, 240)
|
|
|
|
def two_colors_cyan_orange(framecount, index, target):
|
|
two_colors(framecount, index, target, 25, 180)
|
|
|
|
def black(framecount, index, target):
|
|
target[0] = 0
|
|
target[1] = 0
|
|
target[2] = 0
|
|
|