/// <summary> /// Draws a triangle with the specified border and fill brushes. /// </summary> /// <param name="triangle">The triangle to draw.</param> /// <param name="border">The border brush.</param> /// <param name="fill">The fill brush.</param> public void DrawTriangle(Triangle triangle, BufferBrush border, BufferBrush fill) { var bounds = triangle.GetBounds(); double area = triangle.Area; Point p = new Point(); double sum = 0; for (int i = bounds.Left; i < bounds.Right; i++) for (int j = bounds.Top; j < bounds.Bottom; j++) { p.X = i; p.Y = j; sum = Triangle.GetArea(p, triangle.A, triangle.B) + Triangle.GetArea(p, triangle.B, triangle.C) + Triangle.GetArea(p, triangle.C, triangle.A); if (sum >= area - 1 && sum <= area + 1) { _buffer[j, i].BackColor = fill.GetColor(i, j); } } DrawTriangle(triangle, border); }
/// <summary> /// Draws a triangle to the buffer. /// </summary> /// <param name="triangle">The triangle to draw.</param> /// <param name="brush">The brush to draw the triangle with.</param> public void DrawTriangle(Triangle triangle, BufferBrush brush) { DrawLine(ref triangle.A, ref triangle.B, brush); DrawLine(ref triangle.B, ref triangle.C, brush); DrawLine(ref triangle.C, ref triangle.A, brush); }
/// <summary> /// Draws a triangle to the buffer. /// </summary> /// <param name="triangle">The triangle to draw.</param> /// <param name="color">The color to draw the triangle.</param> public void DrawTriangle(ref Triangle triangle, BufferColor color) { DrawLine(ref triangle.A, ref triangle.B, color); DrawLine(ref triangle.B, ref triangle.C, color); DrawLine(ref triangle.C, ref triangle.A, color); }