colors - Find colour based on brightness in python -
Given a certain amount of brightness (for example, 0 to 255), there is an algorithm in which to obtain an RGB What is its color?
This will work where 0 is black, 255 is white and all other colors are kept between them.
The standard library module in Python is. What do you want; So your "brightness" is the luminance value used by the module is 0..1 for each component. [Notice that the standard order is HSL, while in Python it is H LS ]
Thus to get completely saturated red color for different luminances, you
can colorys hue = 0.0 # 0 red saturation = 1.0 # saturated range (0, 10, 1) for fully luminance: R, G, B = Calls. HSLTORRGB (HEE, Luminance / 10.0, Saturation) Print ('{:}}}, {: D}, {: D}'. Format (int * R5), int (g * 255), int (b * 255) )) Results in
0, 0, 0, 0, 0 102, 0, 0 153, 0, 0 204, 0, 0 255, 0, 0 255, 50, 50 255, 101, 101 255, 153, 153 254, 204, 204 255, 255, 255
Similarly, the same brightness for the entire spectrum To get the color, keep the brightness and saturation continuous and change the color from 0 to 1.
Comments
Post a Comment