Answers for "python color hex to rgb"

1

hex to rgb python

def hex2rgb(color):
  hex = color.lstrip('#')
  rgb = tuple(int(hex[i:i+2], 16) for i in (0, 2, 4))
  
  return rgb

hex_color = "#B4FBB8"
rgb_color = hex2rgb(hex_color)

print(rgb_color)
#(180, 251, 184)
Posted by: Guest on June-16-2021
0

python rgb to hex

# Convert RGB to HEX
rgb = (255,255,255) # ---------> pure white
print("#%02x%02x%02x" % rgb) # -----> #ffffff

#													- sabz
Posted by: Guest on July-14-2021
0

hex to rgb python

h = input('Enter hex: ').lstrip('#')
print('RGB =', tuple(int(h[i:i+2], 16) for i in (0, 2, 4)))
Posted by: Guest on March-13-2021
-2

rgb to hex python

import matplotlib

print(matplotlib.colors.to_hex([ 0.47, 0.0, 1.0 ]))
print(matplotlib.colors.to_hex([ 0.7, 0.321, 0.3, 0.5 ], keep_alpha=True))

print(matplotlib.colors.to_rgb("#aabbcc"))
print(matplotlib.colors.to_rgb("#ddee9f"))
Posted by: Guest on September-04-2020

Python Answers by Framework

Browse Popular Code Answers by Language