public static void DrawEllipse(Figures.Ellipse ellipse, EllipseDrawingMethod drawingMethod = EllipseDrawingMethod.Polygon) { switch (drawingMethod) { case EllipseDrawingMethod.Triangles: { for (var i = 0; i < ellipse.PointsCount - 1; i++) { Graphics.Triangle ( x1: ellipse.Center.X, y1: ellipse.Center.Y, x2: ellipse.Points[i].X, y2: ellipse.Points[i].Y, x3: ellipse.Points[i + 1].X, y3: ellipse.Points[i + 1].Y, fillColor: ellipse.FillColor, borderColor: FloatColor.Transparent ); } if (ellipse.IsCompleted) { Graphics.Triangle ( x1: ellipse.Center.X, y1: ellipse.Center.Y, x2: ellipse.Points[0].X, y2: ellipse.Points[0].Y, x3: ellipse.Points[ellipse.PointsCount - 1].X, y3: ellipse.Points[ellipse.PointsCount - 1].Y, fillColor: ellipse.FillColor, borderColor: FloatColor.Transparent ); } break; } case EllipseDrawingMethod.Polygon: { if (ellipse.IsCompleted) { Graphics.Polygon(ellipse.FillColor, FloatColor.Transparent, ellipse.Points.Where((point, index) => index != ellipse.PointsCount - 1)); } else { Graphics.Polygon(ellipse.FillColor, FloatColor.Transparent, ellipse.Points.Where((point, index) => index != ellipse.PointsCount).Append(ellipse.Center)); } break; } } Graphics.SetBorder(ellipse, ellipse.BorderColor); }
public static void DrawRectangle(Figures.Rectangle rectangle) { if (!rectangle.FillColor.IsTransparent) { GL.Begin(PrimitiveType.Quads); GL.Color4(rectangle.FillColor.R, rectangle.FillColor.G, rectangle.FillColor.B, rectangle.FillColor.A); foreach (var point in rectangle.Points) { GL.Vertex2(point.X, point.Y); } GL.End(); } Graphics.SetBorder(rectangle, rectangle.BorderColor); }
public static void DrawPolygon(Figures.Polygon polygon) { if (!polygon.FillColor.IsTransparent) { GL.Begin(PrimitiveType.Polygon); GL.Color4(polygon.FillColor.R, polygon.FillColor.G, polygon.FillColor.B, polygon.FillColor.A); foreach (var point in polygon.Points.Reverse()) { GL.Vertex2(point.X, point.Y); } GL.End(); } Graphics.SetBorder(polygon, polygon.BorderColor); }
public static void DrawTriangle(Figures.Triangle triangle) { if (!triangle.FillColor.IsTransparent) { GL.Begin(PrimitiveType.Triangles); GL.Color4(triangle.FillColor.R, triangle.FillColor.G, triangle.FillColor.B, triangle.FillColor.A); foreach (var point in triangle.Points) { GL.Vertex2(point.X, point.Y); } GL.End(); } Graphics.SetBorder(triangle, triangle.BorderColor); }