WriteTo() 공개 메소드

public WriteTo ( VertexStore outputVxs ) : void
outputVxs VertexStore
리턴 void
예제 #1
0
        public VertexStore MakeVxs(VertexStore sourceVxs, VertexStore outputVxs)
        {
            StrokeGenerator strkgen = _strokeGen;
            int             j       = sourceVxs.Count;

            strkgen.Reset();
            VertexCmd cmd;
            double    x = 0, y = 0, startX = 0, startY = 0;

            for (int i = 0; i < j; ++i)
            {
                cmd = sourceVxs.GetVertex(i, out x, out y);
                switch (cmd)
                {
                case VertexCmd.NoMore:
                    break;

                case VertexCmd.Close:
                    if (i < j)
                    {
                        //close command
                        strkgen.Close();
                        strkgen.WriteTo(outputVxs);
                        strkgen.Reset();
                    }
                    else
                    {
                    }
                    break;

                case VertexCmd.CloseAndEndFigure:
                    if (i < j)
                    {
                        //close command
                        strkgen.Close();
                        strkgen.WriteTo(outputVxs);
                        strkgen.Reset();
                    }
                    else
                    {
                    }
                    break;

                case VertexCmd.LineTo:
                case VertexCmd.P2c:    //user must flatten the curve before do stroke
                case VertexCmd.P3c:    //user must flatten the curve before do stroke

                    strkgen.AddVertex(x, y, cmd);

                    break;

                case VertexCmd.MoveTo:

                    strkgen.AddVertex(x, y, cmd);
                    startX = x;
                    startY = y;

                    break;

                default: throw new System.NotSupportedException();
                }
            }
            strkgen.WriteTo(outputVxs);
            strkgen.Reset();

            return(outputVxs);
        }
예제 #2
0
파일: Stroke.cs 프로젝트: asmboom/PixelFarm
        public VertexStore MakeVxs(VertexStore sourceVxs)
        {
            StrokeGenerator strkgen = strokeGen;
            VertexStore     vxs     = new VertexStore();

            int    j = sourceVxs.Count;
            double x, y;

            strkgen.RemoveAll();
            //1st vertex

            sourceVxs.GetVertex(0, out x, out y);
            strkgen.AddVertex(x, y, VertexCmd.MoveTo);

            double startX = x, startY = y;
            bool   hasMoreThanOnePart = false;

            for (int i = 0; i < j; ++i)
            {
                var cmd = sourceVxs.GetVertex(i, out x, out y);
                switch (cmd)
                {
                case VertexCmd.Stop:
                case VertexCmd.HasMore:
                {
                } break;

                case VertexCmd.EndFigure:
                case VertexCmd.EndAndCloseFigure:
                {
                    strkgen.AddVertex(x, y, cmd);
                    if (i < j - 2)
                    {
                        strkgen.AddVertex(startX, startY, VertexCmd.LineTo);
                        strkgen.WriteTo(vxs);
                        strkgen.RemoveAll();
                        hasMoreThanOnePart = true;
                    }
                    //end this polygon
                } break;

                case VertexCmd.LineTo:
                case VertexCmd.P2c:
                case VertexCmd.P3c:
                {
                    strkgen.AddVertex(x, y, cmd);
                } break;

                case VertexCmd.MoveTo:
                {
                    strkgen.AddVertex(x, y, cmd);
                    startX = x;
                    startY = y;
                } break;

                default: throw new System.NotSupportedException();
                }
            }
            strkgen.WriteTo(vxs);
            strkgen.RemoveAll();

            vxs.HasMoreThanOnePart = hasMoreThanOnePart;
            return(vxs);
        }