public static IEnumerable <VertexData> GetVertexIter(this Curve4Div curve)
        {
            ArrayList <Vector2> m_points   = curve.GetInternalPoints();
            VertexData          vertexData = new VertexData();

            vertexData.command  = VertexCmd.MoveTo;
            vertexData.position = m_points[0];
            yield return(vertexData);

            vertexData.command = VertexCmd.LineTo;
            for (int i = 1; i < m_points.Count; i++)
            {
                vertexData.position = m_points[i];
                yield return(vertexData);
            }

            vertexData.command  = VertexCmd.NoMore;
            vertexData.position = new Vector2();
            yield return(vertexData);
        }
Exemplo n.º 2
0
        static void CreateBezierVxs4(VertexStore vxs,
                                     double x0, double y0,
                                     double x1, double y1,
                                     double x2, double y2,
                                     double x3, double y3)
        {
            //1. subdiv technique

            s_curve4Div.Init(x0, y0, x1, y1, x2, y2, x3, y3);
            ArrayList <Vector2> points = s_curve4Div.GetInternalPoints();

            int n = 0;

            for (int i = points.Length - 1; i >= 0; --i)
            {
                Vector2 p = points[n++];
                vxs.AddLineTo(p.x, p.y);
            }


            //----------------------------------------
            //2. old tech --  use incremental
            //var curve = new VectorMath.BezierCurveCubic(
            //    start, end,
            //    control1, control2);
            //vxs.AddLineTo(start.x, start.y);
            //float eachstep = (float)1 / NSteps;
            //float stepSum = eachstep;//start
            //for (int i = NSteps - 1; i >= 0; --i)
            //{
            //    var vector2 = curve.CalculatePoint(stepSum);
            //    vxs.AddLineTo(vector2.x, vector2.y);
            //    stepSum += eachstep;
            //}
            //vxs.AddLineTo(end.x, end.y);
        }