Exemple #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);
        }
Exemple #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);
                }
            }
                         );
        }
Exemple #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);
 }
Exemple #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);
 }
Exemple #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);
        }
Exemple #6
0
 public double Cross(VectorD other)
 {
     return(X * other.Y - Y * other.X);
 }
Exemple #7
0
 public bool Equals(VectorD other)
 {
     return(X.Equals(other.X) && Y.Equals(other.Y));
 }
Exemple #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);
 }
Exemple #9
0
 public VectorD Scale(VectorD scale)
 {
     return(new VectorD(X * scale.X, Y * scale.Y));
 }
Exemple #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);
 }
Exemple #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;
 }
Exemple #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);
 }
Exemple #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);
                            }
         );
 }
Exemple #14
0
 public bool Equals(VectorD other)
 {
     return X.Equals(other.X) && Y.Equals(other.Y);
 }
Exemple #15
0
 public double Cross(VectorD other)
 {
     return X * other.Y - Y * other.X;
 }
Exemple #16
0
 public VectorD Scale(VectorD scale)
 {
     return new VectorD(X * scale.X, Y * scale.Y);
 }