![]() ![]() the color wheel consists of 6 sectors. Bri and Sat must be values from 0-1 (~percentage) There also shall be a class method GetRGB that delivers common RGB values. The HSB object delivered can be directly used for the hue lamp. Hue = 4 + (r - g) / delta // between magenta & cyan Hue = 2 + (b - r) / delta // between cyan & yellow Hue = (g - b) / delta // between yellow & magenta public HSB GetHSB()Īnd this are the methods for conversion itself: private float GetHue() There shall be a class method GETHSB() that will deliver the HSB value for the hue lamp. Public static float Min(params float numbers) Public static float Max(params float numbers) Public static bool AlmostEquals(this float a, float b, double precision = float.Epsilon) /first value ///second value ///optional, smallest possible double value /// / Tests equality with a certain amount of precision. I will add some additional extensions for float and numbers to keep the code as simple as possible. To make the code as clean as possible I want to make class methods for each RGB and HSB. To make it easy to follow i want to make my own classes RGB and HSB like the following (the values can easily be parsed to a inbuilt. So it is necessary to convert form RGB/HEX to HSB vice versa. To use for example a WPF colorcanvas to set the color on your hue lamp and receive the color from the hue lamp again to display it in your colorcanvas a little color conversion is needed.Ĭommon colorpickers/canvas work on the RGB/HEX color system. The hue lamps HSB is a little bit different: Brightness/Value from 0 – 1 with floating point.Saturation from 0 – 1 with floating point.In generall HSB/HSV consists of these components: This color system is very hard to display in a canvas cause of the proportions of the xy values. The hue lamp can display colors out of two colorsystems: HSB/HSV and CIE 1931 xyY, while xyY consists of two values from 0-1 with floating point that display a point on the color systems color palette. But to understand why i did this and how it works i want to give you a little bit of background information to this topic. To demonstrate the correct conversion from HSB to RGB in case of hue lamps I will show you some code out of a little sample programm of mine. ![]()
0 Comments
Leave a Reply. |