当前位置: 首页>>代码示例>>C#>>正文


C# PointF.ToVertex2F方法代码示例

本文整理汇总了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);
        }
开发者ID:hcxyzlm,项目名称:CocosNet-1,代码行数:60,代码来源:Primitives.cs

示例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);
        }
开发者ID:hcxyzlm,项目名称:CocosNet-1,代码行数:21,代码来源:Primitives.cs

示例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);
        }
开发者ID:hcxyzlm,项目名称:CocosNet-1,代码行数:11,代码来源:Primitives.cs

示例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);
        }
开发者ID:hcxyzlm,项目名称:CocosNet-1,代码行数:14,代码来源:Primitives.cs


注:本文中的System.Drawing.PointF.ToVertex2F方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。