Changing Font color with script, how to?

#1
Hi, I want to change the fontcolor with script depending on a lvar value.
What I have:

XML:
<?xml version="1.0" encoding="UTF-8"?>
<Gauge Name="BaroDisp">
<Image Name="BaroDisp.bmp"/>
<Element>
<Visible>(L:Avail, number) 1 ==</Visible>


   <Element>
       <Position X="10" Y="12"/>
       <Text X="123" Y="35" Length="6" Fixed="Yes" Font="Digit" FontSize="38" Attributes="Bold" Color="#C86B20" BackgroundColor="transparent" HilightColor="white" Bright="Yes" UseTransparency="Yes">
           <String>%((A:KOHLSMAN SETTING MB, millibars) near)%!4d!</String>
       </Text>
   </Element>

</Element>
</Gauge>
Do I have to use for Color a macro? Or should I use ColorScript if existing?

That is the part I want to combine with the upper TextElement.

XML:
(L:DISPLAY_Rotary, number) 0 == if{ #FF0000 }
(L:DISPLAY_Rotary, number) 1 == if{ #FF0B00 }
(L:DISPLAY_Rotary, number) 2 == if{ #FF1600 }
(L:DISPLAY_Rotary, number) 3 == if{ #FF2000 }
(L:DISPLAY_Rotary, number) 4 == if{ #FF2B00 }
Can someone give me a hint, please?
 
#2
Code:
  <Element>
    <Position X="22" Y="162"/>
    <FormattedText X="210" Y="66" Luminous="Yes" Font="glassga"
         Tabs="0,120C" Color="0xD0D0D0" FontSize="26" Adjust="left" >
    <Color Value="yellow"/>
    <Color Value="Orange"/>
    <Color Value="red"/>
    <Color Value="#0099FF"/>   <!-- Light blue -->
    <String>
      %((L:DISPLAY_Rotary, number) 0 ==)
      %{if}
        %\{clr3}   <!-- clr3  is orange -->
      %{end}
     % your text
      %\{clr1}   <!-- reset color -->

   ... and so on......

    </String>
    </FormattedText>
  </Element>
just an excerpt from a gauge. Adapt it to your needs.
Hope everything is clear..
 
#3
another solution


Code:
        %((L:DISPLAY_Rotary, number))%{case}%{:0}%\{clr1}%{:1}%\{clr2}%{:2}%\{clr3}%{:3}%\{clr4}%{:3}%\{clr5}%{end}%
 

JB3DG

Resource contributor
#5
If you use ColorScript, you can dynamically change colors by multiplying each individual channel intensity by any desired factor, and then using the bit shift and bitwise OR operators to combine them into the final BGR color.
 
#6
Hi, I have a solution. Here is what I'm using now:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<Gauge Name="BaroDisp">
<Image Name="BaroDisp.bmp"/>

<Macro Name="DigitColor">%('#9F5810' '#9C5815' '#98591A' '#955A1F' '#915B24' '#8D5B29' '#8A5C2E' '#865D33' '#835D38' '#7F5E3D' '#7B5F42' '#785F47' '#74604C' '#716151' '#6D6256' '#69625B' '#666360' '#626465' '#5F646A' '#5B656F' 20 (L:DISPLAY_Rotary, number) case)</Macro>

<Element>
<Visible>(L:Avail, number) 1 ==</Visible>

   <Element>
       <Position X="10" Y="12"/>
       <Text X="123" Y="35" Length="6" Fixed="Yes" Font="Digit" FontSize="38" Attributes="Bold" Color="@DigitColor" BackgroundColor="transparent" HilightColor="white" Bright="Yes" UseTransparency="Yes">
           <String>%((A:KOHLSMAN SETTING MB, millibars) near)%!4d!</String>
       </Text>
   </Element>

</Element>
</Gauge>
 
Top