예제 #1
0
 public void SetDashPattern(float solid0, float blank0, float solid1, float blank1)
 {
     _dashGenLineWalker = new LineWalker();
     _dashGenLineWalker.AddMark(solid0, LineWalkDashStyle.Solid);
     _dashGenLineWalker.AddMark(blank0, LineWalkDashStyle.Blank);
     //
     _dashGenLineWalker.AddMark(solid1, LineWalkDashStyle.Solid);
     _dashGenLineWalker.AddMark(blank1, LineWalkDashStyle.Blank);
 }
예제 #2
0
        void DrawB(Painter p)
        {
            p.Clear(PixelFarm.Drawing.Color.White);
            //--------------------------
            p.StrokeColor = PixelFarm.Drawing.Color.Black;
            p.StrokeWidth = 2.0f;


            using (VxsTemp.Borrow(out var v1, out var v2))
                using (VectorToolBox.Borrow(v1, out PathWriter writer))
                {
                    writer.MoveTo(20, 10);
                    writer.LineTo(60, 10);
                    writer.LineTo(20, 200);
                    writer.CloseFigure();

                    //aggPainter.LineJoin = this.LineJoin;
                    //aggPainter.LineCap = this.LineCap;
                    //
                    //----------------------------------------------------
                    //create a dash line


                    _dashGenLineWalker.ClearMarks(); //clear previous markers
                    //***
                    //you can customize what happend with the line segment
                    _dashGenLineWalker.AddMark(10, (outputVxs, cmd, x, y) =>
                    {
                        //solid
                        switch (cmd)
                        {
                        case VertexCmd.MoveTo:
                            outputVxs.AddMoveTo(x, y);
                            break;

                        case VertexCmd.LineTo:
                            outputVxs.AddLineTo(x, y);
                            break;
                        }
                    });
                    _dashGenLineWalker.AddMark(10, (outputVxs, cmd, x, y) =>
                    {
                        //whitespace, do nothing
                    });

                    //then generate dash by walking along v1
                    _dashGenLineWalker.Walk(v1, v2);
                    //aggPainter.Draw(vxs);

                    //test drawline
                    int    n = v2.Count;
                    double px = 0, py = 0;

                    for (int i = 0; i < n; ++i)
                    {
                        double    x, y;
                        VertexCmd cmd = v2.GetVertex(i, out x, out y);
                        switch (cmd)
                        {
                        case VertexCmd.MoveTo:
                            px = x;
                            py = y;

                            break;

                        case VertexCmd.LineTo:
                            p.DrawLine(px, py, x, y);

                            break;
                        }
                        px = x;
                        py = y;
                    }
                }
            //aggPainter.Draw(newvxs);
        }
예제 #3
0
        void DrawB(PixelFarm.Agg.AggPainter aggPainter)
        {
            aggPainter.Clear(PixelFarm.Drawing.Color.White);
            //--------------------------
            aggPainter.StrokeColor = PixelFarm.Drawing.Color.Black;
            aggPainter.StrokeWidth = 2.0f;

            //
            VertexStore vxs    = new VertexStore();
            PathWriter  writer = new PathWriter(vxs);

            writer.MoveTo(20, 10);
            writer.LineTo(60, 10);
            writer.LineTo(20, 200);
            writer.CloseFigure();

            //writer.MoveTo(100, 100);
            //writer.LineTo(20, 200);
            //aggPainter.LineJoin = this.LineJoin;
            //aggPainter.LineCap = this.LineCap;
            //
            //----------------------------------------------------
            //create a dash line
            VertexStore newvxs            = new VertexStore();
            LineWalker  dashGenLineWalker = new LineWalker();

            //***
            //you can customize what happend with the line segment
            dashGenLineWalker.AddMark(10, (outputVxs, cmd, x, y) =>
            {
                //solid
                switch (cmd)
                {
                case VertexCmd.MoveTo:
                    outputVxs.AddMoveTo(x, y);
                    break;

                case VertexCmd.LineTo:
                    outputVxs.AddLineTo(x, y);
                    break;
                }
            });
            dashGenLineWalker.AddMark(10, (outputVxs, cmd, x, y) =>
            {
                //whitespace, do nothing
            });

            dashGenLineWalker.Walk(vxs, newvxs);
            //aggPainter.Draw(vxs);

            //test drawline
            int    n = newvxs.Count;
            double px = 0, py = 0;

            for (int i = 0; i < n; ++i)
            {
                double    x, y;
                VertexCmd cmd = newvxs.GetVertex(i, out x, out y);

                switch (cmd)
                {
                case VertexCmd.MoveTo:
                    px = x;
                    py = y;

                    break;

                case VertexCmd.LineTo:
                    aggPainter.DrawLine(px, py, x, y);

                    break;
                }
                px = x;
                py = y;
            }
            //aggPainter.Draw(newvxs);
        }
예제 #4
0
        void DrawB(Painter p)
        {
            p.Clear(PixelFarm.Drawing.Color.White);
            //--------------------------
            p.StrokeColor = PixelFarm.Drawing.Color.Black;
            p.StrokeWidth = 2.0f;


            using (Tools.BorrowVxs(out var v1, out var v2))
                using (Tools.BorrowPathWriter(v1, out var writer))
                {
                    writer.MoveTo(20, 10);
                    writer.LineTo(60, 10);
                    writer.LineTo(20, 200);
                    writer.CloseFigure();

                    //aggPainter.LineJoin = this.LineJoin;
                    //aggPainter.LineCap = this.LineCap;
                    //
                    //----------------------------------------------------
                    //create a dash line


                    _dashGenLineWalker.Reset(); //clear previous markers
                    //***
                    //you can customize what happend with the line segment
                    _dashGenLineWalker.AddMark(10, (output, marker, cmd, x, y) =>
                    {
                        //solid
                        switch (cmd)
                        {
                        case VertexCmd.MoveTo:
                            output.AddMoveTo(marker, x, y);
                            break;

                        case VertexCmd.LineTo:
                            output.AddLineTo(marker, x, y);
                            break;
                        }
                    });
                    _dashGenLineWalker.AddMark(10, (output, marker, cmd, x, y) =>
                    {
                        //whitespace, do nothing
                    });


                    //-------------------------------------------
                    //then generate dash by walking along v1
                    ExampleVxsLineDashSegmentWalkerOutput walkerOutput = new ExampleVxsLineDashSegmentWalkerOutput();
                    walkerOutput.SetOutput(v2);
                    _dashGenLineWalker.Walk(v1, walkerOutput);
                    //test drawline
                    int    n = v2.Count;
                    double px = 0, py = 0;

                    for (int i = 0; i < n; ++i)
                    {
                        VertexCmd cmd = v2.GetVertex(i, out double x, out double y);
                        switch (cmd)
                        {
                        case VertexCmd.MoveTo:
                            break;

                        case VertexCmd.LineTo:
                            p.DrawLine(px, py, x, y);
                            break;
                        }
                        px = x;
                        py = y;
                    }
                    //-------------------------------------------
                }
        }