From e780a65007296384bbde8687fc328c9138744ac8 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Sun, 5 Jul 2020 23:06:25 +0200 Subject: [PATCH] api/_common/ColorLight: change rgb to hsv This makes it much easier to have fine grained control over colors and cycle through them easily (0--360). This also makes it consistent with sensor APIs. Now you can measure the color and plug it into this method. We can make this change because none of the implementations use this yet. If we feel we miss out by dropping the RGB, it would be more fitting to instead expose R, G, and B attributes which point to instances of the Light class. However, this is using more memory for something that isn't very useful. We could also just provide generic color converters between rgb, hsv, and perhaps hex html color strings, not tied to any particular light or sensor. --- pybricks/_common.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pybricks/_common.py b/pybricks/_common.py index e01380f..7185a33 100644 --- a/pybricks/_common.py +++ b/pybricks/_common.py @@ -440,13 +440,13 @@ class ColorLight: """Turns off the light.""" pass - def rgb(self, red, green, blue): - """Sets the brightness of the red, green, and blue light. + def hsv(self, hue, saturation=100, value=100): + """Set the hue, saturation and brightness of the light. Arguments: - red (:ref:`brightness`): Brightness of the red light. - green (:ref:`brightness`): Brightness of the green light. - blue (:ref:`brightness`): Brightness of the blue light. + hue (:ref:`angle`): Hue of the color. + saturation (:ref:`percentage`): Saturation of the color. + value (:ref:`percentage`): Brightness value of the color. """ pass