Color Dynamic Example
To create a three color traffic light in 2D GraphWorX, do the following:
-
Create three grey circles, enclose them in a rectangle, send the rectangle to the back, and then group them.
-
Double click the group, select the three circles and click the Color dynamic tool in the Color section of the Dynamics ribbon.
-
Set the DataSource property for all three circles to
localsim:ramp:::0:1000, their ActiveWhen property to(data>=low) AND (data <=high), AnimationMode toDiscrete, TargetProperty toFill.These settings change the value regularly over time, set the interval when the color is active, make the animation a stepwise process, and change the fill color. Since all three objects were selected, these settings are applied to all of the circles.
-
Click the top circle and then set the following settings: LowLimit,
0; HighLimit,400; UseEndColor,True; EndColor,0, 255, 0(green). The UseStartColor property keeps its default of False. -
Click the middle circle and change the settings for Step 4 to use: LowLimit,
401; HighLimit,599; UseEndColor,True; and EndColor,255, 255, 0(yellow).The UseStartColor property keeps its default of False. -
Click the bottom circle and change the settings for Step 4 to use: LowLimit,
600; HighLimit,1000; UseEndColor,True; and EndColor,255, 0, 0(red).The UseStartColor property keeps its default of False. Refer to the figure below to see the properties for the red circle. -
Switch to runtime mode to observe your newly created traffic light.
The top circle will be red for two seconds; yellow will appear in the center circle for a second while red goes back to grey; and then the bottom circle turns green for two second while the top two circles are grey. After five seconds are over the display cycles. The timing is a property of the localsim:ramp simulator, which has as a default period setting set to 5 seconds. You can change this value as part of the simulator's definition.
See also: