Ejemplo n.º 1
0
        public HSLColor(RGBColor rgbColor)
        {
            double red = (rgbColor.Red / 255d);
            double green = (rgbColor.Green / 255d);
            double blue = (rgbColor.Blue / 255d);

            double min = Math.Min(Math.Min(red, green), blue);
            double max = Math.Max(Math.Max(red, green), blue);
            double delta = max - min;

            double hue = 0;
            double saturation = 0;
            double luminosity = (double)((max + min) / 2.0d);

            if (luminosity > 0.0d && luminosity < 1.0d)
            {
                saturation = delta/(luminosity < 0.5f ? 2.0f*luminosity : (2.0f - 2.0f*luminosity));
            }
            if (delta > 0.0d)
            {
                if (max == red && max != green) hue += (green - blue)/delta;
                if (max == green && max != blue) hue += (2.0d + (blue - red)/delta);
                if (max == blue && max != red) hue += (4.0d + (red - green)/delta);
                hue /= 6.0d;
            }

            Hue = (byte)(hue * 255);
            Saturation = (byte)(saturation * 255);
            Luminosity = (byte)(luminosity * 255);
            Alpha = Convert.ToByte(rgbColor.Alpha);
        }
 protected ToolbarItemBase()
 {
     BackgroundColor = new RGBColor(0xf45f00);
     PrimaryItems = new List<ToolbarItem>();
     SecondaryItems = new List<ToolbarItem>();
     Enabled = true;
 }