public void DrawConvexPath(GLConvexPath geo, GLBrush brush, float lineWidth = 1.0f) { GL.PushMatrix(); GL.Translate(0.5f, 0.5f, 0); GL.Enable(EnableCap.LineSmooth); GL.Color4(brush.Color0); #if FAMISTUDIO_LINUX if (!supportsLineWidth && lineWidth > 1) { var pts = new float[geo.Points.Length * 2 + 2]; for (int i = 0; i < geo.Points.Length; i++) { pts[i * 2 + 0] = geo.Points[i].X; pts[i * 2 + 1] = geo.Points[i].Y; } pts[geo.Points.Length * 2 + 0] = geo.Points[0].X; pts[geo.Points.Length * 2 + 1] = geo.Points[0].Y; DrawThickLineAsPolygon(pts, brush, lineWidth); } else #endif { GL.LineWidth(lineWidth); GL.Begin(BeginMode.LineLoop); foreach (var pt in geo.Points) { GL.Vertex2(pt.X, pt.Y); } GL.End(); } GL.Disable(EnableCap.LineSmooth); GL.PopMatrix(); }
public void FillConvexPath(GLConvexPath geo, GLBrush brush) { if (!brush.IsGradient) { GL.Color4(brush.Color0); GL.Begin(BeginMode.TriangleFan); foreach (var pt in geo.Points) { GL.Vertex2(pt.X + 0.5f, pt.Y + 0.5f); } GL.End(); } else { Debug.Assert(brush.GradientSizeX == 0.0f); GL.Begin(BeginMode.TriangleFan); foreach (var pt in geo.Points) { float lerp = pt.Y / (float)brush.GradientSizeY; byte r = (byte)(brush.Color0.R * (1.0f - lerp) + (brush.Color1.R * lerp)); byte g = (byte)(brush.Color0.G * (1.0f - lerp) + (brush.Color1.G * lerp)); byte b = (byte)(brush.Color0.B * (1.0f - lerp) + (brush.Color1.B * lerp)); byte a = (byte)(brush.Color0.A * (1.0f - lerp) + (brush.Color1.A * lerp)); GL.Color4(r, g, b, a); GL.Vertex2(pt.X + 0.5f, pt.Y + 0.5f); } GL.End(); } }
public void FillConvexPath(GLConvexPath geo, GLBrush brush, bool smooth = false) { if (!brush.IsGradient) { if (smooth) GL.Enable(EnableCap.PolygonSmooth); GL.Color4(brush.Color0); GL.Begin(BeginMode.TriangleFan); foreach (var pt in geo.Points) GL.Vertex2(pt.X, pt.Y); GL.End(); if (smooth) GL.Disable(EnableCap.PolygonSmooth); } else { Debug.Assert(brush.GradientSizeX == 0.0f); GL.Begin(BeginMode.TriangleFan); foreach (var pt in geo.Points) { float lerp = pt.Y / (float)brush.GradientSizeY; byte r = (byte)(brush.Color0.R * (1.0f - lerp) + (brush.Color1.R * lerp)); byte g = (byte)(brush.Color0.G * (1.0f - lerp) + (brush.Color1.G * lerp)); byte b = (byte)(brush.Color0.B * (1.0f - lerp) + (brush.Color1.B * lerp)); byte a = (byte)(brush.Color0.A * (1.0f - lerp) + (brush.Color1.A * lerp)); GL.Color4(r, g, b, a); GL.Vertex2(pt.X, pt.Y); } GL.End(); } }
public void DrawConvexPath(GLConvexPath geo, GLBrush brush) { GL.Enable(EnableCap.LineSmooth); GL.Color4(brush.Color0); GL.Begin(BeginMode.LineLoop); foreach (var pt in geo.Points) { GL.Vertex2(pt.X + 0.5f, pt.Y + 0.5f); } GL.End(); GL.Disable(EnableCap.LineSmooth); }
public void FillAndDrawConvexPath(GLConvexPath geo, GLBrush fillBrush, GLBrush lineBrush, float lineWidth = 1.0f) { FillConvexPath(geo, fillBrush); DrawConvexPath(geo, lineBrush, lineWidth); }