Пример #1
0
        public static void DrawLineVector(this IntPtr target,
                                          VectorD start,
                                          VectorD stop,
                                          Color startColor,
                                          Color stopColor,
                                          int width,
                                          int height)
        {
            var rFac = (stopColor.R - startColor.R);
            var gFac = (stopColor.G - startColor.G);
            var bFac = (stopColor.B - startColor.B);
            var aFac = (stopColor.A - startColor.A);

            target.DrawLineVector(start, stop, (d, d1, position) => Color.FromArgb((byte)(startColor.A + aFac * position),
                                                                                   (byte)(startColor.R + rFac * position),
                                                                                   (byte)(startColor.G + gFac * position),
                                                                                   (byte)(startColor.B + bFac * position)).Intify(), width,
                                  height);
        }
Пример #2
0
        public static unsafe void DrawLineVector(this IntPtr target,
                                                 VectorD start,
                                                 VectorD stop,
                                                 ColorForPixel colorForPixel,
                                                 int width,
                                                 int height)
        {
            var buf        = (int *)target;
            var lineVector = stop - start;
            var steps      = (int)Math.Max(Math.Abs(lineVector.X), Math.Abs(lineVector.Y));
            var uX         = lineVector.X / steps;
            var uY         = lineVector.Y / steps;

            Parallel.For(0, steps, i =>
            {
                var x = start.X + uX * i;
                var y = start.Y + uY * i;
                if (y > -1 && x > -1 && x < width && y < height)
                {
                    buf[(int)y * width + (int)x] = colorForPixel(x, y, i / (double)steps);
                }
            }
                         );
        }
Пример #3
0
 public static void DrawEllipse(this RenderContext context, VectorD center, VectorD radius, Color color)
 {
     context.BackBuffer.DrawEllipse((int)center.X, (int)center.Y, (int)radius.X, (int)radius.Y, color.Intify(), context.Width,
                                    context.Height);
 }
Пример #4
0
 public static bool HitTest(VectorD vector, int width, int height)
 {
     return(vector.X >= 0 && vector.Y >= 0 && vector.X < width && vector.Y < height);
 }
Пример #5
0
        public static void DrawLineVector(this IntPtr target, VectorD start, VectorD stop, Color colour, int width, int height)
        {
            var col = colour.Intify();

            target.DrawLineVector(start, stop, (d, d1, position) => col, width, height);
        }
Пример #6
0
 public double Cross(VectorD other)
 {
     return(X * other.Y - Y * other.X);
 }
Пример #7
0
 public bool Equals(VectorD other)
 {
     return(X.Equals(other.X) && Y.Equals(other.Y));
 }
Пример #8
0
 public static void DrawEllipse(this RenderContext context, VectorD center, VectorD radius, Color color)
 {
     context.BackBuffer.DrawEllipse((int) center.X, (int) center.Y, (int) radius.X, (int) radius.Y, color.Intify(), context.Width,
         context.Height);
 }
Пример #9
0
 public VectorD Scale(VectorD scale)
 {
     return(new VectorD(X * scale.X, Y * scale.Y));
 }
Пример #10
0
 public static void DrawLineVector(this IntPtr target,
     VectorD start,
     VectorD stop,
     Color startColor,
     Color stopColor,
     int width,
     int height)
 {
     var rFac = (stopColor.R - startColor.R);
     var gFac = (stopColor.G - startColor.G);
     var bFac = (stopColor.B - startColor.B);
     var aFac = (stopColor.A - startColor.A);
     target.DrawLineVector(start, stop, (d, d1, position) => Color.FromArgb((byte) (startColor.A + aFac*position),
         (byte) (startColor.R + rFac*position),
         (byte) (startColor.G + gFac*position),
         (byte) (startColor.B + bFac*position)).Intify(), width,
         height);
 }
Пример #11
0
 public static bool HitTest(VectorD vector, int width, int height)
 {
     return vector.X >= 0 && vector.Y >= 0 && vector.X < width && vector.Y < height;
 }
Пример #12
0
 public static void DrawLineVector(this IntPtr target, VectorD start, VectorD stop, Color colour, int width, int height)
 {
     var col = colour.Intify();
     target.DrawLineVector(start, stop, (d, d1, position) => col, width, height);
 }
Пример #13
0
 public static unsafe void DrawLineVector(this IntPtr target,
     VectorD start,
     VectorD stop,
     ColorForPixel colorForPixel,
     int width,
     int height)
 {
     var buf = (int*) target;
     var lineVector = stop - start;
     var steps = (int) Math.Max(Math.Abs(lineVector.X), Math.Abs(lineVector.Y));
     var uX = lineVector.X/steps;
     var uY = lineVector.Y/steps;
     Parallel.For(0, steps, i =>
                            {
                                var x = start.X + uX*i;
                                var y = start.Y + uY*i;
                                if (y > -1 && x > -1 && x < width && y < height)
                                    buf[(int) y*width + (int) x] = colorForPixel(x, y, i/(double) steps);
                            }
         );
 }
Пример #14
0
 public bool Equals(VectorD other)
 {
     return X.Equals(other.X) && Y.Equals(other.Y);
 }
Пример #15
0
 public double Cross(VectorD other)
 {
     return X * other.Y - Y * other.X;
 }
Пример #16
0
 public VectorD Scale(VectorD scale)
 {
     return new VectorD(X * scale.X, Y * scale.Y);
 }