11-11-2020
Visit associated GitHub repository
Visit reference documentation page

An item type that represents a color in the Red Green Blue space, optionally also having an Alpha. Colors are represented as values between 0 and 255 for each part and optionally an additional part for Alpha.

Type information for Rgb32MenuItem

Creating a color menu item using the designer

From the add item dialog choose the RGB Color option. At this point the properties area should look as follows:

image showing the RGB editor
RGB Item Editor UI

The only RGB specific option is alpha, if this color needs an alpha channel tick the box, otherwise leave un-ticked.

Working with color items in code

To get and set color data as an RgbColor32 we can do the following

RgbColor32 color(255, 255, 255);

item.setColorData(color); 
RgbColor32 clr = item.getColorData();

On any RgbColor32 structure you can get a HTML color string such as #ffffff for example.

clr.asHtmlString(buffer, bufferSize, alphaNeeded);

You can check if an menu item is using the alpha channel

item.isAlphaInUse();

Creating an RGB menu item from the CLI

To create an RGB menu item from the CLI here is a template command (options in square brackets are optional):

tcmenu create-item --parent 0 --type rgb --eeprom AUTO --name RgbName [--localonly --readonly --hide]

The structure of an RGB menu item in the EMF file is:

{
  "parentId": 0,
  "type": "rgbItem",
  "item": {
    "includeAlphaChannel": false,
    "name": "RgbName",
    "variableName": "RgbName",
    "id": 13,
    "eepromAddress": 14,
    "readOnly": false,
    "localOnly": false,
    "visible": true,
    "staticDataInRAM": false
  }
}

Creating Rgb items manually

const AnyMenuInfo minfoRGB = { "RGB", myId, myEeprom, 0, onRgbChanged };
Rgb32MenuItem menuRGB(&minfoRGB, RgbColor32(0, 0, 0), isAlphaIncluded, nextItemPtr, INFO_LOCATION_PGM);// or INFO_LOCATION_RAM

You can see above an example of how to very simply create an RGB menu item manually in code without designer. See the reference docs for more information.

These may be of interest

Want to let us know about something?

We use cookies to analyse traffic and to personalise content. We also embed Twitter and Youtube on some pages, these companies have their own privacy policies.

See the privacy policy and terms of use of this site should you need more information or wish to adjust your settings.