NSColor to RGB values

Hi,

I’m currently writing a script with UI that has a couple of options to select foreground and background colors.
While building the UI, I’m using ColorWell from vanilla and it returns an NSColor:

'Foreground color:', NSCalibratedRGBColorSpace 1 0 0 1

I can understand this color is 100% red, 0% green and 0% blue but I’m not very familiar with NSObjects and, since I want to assign the new value to another place I would like to convert this to a list of three values (f.e. [R,G,B]).

Any tip on how to convert NSColors to RGB values?

Thanks!

IIRC, the fourth value is transparency.

You might like to get a bit familiar to the Apple documentation: https://developer.apple.com/documentation/appkit/nscolor?language=objc
And to understand objectiveC a bit, this might help: https://pyobjc.readthedocs.io/en/latest/core/intro.html

1 Like