本文整理汇总了C#中System.Drawing.PointF.ToVertex2F方法的典型用法代码示例。如果您正苦于以下问题:C# PointF.ToVertex2F方法的具体用法?C# PointF.ToVertex2F怎么用?C# PointF.ToVertex2F使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.PointF
的用法示例。
在下文中一共展示了PointF.ToVertex2F方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawCircle
// public static void FillPoly(PointF[] points, Color color) {
// if (points == null) {
// throw new ArgumentNullException("points");
// }
//
// byte[] colors = new byte[points.Length * 4];
// for (int i = 0; i < colors.Length; i += 4) {
// colors[i] = color.R;
// colors[i + 1] = color.G;
// colors[i + 2] = color.B;
// colors[i + 3] = color.A;
// }
//
// GL.ColorPointer(4, All.UnsignedByte, 0, colors);
// GL.EnableClientState(All.ColorArray);
//
//
// if (color.A != 255) {
// GL.BlendFunc(All.SrcAlpha, All.OneMinusSrcAlpha);
// }
//
// Vertex2F[] poli = PointsToVerticesForTriangleStrip(points);
//
// GL.VertexPointer(2, All.Float, 0, poli);
// GL.EnableClientState(All.VertexArray);
//
// GL.DrawArrays(All.TriangleStrip, 0, poli.Length);
//
// GL.DisableClientState(All.ColorArray);
// GL.DisableClientState(All.VertexArray);
//
// if (color.A != 255) {
// GL.BlendFunc(BlendFunc.DefaultBlendSrc, BlendFunc.DefaultBlendDst);
// }
// }
public static void DrawCircle(PointF center, float radius, float a, int segments, bool drawLineToCenter)
{
int additionalSegment = drawLineToCenter ? 2 : 1;
float coef = 2f * (float)Math.PI / segments;
Vertex2F[] vertices = new Vertex2F[segments + 2];
for (int i = 0; i <= segments; ++i) {
float rads = i * coef;
float j = radius * (float)Math.Cos(rads + a) + center.X;
float k = radius * (float)Math.Sin(rads + a) + center.Y;
vertices[i].X = j;
vertices[i].Y = k;
}
vertices[segments + 1] = center.ToVertex2F();
GL.VertexPointer(2, All.Float, 0, vertices);
GL.EnableClientState(All.VertexArray);
GL.DrawArrays(All.LineStrip, 0, segments + additionalSegment);
GL.DisableClientState(All.VertexArray);
}
示例2: DrawCubicBezier
public static void DrawCubicBezier(PointF origin, PointF control1, PointF control2, PointF destination, int segments)
{
Vertex2F[] vertices = new Vertex2F[segments + 1];
float t = 0;
for (int i = 0; i < segments; ++i) {
float x = (float)Math.Pow(1 - t, 3) * origin.X + 3.0f * (float)Math.Pow(1 - t, 2) * t * control1.X + 3.0f * (1 - t) * t * t * control2.X + t * t * t * destination.X;
float y = (float)Math.Pow(1 - t, 3) * origin.Y + 3.0f * (float)Math.Pow(1 - t, 2) * t * control1.Y + 3.0f * (1 - t) * t * t * control2.Y + t * t * t * destination.Y;
vertices[i].X = x;
vertices[i].Y = y;
t += 1f / segments;
}
vertices[segments] = destination.ToVertex2F();
GL.VertexPointer(2, All.Float, 0, vertices);
GL.EnableClientState(All.VertexArray);
GL.DrawArrays(All.LineStrip, 0, segments + 1);
GL.DisableClientState(All.VertexArray);
}
示例3: DrawPoint
public static void DrawPoint(PointF point)
{
Vertex2F[] vertex = { point.ToVertex2F() };
GL.VertexPointer(2, All.Float, 0, vertex);
GL.EnableClientState(All.VertexArray);
GL.DrawArrays(All.Points, 0, 1);
GL.DisableClientState(All.VertexArray);
}
示例4: DrawLine
public static void DrawLine(PointF origin, PointF destination)
{
Vertex2F[] vertices = {
origin.ToVertex2F(),
destination.ToVertex2F()
};
GL.VertexPointer(2, All.Float, 0, vertices);
GL.EnableClientState(All.VertexArray);
GL.DrawArrays(All.Lines, 0, 2);
GL.DisableClientState(All.VertexArray);
}