Beispiel #1
0
            /// <summary>
            /// Creates gradient between 2 points
            /// </summary>
            /// <param name="point1"></param>
            /// <param name="color1"></param>
            /// <param name="point2"></param>
            /// <param name="color2"></param>
            public void Gradient(Point point1, Color color1, Point point2, Color color2)
            {
                int width  = this.Width;
                int height = this.Height;

                for (int i = 0; i < width; i++)
                {
                    for (int j = 0; j < height; j++)
                    {
                        Point  p = new Point(i, j);
                        double d1 = p.Distance(point1), d2 = p.Distance(point2);
                        double dis    = d1 + d2;
                        Color  c      = Color.Black;
                        double ratio1 = d2 / dis;
                        double ratio2 = 1 - ratio1;
                        c            = c.Add(color1.Multiply(ratio1));
                        c            = c.Add(color2.Multiply(ratio2));
                        Canvas[i, j] = (uint)c.ToArgb();
                    }
                }
            }
 public static Color Add(this Color This, int value) => This.Add(value, value, value);
 public static Color Darken(this Color This, byte amount) => This.Add(-amount);
 public static Color Lighten(this Color This, byte amount) => This.Add(amount);