I need to figure out how to get the RGB values of the current active color (like a reverse version of IColorSet). I’ve had a hunt through the documentation, but luck does not seem to be on my side. Has anyone come across anything that could retrieve the RGB values I’m after?
One way is to use [IGet,Color:R], [IGet,Color:G] and [IGet,Color:B
] to get the values of the R, G, B sliders in the Color palette. You can use that method for getting the values from any interface item - hold the cursor over the item and press Ctrl: the “button path” will appear in gray at the bottom of the pop-up.
Alternatively you can use the Main Color which is stored as combined RGB divided by 65536:
[IButton,GetRGB,"Get R, G & B values",
[VarSet,col,[IGet,Color:MainColor]] //stored as (combined RGB/65536)
[VarMul,col,65536]
[VarSet,R,INT(col/65536)]
[VarSub,col,R*65536]
[VarSet,G,INT(col/256)]
[VarSub,col,G*256]
[VarSet,B,col]
[Note,[StrMerge,"R = ",#R,"\nG = ",#G,"\nB = ",#B]]
]
HTH,
Marcus
1 Like
Perfect. Thanks so much for this!