Ejemplo n.º 1
0
        public static Color FromHsv(Angle h, double s, double v, int a)
        {
            var H = h.Degrees / 60;

            s = GMath.Median(0, s, 1);
            v = GMath.Median(0, v, 1);
            var C = v * s;
            var X = C * (1 - GMath.Abs(H % 2 - 1));
            var m = v - C;

            double R, G, B;

            switch ((int)H)
            {
            case 0: R = C; G = X; B = 0; break;

            case 1: R = X; G = C; B = 0; break;

            case 2: R = 0; G = C; B = X; break;

            case 3: R = 0; G = X; B = C; break;

            case 4: R = X; G = 0; B = C; break;

            default: R = C; G = 0; B = X; break;
            }

            return(FromRgba((int)(255 * (R + m)), (int)(255 * (G + m)), (int)(255 * (B + m)), a));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new GRaff.Color, with the same color channels as this instance, but with the new specified opacity.
 /// </summary>
 /// <param name="opacity">The opacity of the new color. 0.0 means it is completely transparent, and 1.0 means it is completely opaque.</param>
 /// <returns>A new GRaff.Color with the same color as this instance, but with an alpha channel corresponding to the specified opacity.</returns>
 public Color Transparent(double opacity) => new Color(R, G, B, (byte)GMath.Round(255.0 * GMath.Median(0.0, opacity, 1.0)));
Ejemplo n.º 3
0
 public Point Project(Point pt)
 => new Point(GMath.Median(Left, pt.X, Right), GMath.Median(Top, pt.Y, Bottom));