colors and lights

Dave Touretzky edited this page Jan 16, 2017 · 1 revision

Color

The Color class (cozmo.lights.Color) describes a color using standard (r,g,b,alpha) values in the range [0..255], where alpha is an opacity coefficient and is presently ignored. (In computer graphics, alpha can be used to make objects semi-transparent, or to blend colors together.) Anki recommends using alpha=255 (fully opaque) so that if they do support transparency in the future, current programs' behavior won't change.

Colors are converted to 32 bit integers; the int_color attribute returns the rgba value in this integer form.

Built-in colors include:

  • cozmo.lights.red
  • cozmo.lights.green
  • cozmo.lights.blue
  • cozmo.lights.white
  • cozmo.lights.off

Light

The Light class (cozmo.lights.Light) describes a light that switches back and forth between two color states, each of which is a cozmo.lights.Color instance. The two color states are called "on" and "off", but in reality they are completely arbitrary. In the simplest case, a steady light, the "on" state is some fully-saturated color such as blue (0,0,255) and the off state isn't used. For a flashing light, the off state would be (0,0,0). For a light that cycles between two colors, such as blue and red, the "off" state would be red (255,0,0).

Built-in steady lights include:

  • cozmo.lights.red_light
  • cozmo.lights.green_light
  • cozmo.lights.blue_light
  • cozmo.lights.white_light
  • cozmo.lights.off_light
Additional parameters define the periods of the on and off states in milliseconds, and the time for an on-to-off or off-to-on transition, also in milliseconds. Thus, a complete light definition comprises six elements:
  • "on" color
  • "on" period (in ms)
  • "on" to off transition time (in ms)
  • "off" color
  • "off" period (in ms)
  • "off" to "on" transition time (in ms)
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.