Alright so the best way I can really explain this is on this site https://www.colorspire.com/rgb-color-wheel/ there is a color wheel when you first load the site don't move the little pointer in the square to select stuff. Just go to the bar that you can drag and drag it you'll see the r g b
values change but you will also notice that one of the values is always 0, how can I recreate that but instead of the bar you drag you input a single 8 bit value (out of 255) so I can run the program with the value lets say 170 and it would somehow map that to a certain color.
Asked
Active
Viewed 573 times
-1

Quintin Dunn
- 25
- 6
2 Answers
0
You are actually changing the hue when you move the bar so try this
import colorsys
color = input("Enter a value from 0-359:")
test_color = colorsys.hsv_to_rgb(color/360.0, 1, 1)
References

talhoid
- 61
- 9
-
Thats kinda what I want, I want the input to be out of 255, and instead of each value being out of 1 they need to be out of 255 – Quintin Dunn Dec 13 '20 at 17:19
-
Yeah but that's not how hue works. The color bar is a number from 0-359 not 1-255. (RGB is from 1-255) – talhoid Dec 13 '20 at 17:22
-
I just multiplied each value by 255 then did math.trunc() – Quintin Dunn Dec 13 '20 at 17:29
-
And I made it more specific just now by instead of doing "test_color = colorsys.hsv_to_rgb(int(value)/360.0, 1, 1)" I did " test_color = colorsys.hsv_to_rgb(int(value)/255.0, 1, 1)" – Quintin Dunn Dec 13 '20 at 17:31
-
yes, and that was just my code while testing it I shortened it down. – Quintin Dunn Dec 13 '20 at 22:43
0
test_color = colorsys.hsv_to_rgb(int(value)/255.0, 1, 1)
r, g, b = test_color
r = (r * 255)
r = math.trunc(r)
g = (g * 255)
g = math.trunc(g)
b = (b * 255)
b = math.trunc(b)
fg.orange = Style(RgbFg(r, g, b))
msg = fg.orange + str(f" r = {r}, g = {g}, b = {b}")
print(msg)

Quintin Dunn
- 25
- 6