Graphics

 View Only
  • 1.  Xpression - Changeable Colored Dots for U.S. Senate Seats on Election Night

    Posted 10-06-2014 20:52
    For our election coverage our newsroom would like to have a graphic that shows a dot for each of the 100 U.S. Senate seats and they would like to be able to change the amount of seats each party holds on the fly. In the past we have just made these graphics in Photoshop which doesn't allow them to be changed quickly. I would think something like this would be able to be scripted so if the number 40 would be typed in for the Democrats then 40 of the dots would turn blue. I have not been able to figure out how the scripting would work for this to happen, if it is even possible at all. If anybody has any ideas how to make this work it would be greatly appreciated.


  • 2.  RE: Xpression - Changeable Colored Dots for U.S. Senate Seats on Election Night

    Posted 10-06-2014 22:07
    Hi Jeff,

    This is certainly something that could be scripted.

    For this you would have to build a project that contains:

    1 group with 100 Quads in it which are named seat1 to seat100

    3 materials which are called Red, Blue and White for example.

    1 Textobject which is called txtDemocrats

    The code would look something like this:



    dim matRed as xpMaterial

    dim matBlue as xpMaterial

    dim matWhite as xpMaterial

    dim quadSeat as xpBaseObject

    dim txtObj as xpTextObject

    dim i as integer

    dim amountDemocrats as integer

    ' LINK THE MATERIALS TO THE OBJECTS

    Engine.getMaterialByName("White", matWhite)

    Engine.getMaterialByName("Blue", matBlue)

    Engine.getMaterialByName("Red", matRed)

    ' EXTRACT THE AMOUNT OF DEMOCRATS FROM THE TEXTOBJECT

    Self.getObjectByName("txtDemocrats", txtObj)

    amountDemocrats = cInt(txtObj.Text)

    ' LOOP THROUGH ALL OF THE DOTS AND ASSIGN THE APPROPRIATE MATERIAL

    for i=1 to 100

    Self.getObjectByName("seat" & i, quadSeat)

    if i

    #XPression


  • 3.  RE: Xpression - Changeable Colored Dots for U.S. Senate Seats on Election Night

    Posted 10-06-2014 22:32
    Hi Kenneth,

    Thanks for this script. This is a huge step forward to accomplishing what we're trying to do. One question though, would there be some way to make it so you could say type in a number for democrats that colors seats blue starting at 1, type in a different number for republicans that colors seats red starting at 100, and then have the remainder of the dots show white for seats that are still up for grabs for races that aren't over yet?

    Thanks,

    Jeff

    #XPression


  • 4.  RE: Xpression - Changeable Colored Dots for U.S. Senate Seats on Election Night

    Posted 10-06-2014 22:55
    Hi Jeff,

    Sure you can, anything is possible! Well almost...

    We only have to include an additional condition.

    Below you'll find the amended code.



    dim matRed as xpMaterial

    dim matBlue as xpMaterial

    dim matWhite as xpMaterial

    dim quadSeat as xpBaseObject

    dim txtObj as xpTextObject

    dim i as integer

    dim amountDemocrats as integer

    dim amountRepublicans as integer

    ' LINK THE MATERIALS TO THE OBJECTS

    Engine.getMaterialByName("White", matWhite)

    Engine.getMaterialByName("Blue", matBlue)

    Engine.getMaterialByName("Red", matRed)

    ' EXTRACT THE AMOUNT OF DEMOCRATS FROM THE TEXTOBJECT

    Self.getObjectByName("txtDemocrats", txtObj)

    amountDemocrats = cInt(txtObj.Text)

    ' EXTRACT THE AMOUNT OF REPUBLICANS FROM THE TEXTOBJECT

    Self.getObjectByName("txtRepublicans", txtObj)

    amountRepublicans = cInt(txtObj.Text)

    ' LOOP THROUGH ALL OF THE DOTS AND ASSIGN THE COLOUR

    for i=1 to 100

    Self.getObjectByName("seat" & i, quadSeat)

    if i [SMALLER THEN]= amountDemocrats then ' CODE NOT DISPLAYING PROPERLY

    quadSeat.setMaterial(0,matBlue)

    else if i [BIGGER THEN] amountDemocrats And i [BIGGER THEN] (100 - amountRepublicans) then ' CODE NOT DISPLAYING PROPERLY

    quadSeat.setMaterial(0,matRed)

    else

    quadSeat.setMaterial(0,matWhite)

    end if

    next



    [EDIT]

    Some of the code is not displaying properly on this forum. So you'll see two lines in the code above which have [SMALLER THEN] or [BIGGER THEN] in it. Replace those with the symbol equal to the text.

    #XPression