Example #1
0
        public static void test_svg()
        {
            Polygon2d  poly  = Polygon2d.MakeCircle(100.0f, 10);
            PolyLine2d pline = new PolyLine2d();

            pline.AppendVertex(Vector2d.Zero);
            pline.AppendVertex(200 * Vector2d.AxisX);
            pline.AppendVertex(200 * Vector2d.One);
            Circle2d  circ = new Circle2d(33 * Vector2d.One, 25);
            Segment2d seg  = new Segment2d(Vector2d.Zero, -50 * Vector2d.AxisY);

            SVGWriter writer = new SVGWriter();

            writer.AddPolygon(poly, SVGWriter.Style.Filled("lime", "black", 0.25f));
            writer.AddPolyline(pline, SVGWriter.Style.Outline("orange", 2.0f));
            writer.AddCircle(circ, SVGWriter.Style.Filled("yellow", "red", 5.0f));
            writer.AddLine(seg, SVGWriter.Style.Outline("blue", 10.0f));

            int      astep = 29;
            Vector2d c     = new Vector2d(-200, 100);

            for (int k = 1; k <= 12; ++k)
            {
                Arc2d arc = new Arc2d(c + k * 45 * Vector2d.AxisX, 20, 0, k * astep);
                writer.AddArc(arc);
                writer.AddBox(arc.Bounds, SVGWriter.Style.Outline("red", 0.5f));
            }
            c.y += 50;
            for (int k = 1; k <= 12; ++k)
            {
                Arc2d arc = new Arc2d(c + k * 45 * Vector2d.AxisX, 20, k * astep, (k + 5) * astep);
                writer.AddArc(arc);
                writer.AddBox(arc.Bounds, SVGWriter.Style.Outline("red", 0.5f));
            }
            c.y += 50;
            for (int k = 1; k <= 12; ++k)
            {
                Arc2d arc = new Arc2d(c + k * 45 * Vector2d.AxisX, 20, k * astep, (k + 10) * astep);
                writer.AddArc(arc);
                writer.AddBox(arc.Bounds, SVGWriter.Style.Outline("red", 0.5f));
            }
            c.y += 50;
            for (int k = 1; k <= 12; ++k)
            {
                Arc2d arc = new Arc2d(c + k * 45 * Vector2d.AxisX, 20, k * astep, (k + 10) * astep);
                arc.Reverse();
                writer.AddArc(arc);
                writer.AddBox(arc.Bounds, SVGWriter.Style.Outline("red", 0.5f));
            }

            writer.Write(TestUtil.GetTestOutputPath("test.svg"));
        }
Example #2
0
 private static void Window_KeyReleaseEvent(object sender, KeyReleaseEventArgs args)
 {
     if (args.Event.Key == Gdk.Key.Up)
     {
         if ((args.Event.State & Gdk.ModifierType.ShiftMask) != 0)
         {
             View.CurrentLayer = View.CurrentLayer + 10;
         }
         else
         {
             View.CurrentLayer = View.CurrentLayer + 1;
         }
     }
     else if (args.Event.Key == Gdk.Key.Down)
     {
         if ((args.Event.State & Gdk.ModifierType.ShiftMask) != 0)
         {
             View.CurrentLayer = View.CurrentLayer - 10;
         }
         else
         {
             View.CurrentLayer = View.CurrentLayer - 1;
         }
     }
     else if (args.Event.Key == Gdk.Key.n)
     {
         if (View.NumberMode == SliceViewCanvas.NumberModes.NoNumbers)
         {
             View.NumberMode = SliceViewCanvas.NumberModes.PathNumbers;
         }
         else
         {
             View.NumberMode = SliceViewCanvas.NumberModes.NoNumbers;
         }
         View.QueueDraw();
     }
     else if (args.Event.Key == Gdk.Key.f)
     {
         View.ShowFillArea = !View.ShowFillArea;
         View.QueueDraw();
     }
     else if (args.Event.Key == Gdk.Key.t)
     {
         View.ShowTravels = !View.ShowTravels;
         View.QueueDraw();
     }
     else if (args.Event.Key == Gdk.Key.e)
     {
         View.ShowDepositMoves = !View.ShowDepositMoves;
         View.QueueDraw();
     }
     else if (args.Event.Key == Gdk.Key.p)
     {
         View.ShowAllPathPoints = !View.ShowAllPathPoints;
         View.QueueDraw();
     }
     else if (args.Event.Key == Gdk.Key.b)
     {
         View.ShowBelowLayer = !View.ShowBelowLayer;
         View.QueueDraw();
     }
     else if (args.Event.Key == Gdk.Key.i)
     {
         View.ShowIssues = !View.ShowIssues;
         View.QueueDraw();
     }
     else if (args.Event.Key == Gdk.Key.q)
     {
         //SliceViewerTests.TestDGraph2();
         //SliceViewerTests.TestFill();
         //SliceViewerTests.TestOffset();
         if (SliceViewerTests.Active == null)
         {
             SliceViewerTests.TestOffsetAnimation();
         }
         else
         {
             SliceViewerTests.UpdateOffsetAnimation();
         }
     }
     else if (args.Event.Key == Gdk.Key.E)
     {
         List <PolyLine2d> paths     = View.GetPolylinesForLayer(View.CurrentLayer);
         SVGWriter         writer    = new SVGWriter();
         SVGWriter.Style   lineStyle = SVGWriter.Style.Outline("black", 0.2f);
         foreach (var p in paths)
         {
             writer.AddPolyline(p, lineStyle);
         }
         writer.Write("c:\\scratch\\__LAST_PATHS.svg");
     }
 }