示例#1
0
        public override IEnumerable <VertexData> Vertices()
        {
            for (int i = 0; i < SourcePaths.Count; i++)
            {
                IVertexSource sourcePath = SourcePaths[i];
                bool          firstMove  = true;
                foreach (VertexData vertexData in sourcePath.Vertices())
                {
                    // skip the initial command if it is not the first path and is a moveto.
                    if (i > 0 &&
                        firstMove &&
                        ShapePath.is_move_to(vertexData.command))
                    {
                        continue;
                    }

                    // when we hit a stop move on to the next path
                    if (ShapePath.is_stop(vertexData.command))
                    {
                        break;
                    }
                    yield return(vertexData);
                }
            }

            // and send the actual stop
            yield return(new VertexData(ShapePath.FlagsAndCommand.EndPoly | ShapePath.FlagsAndCommand.FlagClose | ShapePath.FlagsAndCommand.FlagCCW, new Vector2()));

            yield return(new VertexData(ShapePath.FlagsAndCommand.Stop, new Vector2()));
        }
示例#2
0
        public override ShapePath.FlagsAndCommand vertex(out double x, out double y)
        {
            x = 0;
            y = 0;
            ShapePath.FlagsAndCommand cmd = ShapePath.FlagsAndCommand.CommandStop;
            switch (m_idx)
            {
            case 0:
            case 1:
            case 2:
                cmd = m_stroke.vertex(out x, out y);
                break;

            case 3:
            case 4:
            case 5:
            case 6:
                cmd = m_ellipse.vertex(out x, out y);
                break;
            }

            if (!ShapePath.is_stop(cmd))
            {
                ParentToChildTransform.transform(ref x, ref y);
            }
            return(cmd);
        }
示例#3
0
        public IEnumerable <VertexData> Vertices()
        {
            currentProcessingArc.init(bounds.Left + leftBottomRadius.x, bounds.Bottom + leftBottomRadius.y, leftBottomRadius.x, leftBottomRadius.y, Math.PI, Math.PI + Math.PI * 0.5);
            foreach (VertexData vertexData in currentProcessingArc.Vertices())
            {
                if (ShapePath.is_stop(vertexData.command))
                {
                    break;
                }
                yield return(vertexData);
            }
            currentProcessingArc.init(bounds.Right - rightBottomRadius.x, bounds.Bottom + rightBottomRadius.y, rightBottomRadius.x, rightBottomRadius.y, Math.PI + Math.PI * 0.5, 0.0);
            foreach (VertexData vertexData in currentProcessingArc.Vertices())
            {
                if (ShapePath.is_move_to(vertexData.command))
                {
                    // skip the initial moveto
                    continue;
                }
                if (ShapePath.is_stop(vertexData.command))
                {
                    break;
                }
                yield return(vertexData);
            }

            currentProcessingArc.init(bounds.Right - rightTopRadius.x, bounds.Top - rightTopRadius.y, rightTopRadius.x, rightTopRadius.y, 0.0, Math.PI * 0.5);
            foreach (VertexData vertexData in currentProcessingArc.Vertices())
            {
                if (ShapePath.is_move_to(vertexData.command))
                {
                    // skip the initial moveto
                    continue;
                }
                if (ShapePath.is_stop(vertexData.command))
                {
                    break;
                }
                yield return(vertexData);
            }

            currentProcessingArc.init(bounds.Left + leftTopRadius.x, bounds.Top - leftTopRadius.y, leftTopRadius.x, leftTopRadius.y, Math.PI * 0.5, Math.PI);
            foreach (VertexData vertexData in currentProcessingArc.Vertices())
            {
                if (ShapePath.is_move_to(vertexData.command))
                {
                    // skip the initial moveto
                    continue;
                }
                if (ShapePath.is_stop(vertexData.command))
                {
                    break;
                }
                yield return(vertexData);
            }

            yield return(new VertexData(ShapePath.FlagsAndCommand.CommandEndPoly | ShapePath.FlagsAndCommand.FlagClose | ShapePath.FlagsAndCommand.FlagCCW, new Vector2()));

            yield return(new VertexData(ShapePath.FlagsAndCommand.CommandStop, new Vector2()));
        }
示例#4
0
        public ShapePath.FlagsAndCommand vertex(out double x, out double y)
        {
            x = 0;
            y = 0;

            if (ShapePath.is_stop(m_NextPathCommand))
            {
                return(ShapePath.FlagsAndCommand.CommandStop);
            }

            if ((m_CurrentFlatenAngle < endAngle - flatenDeltaAngle / 4) != ((int)EDirection.CounterClockWise == 1))
            {
                x = originX + Math.Cos(endAngle) * radiusX;
                y = originY + Math.Sin(endAngle) * radiusY;
                m_NextPathCommand = ShapePath.FlagsAndCommand.CommandStop;

                return(ShapePath.FlagsAndCommand.CommandLineTo);
            }

            x = originX + Math.Cos(m_CurrentFlatenAngle) * radiusX;
            y = originY + Math.Sin(m_CurrentFlatenAngle) * radiusY;

            m_CurrentFlatenAngle += flatenDeltaAngle;

            ShapePath.FlagsAndCommand CurrentPathCommand = m_NextPathCommand;
            m_NextPathCommand = ShapePath.FlagsAndCommand.CommandLineTo;
            return(CurrentPathCommand);
        }
示例#5
0
 // Make path functions
 //--------------------------------------------------------------------
 public int start_new_path()
 {
     if (!ShapePath.is_stop(vertices.last_command()))
     {
         vertices.AddVertex(0.0, 0.0, ShapePath.FlagsAndCommand.CommandStop);
     }
     return(vertices.total_vertices());
 }
示例#6
0
        public override ShapePath.FlagsAndCommand vertex(out double x, out double y)
        {
            x = 0;
            y = 0;
            ShapePath.FlagsAndCommand cmd = ShapePath.FlagsAndCommand.LineTo;
            switch (m_idx)
            {
            case 0:
                if (m_vertex == 0)
                {
                    cmd = ShapePath.FlagsAndCommand.MoveTo;
                }
                if (m_vertex >= 4)
                {
                    cmd = ShapePath.FlagsAndCommand.Stop;
                }
                x = m_vx[m_vertex];
                y = m_vy[m_vertex];
                m_vertex++;
                break;

            case 1:
                if (m_vertex == 0 || m_vertex == 4)
                {
                    cmd = ShapePath.FlagsAndCommand.MoveTo;
                }
                if (m_vertex >= 8)
                {
                    cmd = ShapePath.FlagsAndCommand.Stop;
                }
                x = m_vx[m_vertex];
                y = m_vy[m_vertex];
                m_vertex++;
                break;

            case 2:
                cmd = m_curve_poly.vertex(out x, out y);
                break;

            case 3:
            case 4:
                cmd = m_curve_pnt.vertex(out x, out y);
                break;

            default:
                cmd = ShapePath.FlagsAndCommand.Stop;
                break;
            }

            if (!ShapePath.is_stop(cmd))
            {
                //OriginRelativeParentTransform.transform(ref x, ref y);
            }

            return(cmd);
        }
示例#7
0
        public void concat_path(IVertexSource vs, int path_id)
        {
            double x, y;

            ShapePath.FlagsAndCommand PathAndFlags;
            vs.rewind(path_id);
            while (!ShapePath.is_stop(PathAndFlags = vs.vertex(out x, out y)))
            {
                vertices.AddVertex(x, y, PathAndFlags);
            }
        }
示例#8
0
        public ShapePath.FlagsAndCommand vertex(out double x, out double y)
        {
            if (!ShapePath.is_stop(m_curve3.vertex(out x, out y)))
            {
                lastX = x;
                lastY = y;
                return(ShapePath.FlagsAndCommand.CommandLineTo);
            }

            if (!ShapePath.is_stop(m_curve4.vertex(out x, out y)))
            {
                lastX = x;
                lastY = y;
                return(ShapePath.FlagsAndCommand.CommandLineTo);
            }

            double ct2_x;
            double ct2_y;
            double end_x;
            double end_y;

            ShapePath.FlagsAndCommand cmd = VertexSource.vertex(out x, out y);
            switch (cmd)
            {
            case ShapePath.FlagsAndCommand.CommandCurve3:
                VertexSource.vertex(out end_x, out end_y);

                m_curve3.init(lastX, lastY, x, y, end_x, end_y);

                m_curve3.vertex(out x, out y);                            // First call returns path_cmd_move_to
                m_curve3.vertex(out x, out y);                            // This is the first vertex of the curve
                cmd = ShapePath.FlagsAndCommand.CommandLineTo;
                break;

            case ShapePath.FlagsAndCommand.CommandCurve4:
                VertexSource.vertex(out ct2_x, out ct2_y);
                VertexSource.vertex(out end_x, out end_y);

                m_curve4.init(lastX, lastY, x, y, ct2_x, ct2_y, end_x, end_y);

                m_curve4.vertex(out x, out y);                            // First call returns path_cmd_move_to
                m_curve4.vertex(out x, out y);                            // This is the first vertex of the curve
                cmd = ShapePath.FlagsAndCommand.CommandLineTo;
                break;
            }
            lastX = x;
            lastY = y;
            return(cmd);
        }
示例#9
0
 public int arrange_orientations(int start, ShapePath.FlagsAndCommand orientation)
 {
     if (orientation != ShapePath.FlagsAndCommand.FlagNone)
     {
         while (start < vertices.total_vertices())
         {
             start = arrange_polygon_orientation(start, orientation);
             if (ShapePath.is_stop(vertices.command(start)))
             {
                 ++start;
                 break;
             }
         }
     }
     return(start);
 }
示例#10
0
        public void join_path(PathStorage vs, int path_id)
        {
            double x, y;

            vs.rewind(path_id);
            ShapePath.FlagsAndCommand PathAndFlags = vs.vertex(out x, out y);
            if (!ShapePath.is_stop(PathAndFlags))
            {
                if (ShapePath.is_vertex(PathAndFlags))
                {
                    double x0, y0;
                    ShapePath.FlagsAndCommand PathAndFlags0 = last_vertex(out x0, out y0);
                    if (ShapePath.is_vertex(PathAndFlags0))
                    {
                        if (agg_math.calc_distance(x, y, x0, y0) > agg_math.vertex_dist_epsilon)
                        {
                            if (ShapePath.is_move_to(PathAndFlags))
                            {
                                PathAndFlags = ShapePath.FlagsAndCommand.CommandLineTo;
                            }
                            vertices.AddVertex(x, y, PathAndFlags);
                        }
                    }
                    else
                    {
                        if (ShapePath.is_stop(PathAndFlags0))
                        {
                            PathAndFlags = ShapePath.FlagsAndCommand.CommandMoveTo;
                        }
                        else
                        {
                            if (ShapePath.is_move_to(PathAndFlags))
                            {
                                PathAndFlags = ShapePath.FlagsAndCommand.CommandLineTo;
                            }
                        }
                        vertices.AddVertex(x, y, PathAndFlags);
                    }
                }
                while (!ShapePath.is_stop(PathAndFlags = vs.vertex(out x, out y)))
                {
                    vertices.AddVertex(x, y, ShapePath.is_move_to(PathAndFlags) ?
                                       ShapePath.FlagsAndCommand.CommandLineTo :
                                       PathAndFlags);
                }
            }
        }
示例#11
0
        public static void SendShapeToTesselator(VertexTesselatorAbstract tesselator, IVertexSource vertexSource)
        {
#if !DEBUG
            try
#endif
            {
                tesselator.BeginPolygon();

                ShapePath.FlagsAndCommand PathAndFlags = 0;
                double x, y;
                bool   haveBegunContour = false;
                while (!ShapePath.is_stop(PathAndFlags = vertexSource.vertex(out x, out y)))
                {
                    if (ShapePath.is_close(PathAndFlags) ||
                        (haveBegunContour && ShapePath.is_move_to(PathAndFlags)))
                    {
                        tesselator.EndContour();
                        haveBegunContour = false;
                    }

                    if (!ShapePath.is_close(PathAndFlags))
                    {
                        if (!haveBegunContour)
                        {
                            tesselator.BeginContour();
                            haveBegunContour = true;
                        }

                        tesselator.AddVertex(x, y);
                    }
                }

                if (haveBegunContour)
                {
                    tesselator.EndContour();
                }

                tesselator.EndPolygon();
            }
#if !DEBUG
            catch
            {
            }
#endif
        }
示例#12
0
        override public IEnumerable <VertexData> Vertices()
        {
            // return all the data for the glyph
            foreach (VertexData vertexData in glyph.Vertices())
            {
                if (ShapePath.is_stop(vertexData.command))
                {
                    break;
                }
                yield return(vertexData);
            }

            // then the underline
            foreach (VertexData vertexData in underline.Vertices())
            {
                yield return(vertexData);
            }
        }
示例#13
0
        override public IEnumerable <VertexData> Vertices()
        {
            IVertexSource sourcePath = SourcPath;

            foreach (VertexData vertexData in sourcePath.Vertices())
            {
                // when we hit the initial stop. Skip it
                if (ShapePath.is_stop(vertexData.command))
                {
                    break;
                }
                yield return(vertexData);
            }

            // and send the actual stop
            yield return(new VertexData(ShapePath.FlagsAndCommand.EndPoly | ShapePath.FlagsAndCommand.FlagClose | ShapePath.FlagsAndCommand.FlagCCW, new Vector2()));

            yield return(new VertexData(ShapePath.FlagsAndCommand.Stop, new Vector2()));
        }
示例#14
0
        public override ShapePath.FlagsAndCommand vertex(out double x, out double y)
        {
            ShapePath.FlagsAndCommand cmd = ShapePath.FlagsAndCommand.Stop;
            double r = m_point_radius;

            if (m_status == 0)
            {
                cmd = m_stroke.vertex(out x, out y);
                if (!ShapePath.is_stop(cmd))
                {
                    ParentToChildTransform.transform(ref x, ref y);
                    return(cmd);
                }
                if (m_node >= 0 && m_node == (int)(m_status))
                {
                    r *= 1.2;
                }
                m_ellipse.init(GetXN(m_status), GetYN(m_status), r, r, 32);
                ++m_status;
            }
            cmd = m_ellipse.vertex(out x, out y);
            if (!ShapePath.is_stop(cmd))
            {
                ParentToChildTransform.transform(ref x, ref y);
                return(cmd);
            }
            if (m_status >= m_num_points)
            {
                return(ShapePath.FlagsAndCommand.Stop);
            }
            if (m_node >= 0 && m_node == (int)(m_status))
            {
                r *= 1.2;
            }
            m_ellipse.init(GetXN(m_status), GetYN(m_status), r, r, 32);
            ++m_status;
            cmd = m_ellipse.vertex(out x, out y);
            if (!ShapePath.is_stop(cmd))
            {
                ParentToChildTransform.transform(ref x, ref y);
            }
            return(cmd);
        }
示例#15
0
        public void transform(Transform.Affine trans, int path_id)
        {
            int num_ver = vertices.total_vertices();

            for (; path_id < num_ver; path_id++)
            {
                double x, y;
                ShapePath.FlagsAndCommand PathAndFlags = vertices.vertex(path_id, out x, out y);
                if (ShapePath.is_stop(PathAndFlags))
                {
                    break;
                }
                if (ShapePath.is_vertex(PathAndFlags))
                {
                    trans.transform(ref x, ref y);
                    vertices.modify_vertex(path_id, x, y);
                }
            }
        }
示例#16
0
        public void translate(double dx, double dy, int path_id)
        {
            int num_ver = vertices.total_vertices();

            for (; path_id < num_ver; path_id++)
            {
                double x, y;
                ShapePath.FlagsAndCommand PathAndFlags = vertices.vertex(path_id, out x, out y);
                if (ShapePath.is_stop(PathAndFlags))
                {
                    break;
                }
                if (ShapePath.is_vertex(PathAndFlags))
                {
                    x += dx;
                    y += dy;
                    vertices.modify_vertex(path_id, x, y);
                }
            }
        }
示例#17
0
        public override IEnumerable <VertexData> Vertices()
        {
            for (int i = 0; i < SourcePaths.Count; i++)
            {
                IVertexSource sourcePath = SourcePaths[i];
                foreach (VertexData vertexData in sourcePath.Vertices())
                {
                    // when we hit a stop move on to the next path
                    if (ShapePath.is_stop(vertexData.command))
                    {
                        break;
                    }
                    yield return(vertexData);
                }
            }

            // and send the actual stop
            yield return(new VertexData(ShapePath.FlagsAndCommand.EndPoly | ShapePath.FlagsAndCommand.FlagClose | ShapePath.FlagsAndCommand.FlagCCW, new Vector2()));

            yield return(new VertexData(ShapePath.FlagsAndCommand.Stop, new Vector2()));
        }
示例#18
0
        public ShapePath.FlagsAndCommand vertex(out double x, out double y)
        {
            x = 0;
            y = 0;
            ShapePath.FlagsAndCommand cmd = ShapePath.FlagsAndCommand.CommandStop;
            switch (state)
            {
            case 0:
                cmd = glyph.vertex(out x, out y);
                if (ShapePath.is_stop(cmd))
                {
                    state++;
                    goto case 1;
                }
                return(cmd);

            case 1:
                cmd = underline.vertex(out x, out y);
                break;
            }
            return(cmd);
        }
示例#19
0
        private List <Vertex> TesselateLines(List <Vector2> points, Pen p)
        {
            List <ContourVertex> vecs = new List <ContourVertex>();
            List <Vertex>        ret  = new List <Vertex>();

            if (points.Count < 2)
            {
                return(ret);
            }
            var co = color(p.Color);

            MatterHackers.Agg.VertexSource.PathStorage ps = new MatterHackers.Agg.VertexSource.PathStorage();
            ps.remove_all();
            ps.MoveTo(points[0].X, points[0].Y);

            for (int i = 1; i < points.Count; i++)
            {
                ps.LineTo(points[i].X, points[i].Y);
            }
            ps.end_poly();

            MatterHackers.Agg.VertexSource.Stroke str = new MatterHackers.Agg.VertexSource.Stroke(ps, p.Width);
            switch (p.Join)
            {
            case LineJoin.Round:
                str.line_join(MatterHackers.Agg.VertexSource.LineJoin.Round);
                str.inner_join(MatterHackers.Agg.VertexSource.InnerJoin.Round);

                break;

            case LineJoin.Miter:
                str.line_join(MatterHackers.Agg.VertexSource.LineJoin.Miter);
                str.inner_join(MatterHackers.Agg.VertexSource.InnerJoin.Miter);
                str.inner_miter_limit(p.MiterLimit);
                str.miter_limit(p.MiterLimit);
                break;
            }
            switch (p.Cap)
            {
            case LineCaps.Butt:
                str.line_cap(MatterHackers.Agg.VertexSource.LineCap.Butt);
                break;

            case LineCaps.Round:
                str.line_cap(MatterHackers.Agg.VertexSource.LineCap.Round);
                break;

            case LineCaps.Square:
                str.line_cap(MatterHackers.Agg.VertexSource.LineCap.Square);
                break;
            }
            str.rewind(0);
            double x, y;

            LibTessDotNet.Tess t = new LibTessDotNet.Tess();

            ShapePath.FlagsAndCommand cmd;
            do
            {
                cmd = str.vertex(out x, out y);
                if (ShapePath.is_vertex(cmd))
                {
                    vecs.Add(new ContourVertex()
                    {
                        Position = new Vec3()
                        {
                            X = (float)x, Y = (float)y
                        }
                    });
                }
                if (ShapePath.is_end_poly(cmd))
                {
                    t.AddContour(vecs.ToArray());
                    vecs.Clear();
                }
            } while (!ShapePath.is_stop(cmd));

            /*
             * foreach (var v in vertices)
             * {
             * if (!ShapePath.is_close(v.command) && !ShapePath.is_stop(v.command))
             * vecs.Add(new Vector2((float)v.position.x, (float)v.position.y));
             * }*/
            if (vecs.Count != 0)
            {
                t.AddContour(vecs.ToArray());
            }
            t.Tessellate(LibTessDotNet.WindingRule.NonZero, LibTessDotNet.ElementType.Polygons, 3);
            for (var i = 0; i < t.ElementCount; i++)
            {
                for (var tri = 0; tri < 3; tri++)
                {
                    var v = t.Vertices[t.Elements[(i * 3) + tri]].Position;
                    ret.Add(new Vertex(v.X, v.Y, co));
                }
            }
            return(ret);
        }
示例#20
0
        public ShapePath.FlagsAndCommand Vertex(ref double x, ref double y)
        {
            ShapePath.FlagsAndCommand cmd = ShapePath.FlagsAndCommand.CommandLineTo;
            while (!ShapePath.is_stop(cmd))
            {
                switch (m_status)
                {
                case StrokeMath.status_e.initial:
                    Rewind(0);
                    goto case StrokeMath.status_e.ready;

                case StrokeMath.status_e.ready:
                    if (m_src_vertices.size() < 2 + (m_closed != 0 ? 1 : 0))
                    {
                        cmd = ShapePath.FlagsAndCommand.CommandStop;
                        break;
                    }
                    m_status     = (m_closed != 0) ? StrokeMath.status_e.outline1 : StrokeMath.status_e.cap1;
                    cmd          = ShapePath.FlagsAndCommand.CommandMoveTo;
                    m_src_vertex = 0;
                    m_out_vertex = 0;
                    break;

                case StrokeMath.status_e.cap1:
                    m_stroker.calc_cap(m_out_vertices, m_src_vertices[0], m_src_vertices[1],
                                       m_src_vertices[0].dist);
                    m_src_vertex  = 1;
                    m_prev_status = StrokeMath.status_e.outline1;
                    m_status      = StrokeMath.status_e.out_vertices;
                    m_out_vertex  = 0;
                    break;

                case StrokeMath.status_e.cap2:
                    m_stroker.calc_cap(m_out_vertices,
                                       m_src_vertices[m_src_vertices.size() - 1],
                                       m_src_vertices[m_src_vertices.size() - 2],
                                       m_src_vertices[m_src_vertices.size() - 2].dist);
                    m_prev_status = StrokeMath.status_e.outline2;
                    m_status      = StrokeMath.status_e.out_vertices;
                    m_out_vertex  = 0;
                    break;

                case StrokeMath.status_e.outline1:
                    if (m_closed != 0)
                    {
                        if (m_src_vertex >= m_src_vertices.size())
                        {
                            m_prev_status = StrokeMath.status_e.close_first;
                            m_status      = StrokeMath.status_e.end_poly1;
                            break;
                        }
                    }
                    else
                    {
                        if (m_src_vertex >= m_src_vertices.size() - 1)
                        {
                            m_status = StrokeMath.status_e.cap2;
                            break;
                        }
                    }
                    m_stroker.calc_join(m_out_vertices,
                                        m_src_vertices.prev(m_src_vertex),
                                        m_src_vertices.curr(m_src_vertex),
                                        m_src_vertices.next(m_src_vertex),
                                        m_src_vertices.prev(m_src_vertex).dist,
                                        m_src_vertices.curr(m_src_vertex).dist);
                    ++m_src_vertex;
                    m_prev_status = m_status;
                    m_status      = StrokeMath.status_e.out_vertices;
                    m_out_vertex  = 0;
                    break;

                case StrokeMath.status_e.close_first:
                    m_status = StrokeMath.status_e.outline2;
                    cmd      = ShapePath.FlagsAndCommand.CommandMoveTo;
                    goto case StrokeMath.status_e.outline2;

                case StrokeMath.status_e.outline2:
                    if (m_src_vertex <= (m_closed == 0 ? 1 : 0))
                    {
                        m_status      = StrokeMath.status_e.end_poly2;
                        m_prev_status = StrokeMath.status_e.stop;
                        break;
                    }

                    --m_src_vertex;
                    m_stroker.calc_join(m_out_vertices,
                                        m_src_vertices.next(m_src_vertex),
                                        m_src_vertices.curr(m_src_vertex),
                                        m_src_vertices.prev(m_src_vertex),
                                        m_src_vertices.curr(m_src_vertex).dist,
                                        m_src_vertices.prev(m_src_vertex).dist);

                    m_prev_status = m_status;
                    m_status      = StrokeMath.status_e.out_vertices;
                    m_out_vertex  = 0;
                    break;

                case StrokeMath.status_e.out_vertices:
                    if (m_out_vertex >= m_out_vertices.size())
                    {
                        m_status = m_prev_status;
                    }
                    else
                    {
                        Vector2 c = m_out_vertices[(int)m_out_vertex++];
                        x = c.x;
                        y = c.y;
                        return(cmd);
                    }
                    break;

                case StrokeMath.status_e.end_poly1:
                    m_status = m_prev_status;
                    return(ShapePath.FlagsAndCommand.CommandEndPoly
                           | ShapePath.FlagsAndCommand.FlagClose
                           | ShapePath.FlagsAndCommand.FlagCCW);

                case StrokeMath.status_e.end_poly2:
                    m_status = m_prev_status;
                    return(ShapePath.FlagsAndCommand.CommandEndPoly
                           | ShapePath.FlagsAndCommand.FlagClose
                           | ShapePath.FlagsAndCommand.FlagCW);

                case StrokeMath.status_e.stop:
                    cmd = ShapePath.FlagsAndCommand.CommandStop;
                    break;
                }
            }
            return(cmd);
        }
示例#21
0
        public IEnumerable <VertexData> Vertices()
        {
            VertexData lastPosition = new VertexData();

            IEnumerator <VertexData> vertexDataEnumerator = VertexSource.Vertices().GetEnumerator();

            while (vertexDataEnumerator.MoveNext())
            {
                VertexData vertexData = vertexDataEnumerator.Current;
                switch (vertexData.command)
                {
                case ShapePath.FlagsAndCommand.CommandCurve3:
                {
                    vertexDataEnumerator.MoveNext();
                    VertexData vertexDataEnd = vertexDataEnumerator.Current;
                    m_curve3.init(lastPosition.position.x, lastPosition.position.y, vertexData.position.x, vertexData.position.y, vertexDataEnd.position.x, vertexDataEnd.position.y);
                    IEnumerator <VertexData> curveIterator = m_curve3.Vertices().GetEnumerator();
                    curveIterator.MoveNext();                                     // First call returns path_cmd_move_to
                    do
                    {
                        curveIterator.MoveNext();
                        if (ShapePath.is_stop(curveIterator.Current.command))
                        {
                            break;
                        }
                        vertexData = new VertexData(ShapePath.FlagsAndCommand.CommandLineTo, curveIterator.Current.position);
                        yield return(vertexData);

                        lastPosition = vertexData;
                    } while (!ShapePath.is_stop(curveIterator.Current.command));
                }
                break;

                case ShapePath.FlagsAndCommand.CommandCurve4:
                {
                    vertexDataEnumerator.MoveNext();
                    VertexData vertexDataControl = vertexDataEnumerator.Current;
                    vertexDataEnumerator.MoveNext();
                    VertexData vertexDataEnd = vertexDataEnumerator.Current;
                    m_curve4.init(lastPosition.position.x, lastPosition.position.y, vertexData.position.x, vertexData.position.y, vertexDataControl.position.x, vertexDataControl.position.y, vertexDataEnd.position.x, vertexDataEnd.position.y);
                    IEnumerator <VertexData> curveIterator = m_curve4.Vertices().GetEnumerator();
                    curveIterator.MoveNext();                                     // First call returns path_cmd_move_to
                    while (!ShapePath.is_stop(vertexData.command))
                    {
                        curveIterator.MoveNext();
                        if (ShapePath.is_stop(curveIterator.Current.command))
                        {
                            break;
                        }
                        vertexData = new VertexData(ShapePath.FlagsAndCommand.CommandLineTo, curveIterator.Current.position);
                        yield return(vertexData);

                        lastPosition = vertexData;
                    }
                }
                break;

                default:
                    yield return(vertexData);

                    lastPosition = vertexData;
                    break;
                }
            }
        }
示例#22
0
        public ShapePath.FlagsAndCommand vertex(out double x, out double y)
        {
            x = 0;
            y = 0;
            ShapePath.FlagsAndCommand cmd = ShapePath.FlagsAndCommand.CommandStop;
            switch (state)
            {
            case 0:
                currentProcessingArc.init(bounds.Left + leftBottomRadius.x, bounds.Bottom + leftBottomRadius.y, leftBottomRadius.x, leftBottomRadius.y,
                                          Math.PI, Math.PI + Math.PI * 0.5);
                currentProcessingArc.rewind(0);
                state++;
                goto case 1;

            case 1:
                cmd = currentProcessingArc.vertex(out x, out y);
                if (ShapePath.is_stop(cmd))
                {
                    state++;
                }
                else
                {
                    return(cmd);
                }
                goto case 2;

            case 2:
                currentProcessingArc.init(bounds.Right - rightBottomRadius.x, bounds.Bottom + rightBottomRadius.y, rightBottomRadius.x, rightBottomRadius.y,
                                          Math.PI + Math.PI * 0.5, 0.0);
                currentProcessingArc.rewind(0);
                state++;
                goto case 3;

            case 3:
                cmd = currentProcessingArc.vertex(out x, out y);
                if (ShapePath.is_stop(cmd))
                {
                    state++;
                }
                else
                {
                    return(ShapePath.FlagsAndCommand.CommandLineTo);
                }
                goto case 4;

            case 4:
                currentProcessingArc.init(bounds.Right - rightTopRadius.x, bounds.Top - rightTopRadius.y, rightTopRadius.x, rightTopRadius.y,
                                          0.0, Math.PI * 0.5);
                currentProcessingArc.rewind(0);
                state++;
                goto case 5;

            case 5:
                cmd = currentProcessingArc.vertex(out x, out y);
                if (ShapePath.is_stop(cmd))
                {
                    state++;
                }
                else
                {
                    return(ShapePath.FlagsAndCommand.CommandLineTo);
                }
                goto case 6;

            case 6:
                currentProcessingArc.init(bounds.Left + leftTopRadius.x, bounds.Top - leftTopRadius.y, leftTopRadius.x, leftTopRadius.y,
                                          Math.PI * 0.5, Math.PI);
                currentProcessingArc.rewind(0);
                state++;
                goto case 7;

            case 7:
                cmd = currentProcessingArc.vertex(out x, out y);
                if (ShapePath.is_stop(cmd))
                {
                    state++;
                }
                else
                {
                    return(ShapePath.FlagsAndCommand.CommandLineTo);
                }
                goto case 8;

            case 8:
                cmd = ShapePath.FlagsAndCommand.CommandEndPoly
                      | ShapePath.FlagsAndCommand.FlagClose
                      | ShapePath.FlagsAndCommand.FlagCCW;
                state++;
                break;
            }
            return(cmd);
        }
示例#23
0
        public ShapePath.FlagsAndCommand vertex(out double x, out double y)
        {
            x = 0;
            y = 0;
            ShapePath.FlagsAndCommand command = ShapePath.FlagsAndCommand.CommandStop;
            bool done = false;

            while (!done)
            {
                switch (m_status)
                {
                case status.initial:
                    markers.remove_all();
                    m_last_cmd = VertexSource.vertex(out m_start_x, out m_start_y);
                    m_status   = status.accumulate;
                    goto case status.accumulate;

                case status.accumulate:
                    if (ShapePath.is_stop(m_last_cmd))
                    {
                        return(ShapePath.FlagsAndCommand.CommandStop);
                    }

                    generator.RemoveAll();
                    generator.AddVertex(m_start_x, m_start_y, ShapePath.FlagsAndCommand.CommandMoveTo);
                    markers.add_vertex(m_start_x, m_start_y, ShapePath.FlagsAndCommand.CommandMoveTo);

                    for (; ;)
                    {
                        command = VertexSource.vertex(out x, out y);
                        //DebugFile.Print("x=" + x.ToString() + " y=" + y.ToString() + "\n");
                        if (ShapePath.is_vertex(command))
                        {
                            m_last_cmd = command;
                            if (ShapePath.is_move_to(command))
                            {
                                m_start_x = x;
                                m_start_y = y;
                                break;
                            }
                            generator.AddVertex(x, y, command);
                            markers.add_vertex(x, y, ShapePath.FlagsAndCommand.CommandLineTo);
                        }
                        else
                        {
                            if (ShapePath.is_stop(command))
                            {
                                m_last_cmd = ShapePath.FlagsAndCommand.CommandStop;
                                break;
                            }
                            if (ShapePath.is_end_poly(command))
                            {
                                generator.AddVertex(x, y, command);
                                break;
                            }
                        }
                    }
                    generator.Rewind(0);
                    m_status = status.generate;
                    goto case status.generate;

                case status.generate:
                    command = generator.Vertex(ref x, ref y);
                    //DebugFile.Print("x=" + x.ToString() + " y=" + y.ToString() + "\n");
                    if (ShapePath.is_stop(command))
                    {
                        m_status = status.accumulate;
                        break;
                    }
                    done = true;
                    break;
                }
            }
            return(command);
        }
示例#24
0
        public ShapePath.FlagsAndCommand Vertex(ref double x, ref double y)
        {
            ShapePath.FlagsAndCommand cmd = ShapePath.FlagsAndCommand.LineTo;
            while (!ShapePath.is_stop(cmd))
            {
                switch (m_status)
                {
                case StrokeMath.status_e.initial:
                    Rewind(0);
                    goto case StrokeMath.status_e.ready;

                case StrokeMath.status_e.ready:
                    if (m_src_vertices.size() < 2 + (m_closed ? 1 : 0))
                    {
                        cmd = ShapePath.FlagsAndCommand.Stop;
                        break;
                    }
                    m_status     = StrokeMath.status_e.outline1;
                    cmd          = ShapePath.FlagsAndCommand.MoveTo;
                    m_src_vertex = 0;
                    m_out_vertex = 0;
                    goto case StrokeMath.status_e.outline1;

                case StrokeMath.status_e.outline1:
                    if (m_src_vertex >= m_src_vertices.size())
                    {
                        m_status = StrokeMath.status_e.end_poly1;
                        break;
                    }
                    m_stroker.calc_join(m_out_vertices,
                                        m_src_vertices.prev(m_src_vertex),
                                        m_src_vertices.curr(m_src_vertex),
                                        m_src_vertices.next(m_src_vertex),
                                        m_src_vertices.prev(m_src_vertex).dist,
                                        m_src_vertices.curr(m_src_vertex).dist);
                    ++m_src_vertex;
                    m_status     = StrokeMath.status_e.out_vertices;
                    m_out_vertex = 0;
                    goto case StrokeMath.status_e.out_vertices;

                case StrokeMath.status_e.out_vertices:
                    if (m_out_vertex >= m_out_vertices.size())
                    {
                        m_status = StrokeMath.status_e.outline1;
                    }
                    else
                    {
                        Vector2 c = m_out_vertices[m_out_vertex++];
                        x = c.X;
                        y = c.Y;
                        return(cmd);
                    }
                    break;

                case StrokeMath.status_e.end_poly1:
                    if (!m_closed)
                    {
                        return(ShapePath.FlagsAndCommand.Stop);
                    }
                    m_status = StrokeMath.status_e.stop;
                    return(ShapePath.FlagsAndCommand.EndPoly | ShapePath.FlagsAndCommand.FlagClose | ShapePath.FlagsAndCommand.FlagCCW);

                case StrokeMath.status_e.stop:
                    return(ShapePath.FlagsAndCommand.Stop);
                }
            }
            return(cmd);
        }