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); }
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); } } ); }
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); }
public static bool HitTest(VectorD vector, int width, int height) { return(vector.X >= 0 && vector.Y >= 0 && vector.X < width && vector.Y < height); }
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); }
public double Cross(VectorD other) { return(X * other.Y - Y * other.X); }
public bool Equals(VectorD other) { return(X.Equals(other.X) && Y.Equals(other.Y)); }
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); }
public VectorD Scale(VectorD scale) { return(new VectorD(X * scale.X, Y * scale.Y)); }
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); }
public static bool HitTest(VectorD vector, int width, int height) { return vector.X >= 0 && vector.Y >= 0 && vector.X < width && vector.Y < height; }
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); } ); }
public bool Equals(VectorD other) { return X.Equals(other.X) && Y.Equals(other.Y); }
public double Cross(VectorD other) { return X * other.Y - Y * other.X; }
public VectorD Scale(VectorD scale) { return new VectorD(X * scale.X, Y * scale.Y); }