Runtime gradient coloring

The Undaddy

Creating with the power of rage
Reaction score
55
I want to color a text tag which says "Reloading" depending on the progress of the unit's reload.The color I want ranges from red to green and I have the factor of completion (Elapsed Reload Time/Reload Time). That is all well but I have no clue how to go with the coloring part, any ideas?
 

Frozenwind

System maker
Reaction score
99
So basically, you want a text to slowly move to green from red over-time, or am I misreading it?
 

The Undaddy

Creating with the power of rage
Reaction score
55
Sorry, completely forgot about posting this :D. Yes, that is exactly what I want.
 

Frozenwind

System maker
Reaction score
99
Do you know anything about hexadecimals? I mean, the calculation of decimal --> hexadecimal.

Cos basically, a colorcode works like this:
(TT = transparacy - not always used)RRGGBB

Basically, you'll need to put BB to 00.
Red should start at FF and Green at 00.
Now, slowly increase the green's decimal value until it arrives at (16*16¹ + 16*16^0 = 272).
Red should start at 272 (=FF) and slowly be reduced to 0 (=00).

To add the color to your string, you'll need to use "concentrated strings" or something like that, to merge multiple strings.

If you don't know any of the calculations, just ask, but if you know it, I'd rather not work it out :p
Also, please note: you'll need "00", not "0", so make sure you build in something to make 0-F a 00-0F.



Make a string "012345679ABCDEF" which you can call to determine what value you need to write down in your string.
Now, if you have your decimal value, called X. Loop through it.
Code:
locals: integerA integerB integerC
code:
IntegerA = your decimal value
IntegerB = IntegerA
IntegerC = 0
While Integer B>0
    set integerB = integer B - 16
    set integerC = integerC + 1
set integerB = integerB + 16
"your first out of 2 characters needed is integerC" <-- substring integerC,integerC in the 0123..DEF string.
"your second out of 2 characters needed is (integerB+1)"
 

The Undaddy

Creating with the power of rage
Reaction score
55
Well yes, I know about hexadecimals and conversion (for example FF = 15*16 + 15*1 = 255 :p ), but what I still don't understand is what exactly is the format of the color code. I couldn't get anything from your example - what exactly is 'my decimal value' is a mystery to me :D

I feel though I should say, I figured out how to do what I wanted in the first place [in a different, GUI-ish way], but I'd like to know how the color codes in SC2 work (or are they the same as in wc3, with the |c and |r) ?
 

LightStriker

New Member
Reaction score
1
Well yes, I know about hexadecimals and conversion (for example FF = 15*16 + 15*1 = 255 :p ), but what I still don't understand is what exactly is the format of the color code. I couldn't get anything from your example - what exactly is 'my decimal value' is a mystery to me :D

I feel though I should say, I figured out how to do what I wanted in the first place [in a different, GUI-ish way], but I'd like to know how the color codes in SC2 work (or are they the same as in wc3, with the |c and |r) ?

Just use the Color class. ;)
 

Frozenwind

System maker
Reaction score
99
"your decimal value" would be
CurrentTimePassed/TotalTime * (16²-1 = 255) for green
(16²-1 = 255) - CurrentTimePassed/TotalTime * (16²-1 = 255) for red


If you go to the text editor and choose a color for the text you typed in (just type something random), you'll see he places a colorcode around your text. This looks something like <c...>, not sure how exactly it is.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top