fix asyncio calling, accept changes before mutating

This commit is contained in:
2021-04-02 21:27:58 +02:00
parent e6e63efb3f
commit 7556deede0
4 changed files with 58 additions and 41 deletions

View File

@@ -3,22 +3,22 @@ from colormath.color_conversions import convert_color
import time
import math
def rainbow_whole(framecount, index, target):
current_degree = framecount % 360
hsv = HSVColor(current_degree, 1, 1)
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)
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]
hsv_to_target(hsv, target)
def rainbow_whole_offset_dyn(framecount, index, target):
offset_hue_pixel = math.sin(framecount / 10000)*90*(index+1)
@@ -26,10 +26,7 @@ def rainbow_whole_offset_dyn(framecount, index, target):
current_hue_degree = (framecount / 1000 + offset_hue_pixel) % 360
current_sat = (30+saturation_pixel) / 100
hsv = HSVColor(current_hue_degree, current_sat, 1)
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]
hsv_to_target(hsv, target)
def two_colors(framecount, index, target, hue1, hue2):
saturation_pixel = 1
@@ -38,10 +35,7 @@ def two_colors(framecount, index, target, 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)
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]
hsv_to_target(hsv, target)
def two_colors_red_blue(framecount, index, target):
two_colors(framecount, index, target, 210, 359)
@@ -54,3 +48,9 @@ def two_colors_cyan_blue(framecount, index, target):
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