mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-02-23 13:02:14 +01:00
fix brightness scale
This commit is contained in:
@@ -29,7 +29,7 @@ def pos_to_color(x, y):
|
|||||||
def rgb_brightness(rgb_color, brightness):
|
def rgb_brightness(rgb_color, brightness):
|
||||||
# brightness values are in range 0-255
|
# brightness values are in range 0-255
|
||||||
# to make sure that the color is not completly lost we need to rescale this to 70-255
|
# to make sure that the color is not completly lost we need to rescale this to 70-255
|
||||||
brightness = int(scale(entity.attributes.brightness,(0,255),(70,255)))
|
brightness = int(scale(brightness,(0,255),(70,255)))
|
||||||
red = rgb_color[0]/255*brightness
|
red = rgb_color[0]/255*brightness
|
||||||
green = rgb_color[1]/255*brightness
|
green = rgb_color[1]/255*brightness
|
||||||
blue = rgb_color[2]/255*brightness
|
blue = rgb_color[2]/255*brightness
|
||||||
@@ -41,4 +41,4 @@ def rgb_dec565(rgb_color):
|
|||||||
blue = rgb_color[2]
|
blue = rgb_color[2]
|
||||||
# take in the red, green and blue values (0-255) as 8 bit values and then combine
|
# 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.
|
# and shift them to make them a 16 bit dec value in 565 format.
|
||||||
return ((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)))
|
||||||
|
|||||||
Reference in New Issue
Block a user