Jump to content
bumyplum

ctrlSetBackgroundColor RGB

Recommended Posts

Using ctrlSetBackgroundColor Is there a way to set the color as an rgb format instead of [0,0,0,1] for example, i'd prefer _RGB = ["#(rgb,8,8,3)color(%1,%2,%3,%4)",_RED,_BLUE,_GREEN,_BRIGHT];  but i'm unable to get it to work, can someone explain if it's possible how i'm going wrong?

Share this post


Link to post
Share on other sites

_display = findDisplay 46 createDisplay 'RscCredits';
_ColorBlock = _display ctrlCreate ["RscBackground",123];  
_ColorBlock ctrlSetPosition [0.667 * safezoneW + safezoneX,0.1585 * safezoneH + safezoneY,0.10 * safezoneW,0.299 * safezoneH];  
_ColorBlock ctrlCommit 0; 

_RED = 70;
_BLUE = 90;
_GREEN = 50;
_BRIGHT = 70;
_RED = _RED  /100;
_BLUE = _BLUE / 100;
_GREEN = _GREEN / 100;
_BRIGHT = _BRIGHT /100;
_Color = [_RED,_BLUE,_GREEN,_BRIGHT];
_ColorBlock ctrlSetBackgroundColor _Color;  


This is an example, the script above works. I'd like to replace it with 
_Color =  ["#(rgb,8,8,3)color(%1,%2,%3,%4)",_RED,_BLUE,_GREEN,_BRIGHT]; 
So i can display the colour brightness how ever i don't seem to know how to get it to work
Note: _RED =70; Would be replaced with a variable etc..

Share this post


Link to post
Share on other sites

As stated in https://community.bistudio.com/wiki/ctrlSetBackgroundColor, _colour has to be an array in the format of colour [R,G,B,A]. Could you get away with using:

 

_RED = 0.7;
_BLUE = 0.9;
_GREEN = 0.5;
_ALPHA = 0.7;

_control ctrlSetBackgroundColor [_RED,_BLUE,_GREEN,_ALPHA];

 

The values are all between 0....1, so a value of 255 for any of the colours would be 1, and the alpha value is for transparency, so 0 being fully transparent and 1 being solid. At most you'd just have to run some simple maths to get the required values, depending on where those values are coming from.

Share this post


Link to post
Share on other sites

Huh I don't know what advantage that gives you but try the RscPicture as a control base class and then use

_ctrl ctrlSetText "#(rgb,8,8,3)color(1,0,0,1)";

 

Share this post


Link to post
Share on other sites
11 hours ago, bumyplum said:

"#(rgb,8,8,3)color(%1,%2,%3,%4)"

As @7erra says this format makes little sense as this is a procedural texture format, to be used where something needs a texture not a color.

 

As  @beno_83au says a color in Arma is a 0-1 value for each R,G,B and A so just divide your value by 255.

_display = findDisplay 46 createDisplay 'RscCredits';
_ColorBlock = _display ctrlCreate ["RscBackground",123];  
_ColorBlock ctrlSetPosition [0.667 * safezoneW + safezoneX,0.1585 * safezoneH + safezoneY,0.10 * safezoneW,0.299 * safezoneH];  
_ColorBlock ctrlCommit 0; 

_RED = 70;
_BLUE = 90;
_GREEN = 50;
_ALPHA = 70;

_Color = [_RED/255,_BLUE/255,_GREEN/255,_ALPHA/255];
_ColorBlock ctrlSetBackgroundColor _Color;  

Or I even made a ui to help convert color formats HERE.

  • Like 2

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×