Color help with SetLabelColor

Hello,

I’ve been struggling with understanding how the integer is determined with this function. Is there a reference or list for colors?

For example, I’m after blue FF406AFF / 40,6A,FF,FF. And a lite purple FFE040FF / E0,40,FF,FF If I’m converting how I think I should I use
SetLabelColor(myLabelWidget, -41920) but I get a orangish color. Would anyone help me understand how RGBA is being converted? Or if you know the int to use for Blue and Purple?

There are functions to convert RGBA-Hex values to Integer and vice versa:
RGBToColor (red : double, green : double, blue : double, alpha : double) returns Integer
and
ColorToRGB (color : Integer, RGBA : double Array)

…and assuming you would like to change the fill color of your label, you’d have to use the function SetWidgetFillColor() rather than the SetLabelColor() which changes a widget’s text color (this is unfortunately quite a bit missleading).

So after all, you’ll have to combine both functions for a proper result:
SetWidgetFillColor(myLabelWidget, RGBToColor(0xFF, 0x40, 0x6A, 0xFF))
(the “0x” prefix is used to use hex-letter-values as numbers)

Oh… and i moved this topic over to the “Scripting with Gig Performer” sub forum.

1 Like

Ok, thank you. I am trying to change the font color. Sorry I didn’t make that more clear.

I’ve tried a few ways you indicated. but I keep ending up with white. Here’s what I’m trying. RGBToColor(0xFF, 0x40, 0x6A, 0xFF), it sets the font at FFFFFFFF no matter the value. The purple change, where I’ve given an int that I’ve kinda lowkey guessed at, I get a purple FFB024FE. My goal is to swap the font colors depending on which amp is active. They happen to be called Blue and Purple. These are slider widgets(GRAspk) and (GRAamp). I’m also updating the name on the label at the sametime(which works as intended it’s figuring out which speaker cab of 10 available is in use and setting it as a 1,2,3, etc on the label). Any advice would be appreciated. Here’s my current code:

On WidgetValueChanged(w : Widget, index : Integer, newValue : Double) from GRAspk //Set all SPEAKER slider widget names. Coming from the APC button or from the amp will trigger this.
GRAdetectAmpAndSpeaker()//Set DSP name.
// Update all speaker labels
If GetWidgetValue(GRAamp) == 0 Then
SetWidgetLabel(GRAspk, "GRAPHENE BLUE SPEAKER: " + (Round(GetWidgetValue(GRAspk)/(1.0/10)) + 1))
SetWidgetFillColor(GRAspk, RGBToColor(0xFF, 0x14, 0x51, 0xE3))//added this at your suggestion does not change fill color.
SetLabelColor(GRAspk, RGBToColor(0xFF, 0x14, 0x51, 0xE3))//attempting for blue
Elsif GetWidgetValue(GRAamp) == 1 Then
SetWidgetLabel(GRAspk, "GRAPHENE PURPLE SPEAKER: " + (Round(GetWidgetValue(GRAspk)/(1.0/10)) + 1))
SetLabelColor(GRAspk, -5233410 )//purplethat gives FFB024FE
End
End

This is a more clean version, just trying to show the basics. Attempt at blue gives white, and attempt at purple gets pretty close. But I have no idea how that number is getting the value’s it’s setting. So I can’t get the exact colors I’m looking for.

On WidgetValueChanged(w : Widget, index : Integer, newValue : Double) from GRAspk
If GetWidgetValue(GRAamp) == 0 Then
SetLabelColor(GRAspk, RGBToColor(0xFF, 0x14, 0x51, 0xE3))//attempting for blue
Elsif GetWidgetValue(GRAamp) == 1 Then
SetLabelColor(GRAspk, -5233410 )//purple gives FFB024FE
End
End

The exact colors I would like are

Two things to mention (with no offense):

  1. We only can know and see what you are showing or telling - so giving just snippets or beeing unclear or unprecise about what you are trying to do, makes it difficult to help.
    The best option will always be to just upload a gig file where everything is at hand to locate an issue.
  2. If you have a closer look at your screenshots, you might notice that the combined hex-value in the color field has the alpha-value at the beginning (opposite to the sequence of sliders)
    So in that blue screenshot the whole value reads “FF 14 51 E3” but the value sliders (top to bottom) read “14 51 E3 FF
    Maybe that’s the whole issue you are facing?
    I don’t actually know, because 1) :wink:
1 Like

I understand. I’ve attached the gig file. The lines of code are between 478 and 492. I am very new to scripting and writing code. I’ve only been at it for about 2 months. So I’ve made a lot of notes to help myself out in remembering what things do. I have a APC mini configured as well to handle a lot of button presses and led color changes on the APC.

You’ll see on the panel page under Graphene rack they are two slider widgets and two buttons. You should be able to press the Graphene Amp selector button to change between Blue and Purple Amp(the label will update). When you then press the Graphene Speaker Selector button, this should change the font color of the speaker slider and the label’s name to reflect the speaker in use. I have not yet implemented the font color change on the amp slider. I’m sorry for the confusion on the way I indicated the color. GP shows it two different ways. One is ARGB, and the sliders show RGBA. I did try both ways with the same result.

Currently I set it back to what was working. Manually giving an int value. But I’d like to understand how to do it by properly converting the RGBA in the scripting so I can give an exact color. And sending that value to the font color of GRAspk and GRAamp labels.

But I’m unable to get the code you gave to work. What would help me greatly, is first understanding which way RGBA, ARGB I need to use. Second, understanding how to correctly write that the script that will convert to an int.

Thank you for your time.

WIP 11-7-25.gig (1.6 MB)

Ah… i just tried my example i proposed to you, and i noticed that it won’t work the way i hoped it would. I was a bit in a hurry and only did a quick test with a widget, when i just saw that there was a change in color, i thought “ok that’s it!” - but actually it wasn’t at all what i wanted to achieve.
The problem is that the RGBToColor() function expects double values (0-1.0) but in my example i threw in integers (0-255)… so every value above 1 is interpreted as 1.0 and so there’s that unwanted result. Sorry for leading you on a wrong path. :pensive_face: :innocent:

As a possible work around (to get the RGB-decimal you actually need) i tell you how i do that:
I place a widget on the panel, set the desired color in it’s properties and then print out its RGBA-decimal value via GP script:
Print(GetLabelColor(myWidgetLabel))
Then copy that value from the log window and use it (i.e. as a constant) in your script.
I guess, that might be the easiest way to get this RGBA-code.

I also try to provide a script that will work, but it still might take some minutes.

…hope that helps. :clinking_beer_mugs:

Thanks for uploading your gig file - i will also have a closer look at it soon (not much time atm)

1 Like

This works! At least for getting the correct int value. Thank you so much! If you do have time to review my gig file, and offer suggestions on how to code in to the script that would be great. But I understand if you don’t. Having a reliable way to get the value is all that really matters!

1 Like

You’ve made my night!

2 Likes

Ok… this issue actually kept me a bit busy. :smiley:

I wrote two user functions to help script users to set a widget’s (fill) color.
The script can easily be adapted for other color-set functions.

This is the script:

var
myLabel : widget

//user function to convert single hex byte values to double values 0-1.0
//example: SetWidgetFillColor(myLabel, RGBToColor(HexToDouble(0x00), HexToDouble(0xff), HexToDouble(0x00), HexToDouble(0xFF)))
function HexToDouble(HexValue : Integer) returns double
    result = Scale(IntToFloat(HexValue), 0.0, 256.0, 0.0, 1.0)
End

//user function to set a widget's fill color according to a RGBA-Hex string
// the RGBA-Hex string must have 8 digits - one byte for R/G/B/Alpha - no separators allowed
function SetRGBAHexWidgetFillColor (tgtWidget: widget, RGBAString : string)
var
index : integer //just a counter
hexDbl : double //variable to hold the current byte value in double type
hexSingleL, hexSingleU : integer //variables to get the lower and upper digit of a byte
dblR, dblG, dblB, dblA : double //variables to hold the R/G/B/A values in double type


if Length(RGBAString)==8 then//checke if the HEX-String has 8 digits
    for index=1; index<8; index = index +2 Do //step through the whole string by pairs
        hexSingleU=StringToInt(StringToHexString(CopySubstring(RGBAString, index-1, 1)))-30//upper byte digit
        hexSingleL=StringToInt(StringToHexString(CopySubstring(RGBAString, index, 1)))-30//lower byte digit
        hexDbl = hexSingleL + hexSingleU*15//calculate the whole byte value as double
        
        Select//according to the string position extract the R/G/B/A values into separate variables, scaled to double type (0-1.0)
            index==1 do dblR=Scale(IntToFloat(hexDbl), 0.0, 256.0, 0.0, 1.0)
            index==3 do dblG=Scale(IntToFloat(hexDbl), 0.0, 256.0, 0.0, 1.0)
            index==5 do dblB=Scale(IntToFloat(hexDbl), 0.0, 256.0, 0.0, 1.0)
            index==7 do dblA=Scale(IntToFloat(hexDbl), 0.0, 256.0, 0.0, 1.0)
        end
    end

    SetWidgetFillColor(tgtWidget, RGBToColor(dblR, dblG, dblB, dblA))//set the target widget's fill color according to the analyzed hex-string
end

End

// Called automatically after script is loaded
Initialization
//set the widget's fill color by using the byte wise conversion
//SetWidgetFillColor(myLabel, RGBToColor(HexToDouble(0x00), HexToDouble(0xff), HexToDouble(0x00), HexToDouble(0xFF))) 

//set the widget's fill color by using the "complete package" :-)
SetRGBAHexWidgetFillColor(myLabel,"FFFFAABB")
End

I guess the comments in the code will be self-explanatory.

Here is the corresponding gig file to see how it works:
widget_color-user_functions.gig (27.5 KB)

Maybe this is useful for other users as well…

3 Likes