Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

rgb to hex conversion python

def rgb(r, g, b):
    # convert out of range values for r
    if r > 255:
        r = 255
    elif r < 0:
        r = 0
    # convert out of range values for g
    if g > 255:
        g = 255
    elif g < 0:
        g = 0
    # convert out of range values for b
    if b > 255:
        b = 255
    elif b < 0:
        b = 0
    #Return the hex values
    return ('{:02x}{:02x}{:02x}'.format(r,g,b)).upper()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #rgb #hex #conversion #python
ADD COMMENT
Topic
Name
4+4 =