rgb-color-pack

bradzilla84/color-rgb-hsl/rgb-color-pack

No description
rgb-color-pack
@/rgb-color-pack
Rednumber
Red Colour 0 min, 255 Max. You can use 0 to 1 to it will be remapped automatically.
Greennumber
Green Colour 0 min, 255 Max. You can use 0 to 1 to it will be remapped automatically.
Bluenumber
Blue Colour 0 min, 255 Max. You can use 0 to 1 to it will be remapped automatically.
INITpulse
rgb-color-pack
Red
Green
Blue
INIT
OUT
OUT@/rgb-color-pack
To use the node in your project you should have the bradzilla84/color-rgb-hsl library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

struct State {
    // this is a regular state related to the patch (i.e. constructor in this case)
};

struct Type {
    uint8_t Red;
    uint8_t Green;
    uint8_t Blue;
    uint16_t Hex;
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {

    if (!isInputDirty<input_INIT>(ctx)){
        return;}


    uint8_t Red = getValue<input_Red>(ctx);
    uint8_t Green = getValue<input_Green>(ctx);
    uint8_t Blue = getValue<input_Blue>(ctx);

    if(Red <= 1) Red = getValue<input_Red>(ctx) * 255;
    if(Green <= 1) Green = getValue<input_Green>(ctx) * 255;
    if(Blue <= 1) Blue = getValue<input_Blue>(ctx) * 255;

    if(Red >= 255) Red = 255;
    if(Green >= 255) Green = 255;
    if(Blue >= 255) Blue = 255;

    uint16_t Hex = { ((Red & 0xF8) << 8) | ((Green & 0xFC) << 3) | ((Blue & 0xF8) >> 3) };
    Type Color = { Red, Green, Blue, Hex };
    emitValue<output_OUT>(ctx, Color);
}