blinkstick-python icon indicating copy to clipboard operation
blinkstick-python copied to clipboard

Fix morphing in 'blinkstick.py'.

Open elnarte opened this issue 1 year ago • 0 comments

The current morphing implementation contains a dirty hack of descaling (including resetting the R,G,B values when they become larger than 255) because the method _determine_rgb() is called twice, once from morph() and a second time from set_color(). To prevent descaling, a part of the method set_color() has been separated into a private method _set_rgb() which is called both from set_color() and morph(). This also means that the functions _remap_rgb_value_reverse() and _remap_color_reverse() become obsolete. Additionally, applying color inversion has been moved to method _determine_rgb() just before applying max_rgb_value. This assures that first the proper R,G,B values are determined (inverted or not) and afterwards the proper brightness is determined. With this implementation, the morphing starts nicely at the current R,G,B values and gradually transitions towards the end R,G,B values.

elnarte avatar Jan 17 '24 16:01 elnarte