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.
Rgb32MenuItem
with default callback of rgbAlphaItemRenderFn
in ScrollChoiceMenuItem.h
getMenuType()
is MENUTYPE_COLOR_VALUEFrom the add item dialog choose the RGB Color option. At this point the properties area should look as follows:
The only RGB specific option is alpha, if this color needs an alpha channel tick the box, otherwise leave un-ticked.
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();
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
}
}
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.