arvydas / blinkstick-python

BlinkStick Python interface to control devices connected to the computer
Other
136 stars 53 forks source link

Fix morphing in 'blinkstick.py'. #93

Open elnarte opened 10 months ago

elnarte commented 10 months ago

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.