Page 1 of 1

Custom colors in 2D visualization

Posted: Friday 22 April, 2011 - 16:34
by MarvinH
In case you want to use some other colors than the default colors in your 2D visualization, try to add some of the following to your On2DDraw event:

Code: Select all

Do(
  Var([valSolid], vbValue, 1),
  Var([valBlinking], vbValue, 0),
  Var([valDisco], vbValue, 0),
  Var([valPeriod], vbValue, 300),
  Var([valBase], vbValue, ColorLime),
  
  Case(
    WhichIsTrue(
      valSolid,
      valBlinking,
      valDisco
    ),
    { * Solid * }
    Color(c) := ColorBlack,
    { * Blinking * }
    If(
      Sin(valPeriod * Now) > 0,
      Color(c) := ColorBlack,
      Color(c) := ColorWhite
    ),
    { * Disco * }
    Color(c) := valBase * Sin(valPeriod * Now)
  )
)
By playing with the first 5 parameters, the color of your visualization will change. Note that the colors in ED are stored as integer values. For example ColorBlack equals 0, ColorRed equals 255 and ColorLime equals 65280. Try some values your own, and enjoy!