Skip to content

Colors and Colours in OpenRoberta

Reinhard Budde edited this page Apr 16, 2019 · 1 revision

Overview

There are 2 different ways to work with colours:

  • RGB: most robots support RGB colours. This is realized by using a colour picker. The generic representation are 3 byte values for the 3 channels R, G and B.
  • ENUM: LEGO robots (nxt, ev3, WeDo) use a small number of predefined colours. The generic representaion are names as "WHITE" or "RED" which internally are defines for numbers from 1 to 6 for NXT and from 0 to 7 for Ev3

RGB Representation

  • The full 24 bit colour space (16 million colours) is not needed. Thus, we represent a ORA-RGB-value as 1 unsigned int16 (65 thousand colours). R uses 5 bit, G uses 6 bit and B uses 5 bit stored from high bit to low bit in the unsigned int16.
  • When the code is generated, the RGB(r, g, b) macro is used for getting the 16 bit value from 3 byte channels and theRCHANNEL(colour), GCHANNEL(colour) and BCHANNEL(colour) macros are used for extracting R, G and B channels from 16 bit unsigned integer when needed. This is implemented for C/C++ in ???
  • In order to use the same code ??? for creating the colour we check whether the enum name for this colour could be found ??? and if yes we create ???where??? a pair of name - value. In case when no name is defined we create a pair of value - value. ???Explanation missing why this is needed???
  • All RGB-aware robots simply ignore the first item in pair ???which pair, how do we get it??? and use directly the value, so even if the name is recognised, we anyway get the RGB hex value.
  • All RGB-unaware robots (namely LEGO) use the corresponding name taken from the robot's YAML file. ???move to next paragraph??? ???The connection between blockly-XML and yaml is missing. Pls describe???

ENUM Representation

???The connection between blockly-XML and yaml is missing. Pls describe???

The legal enumeration values are declared in the robot's .yml file in the color-property. These values delivered from the front-end are checked w.r.t. the color-property values.

Clone this wiki locally