How to turn color from get() function into an RGB value

I’m having the user pick a color to use in a generated artwork by clicking on a point on an image of a color wheel. This is my code:

def mousePressed():
if pick_color:
c = get(mouseX, mouseY)
pick_color = False
startscreen = True

For example, if I click on a pink color, c returns -1888365. I can plug color(-1888365) in my function and it works as it should but the problem is that I’m trying to fade between colors. So if the color were normally expressed as (255, 51, 153) in RGB colors, I could make the first layer (255, 51, 153), the second layer (127, 26, 76), and the third layer (0, 0, 0), so the colors would fade from black to pink. However, when the value is expressed as -1888365, it makes it impossible to do this. Any idea how the get() function works and how I can transform it into RGB? This page says it should return an RGB value by default but it doesn’t.

Welcome @perrywinkle

You can use the red(), green(), blue() functions to extract the RGB values:

background(255, 200, 10)
c = get(10, 10)
print(red(c))    # 255.0
print(green(c))  # 200.0
print(blue(c))   # 10.0
1 Like