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 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); } ); }