Graphics

 View Only
Expand all | Collapse all

Change font color in XPN 10

  • 1.  Change font color in XPN 10

    Posted 08-26-2022 14:35
    Hi all!
    Sorry if this has been answered before also I'm new to Xpression 10.

    I want my font color to change based on a particular element being visible.

    Example: A gas prices graphic. When the up arrow is visible the font displaying the price would be red and when the down arrow is visible the color would be green.

    Is this possible? And how would I set up the change?

    ------------------------------
    Lee Mann
    WAKA 8
    ------------------------------


  • 2.  RE: Change font color in XPN 10

    Ross Staff
    Posted 08-26-2022 14:54
    Hey,

    Probably the simplest way is visual logic. 

    In my example based on if the quad is visible or not the material changes. 





    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 3.  RE: Change font color in XPN 10

    Posted 08-29-2022 04:05
    Hey!
    Try another method.
    First: Create three fonts: green, red and blue (blue if the price does not change)
    Second: Set the script to "OnOnline" and "OnPreviewRender".
    Dim up, down As xpBaseObject
    self.GetObjectByName("Up", up)
    self.GetObjectByName("Down", down)
    Dim txt As xpTextObject
    self.GetObjectByName("Text1", txt)
    If up.Visible Then
        txt.Text = "{1}" + txt.Text '{1} - green font ID
    ElseIf down.Visible Then
        txt.Text = "{2}" + txt.Text '{2} - red font ID
    Else
        txt.Text = "{3}" + txt.Text '{3} - nochange font ID
    End If​


    ------------------------------
    Roman Yaroshenko
    chief specialist
    RBC-TV
    Moscow Russian Federation
    ------------------------------



  • 4.  RE: Change font color in XPN 10

    Ross Staff
    Posted 08-29-2022 08:49
    You can also use {M:Material Name} such as {M:Blue} to apply a material instead of making separate fonts.

    This way you just have 1 white font and can switch face materials instead. 

    So you could have same as Roma but instead of  
    txt.Text = "{1}" + txt.Text '{1} - green font ID​

    you could have 
    txt.Text = "{M:Green} + text.Text



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 5.  RE: Change font color in XPN 10

    Posted 08-29-2022 10:36
    Hi Red.
    It's great. I didn't know about this feature. May I ask you? Where can I see all functions for text like this?

    ------------------------------
    Roman Yaroshenko
    chief specialist
    RBC-TV
    Moscow Russian Federation
    ------------------------------



  • 6.  RE: Change font color in XPN 10

    Ross Staff
    Posted 08-29-2022 10:56
    I'm not actually sure where they are listed, I found that one in the changes log that you can find in the install folder.

    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 7.  RE: Change font color in XPN 10

    Posted 08-29-2022 11:15
    Thank you!

    ------------------------------
    Roman Yaroshenko
    chief specialist
    RBC-TV
    Moscow Russian Federation
    ------------------------------



  • 8.  RE: Change font color in XPN 10

    Posted 08-30-2022 10:27
    You could try the Help File (F1) ;-). When you search on "macro" you will find other options as well you could use!

    ------------------------------
    Rob van Rooyen
    Senior Graphics Specialis
    NEP The Netherlands
    Hilversum Netherlands
    ------------------------------



  • 9.  RE: Change font color in XPN 10

    Posted 08-30-2022 10:36
    Hi Rob.
    Thank you.

    ------------------------------
    Roman Yaroshenko
    chief specialist
    RBC-TV
    Moscow Russian Federation
    ------------------------------



  • 10.  RE: Change font color in XPN 10

    Posted 08-30-2022 11:27
    Thanks for the helpful information!
    I was able to achieve the desired results with both options.
    I was very excited when I got the Visual Logic to work the way I wanted. This was my first attempt at using Visual Logic.
    I have included my scripting and VL in case someone comes along down the road with a similar need.

    Thanks again!

    ------------------------------
    Lee Mann
    On Air Director
    WAKA 8
    ------------------------------



  • 11.  RE: Change font color in XPN 10

    Posted 08-30-2022 12:01
    Hi Lee.
    I am very glad that it was useful to you.
    I rewrote your script a bit. It works with a cycle.
            Dim up, down As xpBaseObject
            Dim txt As xpTextObject
            Dim addtxt() As String = {"NTL", "AL"}
            For i As Integer = 0 To 1
                self.GetObjectByName("UP " + addtxt(i), up)
                self.GetObjectByName("DOWN " + addtxt(i), down)
                self.GetObjectByName("GP " + addtxt(i), txt) 'rename "GP NATIONAL" to "GP NTL" and it will work properly
                If up.Visible Then
                    txt.Text = "{M:RED}" + txt.Text
                ElseIf down.Visible Then
                    txt.Text = "{M:GREEN}" + txt.Text
                Else
                    txt.Text = "{M:WHITE}" + txt.Text
                End If
            Next​


    ------------------------------
    Roman Yaroshenko
    chief specialist
    RBC-TV
    Moscow Russian Federation
    ------------------------------