public static void LineWithBuffer(vec2i p0, vec2i p1, Color color, Bitmap bitmap, int[] buffer) { if (p0.x > p1.x) { vec2i temp = p0; p0 = p1; p1 = temp; } for (int x = p0.x; x <= p1.x; x++) { float t = (float)(x - p0.x) / (p1.x - p0.x); int y = (int)(p0.y + t * (p1.y - p0.y)); int previousX = buffer[x]; if (buffer[x] < y) { buffer[x] = y; for (int yy = 0; yy < bitmap.Height; yy++) { SetPixel(x, yy, color, bitmap); } } } }
static Tuple <vec2i, vec2i> GetBoundingBox(vec2i v0, vec2i v1, vec2i v2) { var xs = new List <int> { v0.x, v1.x, v2.x }; var ys = new List <int> { v0.y, v1.y, v2.y }; return(new Tuple <vec2i, vec2i>(new vec2i(xs.Min(), ys.Min()), new vec2i(xs.Max(), ys.Max()))); }
public static void Line(vec2i p0, vec2i p1, Color color, Bitmap bitmap) { Line(p0.x, p0.y, p1.x, p1.y, color, bitmap); }