//http://www.bobpowell.net/rgbhsb.htm
        //h is stored from 0-360 the calcultion needs from 0-1 so we divide hsl.H by 360
        public static Colour HslToRgb(HSL hsl)
        {
            double r = 0, g = 0, b = 0;
            double h = hsl.H / 360;
            double s = hsl.S, l = hsl.L;

            double temp1, temp2;

            if (l == 0)
            {
                r = g = b = 0;
            }
            else
            {
                if (s == 0)
                {
                    r = g = b = l;
                }
                else
                {
                    temp2 = ((l <= 0.5) ? l * (1.0 + s) : l + s - (l * s));
                    temp1 = 2.0 * hsl.L - temp2;

                    double[] t3 = new double[] { h + 1.0 / 3.0, h, h - 1.0 / 3.0 };
                    double[] clr = new double[] { 0, 0, 0 };
                    for (int i = 0; i < 3; i++)
                    {
                        if (t3[i] < 0)
                            t3[i] += 1.0;

                        if (t3[i] > 1)
                            t3[i] -= 1.0;

                        if (6.0 * t3[i] < 1.0)
                            clr[i] = temp1 + (temp2 - temp1) * t3[i] * 6.0;
                        else if (2.0 * t3[i] < 1.0)
                            clr[i] = temp2;
                        else if (3.0 * t3[i] < 2.0)
                            clr[i] = (temp1 + (temp2 - temp1) * ((2.0 / 3.0) - t3[i]) * 6.0);
                        else
                            clr[i] = temp1;
                    }
                    r = clr[0];
                    g = clr[1];
                    b = clr[2];
                }
            }
            return Color.FromArgb((int)(255 * r), (int)(255 * g), (int)(255 * b));
        }
        //http://www.bobpowell.net/rgbhsb.htm
        //h is stored from 0-360 the calcultion needs from 0-1 so we divide hsl.H by 360
        public static Colour HslToRgb(HSL hsl)
        {
            double r = 0, g = 0, b = 0;
            double h = hsl.H / 360;
            double s = hsl.S, l = hsl.L;

            double temp1, temp2;

            if (l == 0)
            {
                r = g = b = 0;
            }
            else
            {
                if (s == 0)
                {
                    r = g = b = l;
                }
                else
                {
                    temp2 = ((l <= 0.5) ? l * (1.0 + s) : l + s - (l * s));
                    temp1 = 2.0 * hsl.L - temp2;

                    double[] t3  = new double[] { h + 1.0 / 3.0, h, h - 1.0 / 3.0 };
                    double[] clr = new double[] { 0, 0, 0 };
                    for (int i = 0; i < 3; i++)
                    {
                        if (t3[i] < 0)
                        {
                            t3[i] += 1.0;
                        }

                        if (t3[i] > 1)
                        {
                            t3[i] -= 1.0;
                        }

                        if (6.0 * t3[i] < 1.0)
                        {
                            clr[i] = temp1 + (temp2 - temp1) * t3[i] * 6.0;
                        }
                        else if (2.0 * t3[i] < 1.0)
                        {
                            clr[i] = temp2;
                        }
                        else if (3.0 * t3[i] < 2.0)
                        {
                            clr[i] = (temp1 + (temp2 - temp1) * ((2.0 / 3.0) - t3[i]) * 6.0);
                        }
                        else
                        {
                            clr[i] = temp1;
                        }
                    }
                    r = clr[0];
                    g = clr[1];
                    b = clr[2];
                }
            }
            return(Color.FromArgb((int)(255 * r), (int)(255 * g), (int)(255 * b)));
        }