Skip to content

Commit a42ece2

Browse files
authored
Merge pull request #149 from FoamyGuy/tuple_int_fix_pr
convert tuple to hex color first
2 parents 3f945da + 74a2003 commit a42ece2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

displayio/_colorconverter.py

+7
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,15 @@ def _convert(
205205
self._cached_input_pixel = input_pixel.pixel
206206
self._cached_output_color = output_color.pixel
207207

208+
@staticmethod
209+
def _rgbtuple_to_hex(color_tuple):
210+
"""Convert rgb tuple with 0-255 values to hex color value"""
211+
return color_tuple[0] << 16 | color_tuple[1] << 8 | color_tuple[2]
212+
208213
@staticmethod
209214
def _convert_pixel(colorspace: Colorspace, pixel: int) -> int:
215+
if isinstance(pixel, tuple):
216+
pixel = ColorConverter._rgbtuple_to_hex(pixel)
210217
pixel = clamp(pixel, 0, 0xFFFFFFFF)
211218
if colorspace in (
212219
Colorspace.RGB565_SWAPPED,

0 commit comments

Comments
 (0)