RgbColor::RgbColor(HslColor color)
{
    //Serial.print("HSL to RGB : ");
    //Serial.print(color.H);
    //Serial.print(", ");
    //Serial.print(color.S);
    //Serial.print(", ");
    //Serial.print(color.L);
    //Serial.print(" => ");

    float r;
    float g;
    float b;
#ifdef HSL_FLOAT
    float h = color.H;
    float s = color.S;
    float l = color.L;
#else
    float h = color.H / 255.0f;
    float s = color.S / 255.0f;
    float l = color.L / 255.0f;
#endif

    if (color.S == 0.0f || color.L == 0.0f)
    {
        r = g = b = l; // achromatic or black
    }
    else 
    {
        float q = l < 0.5f ? l * (1.0f + s) : l + s - (l * s);
        float p = 2.0f * l - q;
        r = _CalcColor(p, q, h + 1.0f / 3.0f);
        g = _CalcColor(p, q, h);
        b = _CalcColor(p, q, h - 1.0f / 3.0f);
    }

    //Serial.print(r);
    //Serial.print(", ");
    //Serial.print(g);
    //Serial.print(", ");
    //Serial.print(b);
    //Serial.print(" = ");

    R = (uint8_t)(r * 255.0f);
    G = (uint8_t)(g * 255.0f);
    B = (uint8_t)(b * 255.0f);

    //Serial.print(R);
    //Serial.print(", ");
    //Serial.print(G);
    //Serial.print(", ");
    //Serial.print(B);
    //Serial.println();
}
/*******************************************************************
*
*       _ShowHiResPixels

  This is frame-function for the callback. It creates the window
  and handles the rotation of polygons and colors.
*/
static void _ShowHiResPixels(void) {
    WM_HWIN hWindow;
    const GUI_FONT *font_old;
    float pi, step, angle;
    int i, tm;
    pi = 3.1415926f;
    step = pi / 180;
    GUI_SetBkColor(GUI_BLACK);
    GUI_Clear();
    GUI_SetColor(GUI_WHITE);
    GUI_SetTextAlign(GUI_TA_HCENTER);
    font_old = GUI_SetFont(&GUI_Font24_ASCII);
    GUI_DispStringAt("AA_HiResPixels - Sample", 160, 5);
    GUI_SetFont(font_old);
    GUI_SetColor(GUI_RED);
    GUI_DispStringHCenterAt("not\nantialised", 65, 100);
    GUI_SetColor(GUI_GREEN);
    GUI_DispStringHCenterAt("antialised", 160, 100);
    GUI_SetColor(GUI_BLUE);
    GUI_DispStringHCenterAt("antialised\nwith high\nresolution", 255, 100);
    hWindow = WM_CreateWindow(35, 140, 250, 60, WM_CF_SHOW | WM_CF_MEMDEV, &_cbWindow, 0);
    WM_SelectWindow(hWindow);
    GUI_AA_SetFactor(AA_FACTOR);
    while (1) {
        for (i=0, angle=0; i<360; i++) {
            tm = GUI_GetTime();
            angle += step;
            GUI_RotatePolygon(_aPolygonHiRes, _aPolygonHiRes_src, POLY_POINTS, angle);
            GUI_RotatePolygon(_aPolygon, _aPolygon_src, POLY_POINTS, angle);
            _CalcColor();
            WM_InvalidateWindow(hWindow);
            while (((GUI_GetTime()-tm) < 50) || (WM_Exec1() != 0));
        }
    }
    WM_DeleteWindow(hWindow);
}