set current rgb_color

This commit is contained in:
joBr99
2022-03-19 20:56:15 +01:00
parent 988fdb7d92
commit 65d277d120
2 changed files with 13 additions and 9 deletions

View File

@@ -1,9 +1,10 @@
import colorsys
import math
def hsv2rgb(self, h, s, v):
def hsv2rgb(h, s, v):
hsv = colorsys.hsv_to_rgb(h,s,v)
return tuple(round(i * 255) for i in hsv)
def pos_to_color(self, x, y):
def pos_to_color(x, y):
r = 160/2
x = round((x - r) / r * 100) / 100
y = round((r - y) / r * 100) / 100
@@ -15,10 +16,13 @@ def pos_to_color(self, x, y):
else:
sat = r
hsv = (math.degrees(math.atan2(y, x))%360/360, sat, 1)
rgb = self.hsv2rgb(hsv[0],hsv[1],hsv[2])
rgb = hsv2rgb(hsv[0],hsv[1],hsv[2])
return rgb
def rgb_dec565(red, green, blue):
def rgb_dec565(rgb_color):
red = rgb_color[0]
green = rgb_color[1]
blue = rgb_color[2]
# take in the red, green and blue values (0-255) as 8 bit values and then combine
# and shift them to make them a 16 bit dec value in 565 format.
print ((int(red / 255 * 31) << 11) | (int(green / 255 * 63) << 5) | (int(blue / 255 * 31)))
return ((int(red / 255 * 31) << 11) | (int(green / 255 * 63) << 5) | (int(blue / 255 * 31)))