python - How to color accurately convert from rgb 0-255 format to values in 0.0f-1.0f
Hex colors are in sRGB. You need linear colors. The conversion is (from here)
def color_srgb_to_scene_linear(c):
    if c &lt; 0.04045:
        return 0.0 if c &lt; 0.0 else c * (1.0 / 12.92)
    else:
        return ((c + 0.055) * (1.0 / 1.055)) ** 2.4

print(color_srgb_to_scene_linear(13/255))  # =&gt; 0.00402
print(color_srgb_to_scene_linear(105/255)) # =&gt; 0.14126
print(color_srgb_to_scene_linear(171/255)) # =&gt; 0.40724