Graphics

 View Only
  • 1.  Replacing Text Color in Templates

    Posted 06-22-2015 16:40
    Hello All,

    We have this new graphic where we would like to have 5 different color options on text depending on the golfer's score. Right now, we made our graphic like we normally would and created a text template with the different color for each hole (18 holes plus 5 different color options). Is there an easier way of doing this? Through visual logic maybe? Our graphics are filled out through iNews.

    I would really appreciate the help.

    Best,

    Mildred O.


  • 2.  RE: Replacing Text Color in Templates

    Posted 06-22-2015 16:53

    Text with font tags would be the easiest way to handle this. I'll assume you have a font for -2 or lower, -1, par, +1, and +2 or higher. Get the font numbers for each of these, and you can add it in line to change the font following it. For example, if your par text is font item 1, you would enter `{1}0` or `{1}par` into the text object.

    Visual logic should be able to handle it, but I'm not the guy to answer for that. Someone else could probably chime in to help.

    Scripting, on the other hand, I can help you with. Keeping the same assumptions as earlier, you could script it to find the value, then change the font accordingly:

    FOR FUTURE READERS, I HAVE EDITED THE SCRIPT TO INCLUDE REMARKS



    `dim score as xpTextObject

    dim temp as String=nothing

    dim scoreval as Integer

    dim bogey as xpFont

    dim birdie as xpFont

    dim par as xpFont

    dim dbog as xpFont

    dim dbird as xpFont

    'assign the text object and create an integer from it

    Self.GetObjectByName("Score Text Object", score)

    scoreval=Cint(score.Text)

    'get the fonts from the engine

    Engine.GetFontByName("Bogey Font", bogey)

    Engine.GetFontByName("Birdie Font", birdie)

    Engine.GetFontByName("Par Font", par)

    Engine.GetFontByName("Double Bogey Font", dbog)

    Engine.GetFontByName("Double Birdie Font", dbird)

    'this is the part that does the work

    'each if/elseif statement checks the value of the score

    'then it moves the text to a temporary string

    'deletes the original text

    'changes the font

    'and copies the text back in with the new font applied

    'if you do not delete the old text, the font will not update

    if scoreval = -1 then

    temp=score.Text

    score.Text=""

    score.CurrentFont=bogey

    score.Text=temp

    elseif scoreval = 1 then

    temp=score.Text

    score.Text=""

    score.CurrentFont=birdie

    score.Text=temp

    elseif scoreval = 0 then

    temp=score.Text

    score.Text=""

    score.CurrentFont=par

    score.Text=temp

    elseif scoreval < -1 then

    temp=score.Text

    score.Text=""

    score.CurrentFont=dbog

    score.Text=temp

    elseif scoreval > 1 then

    temp=score.Text

    score.Text=""

    score.CurrentFont=dbird

    score.Text=temp

    end if`

    #XPression


  • 3.  RE: Replacing Text Color in Templates

    Posted 06-22-2015 18:19
    Just to expand on Dan's suggestion.. Note that when you use the font tags, you can use the Name of the font in the tag instead of just the font message. E.g. {par}0 {birdie}-1 {bogey}+2 etc... (assuming the fonts are called par, birdie, and bogey)

    #XPression


  • 4.  RE: Replacing Text Color in Templates

    Posted 06-22-2015 18:36
    It worked perfect! Thanks for the help to both of you :)

    #XPression