コード例 #1
1
    void RenderOpenPath(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 20);

      XPen pen = new XPen(XColors.Navy, Math.PI);
      pen.DashStyle = XDashStyle.Dash;

      XGraphicsPath path = new XGraphicsPath();
      path.AddLine(10, 120, 50, 60);
      path.AddArc(50, 20, 110, 80, 180, 180);
      path.AddLine(160, 60, 220, 100);
      gfx.DrawPath(pen, path);
    }
コード例 #2
1
ファイル: Paths.cs プロジェクト: bossaia/alexandrialibrary
    /// <summary>
    /// Strokes an open path.
    /// </summary>
    void DrawPathOpen(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "DrawPath (open)");

      XPen pen = new XPen(XColors.Navy, Math.PI);
      pen.DashStyle = XDashStyle.Dash;

      XGraphicsPath path = new XGraphicsPath();
      path.AddLine(10, 120, 50, 60);
      path.AddArc(50, 20, 110, 80, 180, 180);
      path.AddLine(160, 60, 220, 100);
      gfx.DrawPath(pen, path);

      EndBox(gfx);
    }
コード例 #3
1
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      XGraphicsPath path = new XGraphicsPath();

      path.AddLine(50, 150, 50, 100);
      path.AddArc(50, 50, 100, 100, -180, 180);
      path.AddLine(150, 70, 200, 70);
      path.AddLine(200, 70, 200, 150);
      path.CloseFigure();
      XPen pen = new XPen(XColors.Red, 50);

      path.Widen(pen, new XMatrix(), 3);
      path.FillMode = this.properties.General.FillMode;
      gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path);
    }
コード例 #4
0
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);
      DrawGridlines(gfx);

      // Create a new graphical path
      XGraphicsPath path = new XGraphicsPath();

      XSize size = new XSize(90, 140);
      double rotationAngle = 130;

      path.AddArc(new XPoint(100, 100), new XPoint(200, 200), size, rotationAngle, false, System.Windows.Media.SweepDirection.Clockwise);
      path.StartFigure();
      path.AddArc(new XPoint(400, 100), new XPoint(500, 200), size, rotationAngle, false, System.Windows.Media.SweepDirection.Counterclockwise);
      path.StartFigure();
      path.AddArc(new XPoint(100, 300), new XPoint(200, 400), size, rotationAngle, true, System.Windows.Media.SweepDirection.Clockwise);
      path.StartFigure();
      path.AddArc(new XPoint(400, 300), new XPoint(500, 400), size, rotationAngle, true, System.Windows.Media.SweepDirection.Counterclockwise);
      path.StartFigure();

#if DEBUG_
      gfx.WriteComment("PathArcSegment");
#endif
      gfx.DrawPath(XPens.Red, path);
    }
コード例 #5
0
ファイル: PathFlatten.cs プロジェクト: AnthonyNystrom/Pikling
    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      XGraphicsPath path = new XGraphicsPath();

      path.AddLine(50, 150, 50, 100);
      path.AddArc(50, 50, 100, 100, -180, 180);
      path.AddLine(150, 70, 200, 70);
      path.AddLine(200, 70, 200, 150);
      path.CloseFigure();
      path.Flatten(XMatrix.Identity, 0.1);
      gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path);
    }
コード例 #6
0
ファイル: ShadingRenderer.cs プロジェクト: Sl0vi/MigraDoc
        internal void Render(XUnit x, XUnit y, XUnit width, XUnit height, RoundedCorner roundedCorner)
        {
            // If there is no rounded corner, we can use the usual Render method.
            if (roundedCorner == RoundedCorner.None)
            {
                Render(x, y, width, height);
                return;
            }

            if (_shading == null || _brush == null)
                return;

            XGraphicsPath path = new XGraphicsPath();

            switch (roundedCorner)
            {
                case RoundedCorner.TopLeft:
                    path.AddArc(new XRect(x, y, width * 2, height * 2), 180, 90); // Error in CORE: _corePath.AddArc().
                    path.AddLine(new XPoint(x + width, y), new XPoint(x + width, y + height));
                    break;
                case RoundedCorner.TopRight:
                    path.AddArc(new XRect(x - width, y, width * 2, height * 2), 270, 90); // Error in CORE: _corePath.AddArc().
                    path.AddLine(new XPoint(x + width, y + height), new XPoint(x, y + height));
                    break;
                case RoundedCorner.BottomRight:
                    path.AddArc(new XRect(x - width, y - height, width * 2, height * 2), 0, 90); // Error in CORE: _corePath.AddArc().
                    path.AddLine(new XPoint(x, y + height), new XPoint(x, y));
                    break;
                case RoundedCorner.BottomLeft:
                    path.AddArc(new XRect(x, y - height, width * 2, height * 2), 90, 90); // Error in CORE: _corePath.AddArc().
                    path.AddLine(new XPoint(x, y), new XPoint(x + width, y));
                    break;
            }

            path.CloseFigure();
            _gfx.DrawPath(_brush, path);
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pg"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public static PDF.XGraphicsPath ToXGraphicsPath(this IPathGeometry pg, double dx, double dy, Func <double, double> scale)
        {
            var gp = new PDF.XGraphicsPath()
            {
                FillMode = pg.FillRule == FillRule.EvenOdd ? PDF.XFillMode.Alternate : PDF.XFillMode.Winding
            };

            foreach (var pf in pg.Figures)
            {
                var startPoint = pf.StartPoint;

                foreach (var segment in pf.Segments)
                {
                    if (segment is IArcSegment arcSegment)
                    {
#if WPF
                        var point1 = new PDF.XPoint(
                            scale(startPoint.X + dx),
                            scale(startPoint.Y + dy));
                        var point2 = new PDF.XPoint(
                            scale(arcSegment.Point.X + dx),
                            scale(arcSegment.Point.Y + dy));
                        var size = new PDF.XSize(
                            scale(arcSegment.Size.Width),
                            scale(arcSegment.Size.Height));
                        gp.AddArc(
                            point1,
                            point2,
                            size, arcSegment.RotationAngle, arcSegment.IsLargeArc,
                            arcSegment.SweepDirection == SweepDirection.Clockwise ? PDF.XSweepDirection.Clockwise : PDF.XSweepDirection.Counterclockwise);
                        startPoint = arcSegment.Point;
#else
                        throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                        // TODO: Convert WPF/SVG elliptical arc segment format to GDI+ bezier curves.
                        //startPoint = arcSegment.Point;
#endif
                    }
                    else if (segment is ICubicBezierSegment cubicBezierSegment)
                    {
                        gp.AddBezier(
                            scale(startPoint.X + dx),
                            scale(startPoint.Y + dy),
                            scale(cubicBezierSegment.Point1.X + dx),
                            scale(cubicBezierSegment.Point1.Y + dy),
                            scale(cubicBezierSegment.Point2.X + dx),
                            scale(cubicBezierSegment.Point2.Y + dy),
                            scale(cubicBezierSegment.Point3.X + dx),
                            scale(cubicBezierSegment.Point3.Y + dy));
                        startPoint = cubicBezierSegment.Point3;
                    }
                    else if (segment is ILineSegment)
                    {
                        var lineSegment = segment as ILineSegment;
                        gp.AddLine(
                            scale(startPoint.X + dx),
                            scale(startPoint.Y + dy),
                            scale(lineSegment.Point.X + dx),
                            scale(lineSegment.Point.Y + dy));
                        startPoint = lineSegment.Point;
                    }
                    else if (segment is IPolyCubicBezierSegment polyCubicBezierSegment)
                    {
                        if (polyCubicBezierSegment.Points.Length >= 3)
                        {
                            gp.AddBezier(
                                scale(startPoint.X + dx),
                                scale(startPoint.Y + dy),
                                scale(polyCubicBezierSegment.Points[0].X + dx),
                                scale(polyCubicBezierSegment.Points[0].Y + dy),
                                scale(polyCubicBezierSegment.Points[1].X + dx),
                                scale(polyCubicBezierSegment.Points[1].Y + dy),
                                scale(polyCubicBezierSegment.Points[2].X + dx),
                                scale(polyCubicBezierSegment.Points[2].Y + dy));
                        }

                        if (polyCubicBezierSegment.Points.Length > 3 &&
                            polyCubicBezierSegment.Points.Length % 3 == 0)
                        {
                            for (int i = 3; i < polyCubicBezierSegment.Points.Length; i += 3)
                            {
                                gp.AddBezier(
                                    scale(polyCubicBezierSegment.Points[i - 1].X + dx),
                                    scale(polyCubicBezierSegment.Points[i - 1].Y + dy),
                                    scale(polyCubicBezierSegment.Points[i].X + dx),
                                    scale(polyCubicBezierSegment.Points[i].Y + dy),
                                    scale(polyCubicBezierSegment.Points[i + 1].X + dx),
                                    scale(polyCubicBezierSegment.Points[i + 1].Y + dy),
                                    scale(polyCubicBezierSegment.Points[i + 2].X + dx),
                                    scale(polyCubicBezierSegment.Points[i + 2].Y + dy));
                            }
                        }

                        startPoint = polyCubicBezierSegment.Points.Last();
                    }
                    else if (segment is IPolyLineSegment polyLineSegment)
                    {
                        if (polyLineSegment.Points.Length >= 1)
                        {
                            gp.AddLine(
                                scale(startPoint.X + dx),
                                scale(startPoint.Y + dy),
                                scale(polyLineSegment.Points[0].X + dx),
                                scale(polyLineSegment.Points[0].Y + dy));
                        }

                        if (polyLineSegment.Points.Length > 1)
                        {
                            for (int i = 1; i < polyLineSegment.Points.Length; i++)
                            {
                                gp.AddLine(
                                    scale(polyLineSegment.Points[i - 1].X + dx),
                                    scale(polyLineSegment.Points[i - 1].Y + dy),
                                    scale(polyLineSegment.Points[i].X + dx),
                                    scale(polyLineSegment.Points[i].Y + dy));
                            }
                        }

                        startPoint = polyLineSegment.Points.Last();
                    }
                    else if (segment is IPolyQuadraticBezierSegment polyQuadraticSegment)
                    {
                        if (polyQuadraticSegment.Points.Length >= 2)
                        {
                            var    p1 = startPoint;
                            var    p2 = polyQuadraticSegment.Points[0];
                            var    p3 = polyQuadraticSegment.Points[1];
                            double x1 = p1.X;
                            double y1 = p1.Y;
                            double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                            double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                            double x3 = x2 + (p3.X - p1.X) / 3.0;
                            double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                            double x4 = p3.X;
                            double y4 = p3.Y;
                            gp.AddBezier(
                                scale(x1 + dx),
                                scale(y1 + dy),
                                scale(x2 + dx),
                                scale(y2 + dy),
                                scale(x3 + dx),
                                scale(y3 + dy),
                                scale(x4 + dx),
                                scale(y4 + dy));
                        }

                        if (polyQuadraticSegment.Points.Length > 2 &&
                            polyQuadraticSegment.Points.Length % 2 == 0)
                        {
                            for (int i = 3; i < polyQuadraticSegment.Points.Length; i += 3)
                            {
                                var    p1 = polyQuadraticSegment.Points[i - 1];
                                var    p2 = polyQuadraticSegment.Points[i];
                                var    p3 = polyQuadraticSegment.Points[i + 1];
                                double x1 = p1.X;
                                double y1 = p1.Y;
                                double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                                double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                                double x3 = x2 + (p3.X - p1.X) / 3.0;
                                double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                                double x4 = p3.X;
                                double y4 = p3.Y;
                                gp.AddBezier(
                                    scale(x1 + dx),
                                    scale(y1 + dy),
                                    scale(x2 + dx),
                                    scale(y2 + dy),
                                    scale(x3 + dx),
                                    scale(y3 + dy),
                                    scale(x4 + dx),
                                    scale(y4 + dy));
                            }
                        }

                        startPoint = polyQuadraticSegment.Points.Last();
                    }
                    else if (segment is IQuadraticBezierSegment quadraticBezierSegment)
                    {
                        var    p1 = startPoint;
                        var    p2 = quadraticBezierSegment.Point1;
                        var    p3 = quadraticBezierSegment.Point2;
                        double x1 = p1.X;
                        double y1 = p1.Y;
                        double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                        double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                        double x3 = x2 + (p3.X - p1.X) / 3.0;
                        double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                        double x4 = p3.X;
                        double y4 = p3.Y;
                        gp.AddBezier(
                            scale(x1 + dx),
                            scale(y1 + dy),
                            scale(x2 + dx),
                            scale(y2 + dy),
                            scale(x3 + dx),
                            scale(y3 + dy),
                            scale(x4 + dx),
                            scale(y4 + dy));
                        startPoint = quadraticBezierSegment.Point2;
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                    }
                }

                if (pf.IsClosed)
                {
                    gp.CloseFigure();
                }
                else
                {
                    gp.StartFigure();
                }
            }

            return(gp);
        }
コード例 #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="arc"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="db"></param>
        /// <param name="r"></param>
        public void Draw(object gfx, Kaliber3D.Render.XArc arc, double dx, double dy, ImmutableArray<Kaliber3D.Render.ShapeProperty> db, Kaliber3D.Render.Record r)
        {
            var _gfx = gfx as XGraphics;

            var a = Kaliber3D.Render.GdiArc.FromXArc(arc, dx, dy);

            if (arc.IsFilled)
            {
                var path = new XGraphicsPath();
                // NOTE: Not implemented in PdfSharp Core version.
                path.AddArc(
                    _scaleToPage(a.X),
                    _scaleToPage(a.Y),
                    _scaleToPage(a.Width),
                    _scaleToPage(a.Height),
                    a.StartAngle,
                    a.SweepAngle);

                if (arc.IsStroked)
                {
                    _gfx.DrawPath(
                        ToXPen(arc.Style, _scaleToPage),
                        ToXSolidBrush(arc.Style.Fill),
                        path);
                }
                else
                {
                    _gfx.DrawPath(
                        ToXSolidBrush(arc.Style.Fill),
                        path);
                }
            }
            else
            {
                if (arc.IsStroked)
                {
                    _gfx.DrawArc(
                        ToXPen(arc.Style, _scaleToPage),
                        _scaleToPage(a.X),
                        _scaleToPage(a.Y),
                        _scaleToPage(a.Width),
                        _scaleToPage(a.Height),
                        a.StartAngle,
                        a.SweepAngle);
                }
            }
        }
コード例 #9
0
        public static PDF.XGraphicsPath ToXGraphicsPath(this IPathGeometry pg, Func <double, double> scale)
        {
            var gp = new PDF.XGraphicsPath()
            {
                FillMode = pg.FillRule == FillRule.EvenOdd ? PDF.XFillMode.Alternate : PDF.XFillMode.Winding
            };

            foreach (var pf in pg.Figures)
            {
                var startPoint = pf.StartPoint;

                foreach (var segment in pf.Segments)
                {
                    if (segment is IArcSegment arcSegment)
                    {
#if WPF
                        var point1 = new PDF.XPoint(
                            scale(startPoint.X),
                            scale(startPoint.Y));
                        var point2 = new PDF.XPoint(
                            scale(arcSegment.Point.X),
                            scale(arcSegment.Point.Y));
                        var size = new PDF.XSize(
                            scale(arcSegment.Size.Width),
                            scale(arcSegment.Size.Height));
                        gp.AddArc(
                            point1,
                            point2,
                            size, arcSegment.RotationAngle, arcSegment.IsLargeArc,
                            arcSegment.SweepDirection == SweepDirection.Clockwise ? PDF.XSweepDirection.Clockwise : PDF.XSweepDirection.Counterclockwise);
                        startPoint = arcSegment.Point;
#else
                        // TODO: Convert WPF/SVG elliptical arc segment format to GDI+ bezier curves.
                        startPoint = arcSegment.Point;
#endif
                    }
                    else if (segment is ICubicBezierSegment cubicBezierSegment)
                    {
                        gp.AddBezier(
                            scale(startPoint.X),
                            scale(startPoint.Y),
                            scale(cubicBezierSegment.Point1.X),
                            scale(cubicBezierSegment.Point1.Y),
                            scale(cubicBezierSegment.Point2.X),
                            scale(cubicBezierSegment.Point2.Y),
                            scale(cubicBezierSegment.Point3.X),
                            scale(cubicBezierSegment.Point3.Y));
                        startPoint = cubicBezierSegment.Point3;
                    }
                    else if (segment is ILineSegment)
                    {
                        var lineSegment = segment as ILineSegment;
                        gp.AddLine(
                            scale(startPoint.X),
                            scale(startPoint.Y),
                            scale(lineSegment.Point.X),
                            scale(lineSegment.Point.Y));
                        startPoint = lineSegment.Point;
                    }
                    else if (segment is IQuadraticBezierSegment quadraticBezierSegment)
                    {
                        var    p1 = startPoint;
                        var    p2 = quadraticBezierSegment.Point1;
                        var    p3 = quadraticBezierSegment.Point2;
                        double x1 = p1.X;
                        double y1 = p1.Y;
                        double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                        double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                        double x3 = x2 + (p3.X - p1.X) / 3.0;
                        double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                        double x4 = p3.X;
                        double y4 = p3.Y;
                        gp.AddBezier(
                            scale(x1),
                            scale(y1),
                            scale(x2),
                            scale(y2),
                            scale(x3),
                            scale(y3),
                            scale(x4),
                            scale(y4));
                        startPoint = quadraticBezierSegment.Point2;
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                    }
                }

                if (pf.IsClosed)
                {
                    gp.CloseFigure();
                }
                else
                {
                    gp.StartFigure();
                }
            }

            return(gp);
        }
コード例 #10
0
ファイル: PdfRenderer.cs プロジェクト: Core2D/Core2D
        /// <inheritdoc/>
        public override void Draw(object dc, Core2D.Shapes.XArc arc, double dx, double dy, ImmutableArray<Core2D.Data.XProperty> db, Core2D.Data.Database.XRecord r)
        {
            var _gfx = dc as XGraphics;

            var a = Core2D.Math.Arc.GdiArc.FromXArc(arc);

            if (arc.IsFilled)
            {
                var path = new XGraphicsPath();
                // NOTE: Not implemented in PdfSharp Core version.
                path.AddArc(
                    _scaleToPage(a.X + dx),
                    _scaleToPage(a.Y + dy),
                    _scaleToPage(a.Width),
                    _scaleToPage(a.Height),
                    a.StartAngle,
                    a.SweepAngle);

                if (arc.IsStroked)
                {
                    _gfx.DrawPath(
                        ToXPen(arc.Style, _scaleToPage, _sourceDpi, _targetDpi),
                        ToXSolidBrush(arc.Style.Fill),
                        path);
                }
                else
                {
                    _gfx.DrawPath(
                        ToXSolidBrush(arc.Style.Fill),
                        path);
                }
            }
            else
            {
                if (arc.IsStroked)
                {
                    _gfx.DrawArc(
                        ToXPen(arc.Style, _scaleToPage, _sourceDpi, _targetDpi),
                        _scaleToPage(a.X + dx),
                        _scaleToPage(a.Y + dy),
                        _scaleToPage(a.Width),
                        _scaleToPage(a.Height),
                        a.StartAngle,
                        a.SweepAngle);
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pg"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public static XGraphicsPath ToXGraphicsPath(this Core2D.XPathGeometry pg, double dx, double dy, Func<double, double> scale)
        {
            var gp = new XGraphicsPath();
            gp.FillMode = pg.FillRule == Core2D.XFillRule.EvenOdd ? XFillMode.Alternate : XFillMode.Winding;

            foreach (var pf in pg.Figures)
            {
                var startPoint = pf.StartPoint;

                foreach (var segment in pf.Segments)
                {
                    if (segment is Core2D.XArcSegment)
                    {
            #if CORE
                        //var arcSegment = segment as Core2D.XArcSegment;
                        // TODO: Convert WPF/SVG elliptical arc segment format to GDI+ bezier curves.
                        //startPoint = arcSegment.Point;
            #endif
            #if WPF
                        var arcSegment = segment as Core2D.XArcSegment;
                        var point1 = new XPoint(
                            scale(startPoint.X),
                            scale(startPoint.Y));
                        var point2 = new XPoint(
                            scale(arcSegment.Point.X),
                            scale(arcSegment.Point.Y));
                        var size = new XSize(
                            scale(arcSegment.Size.Width),
                            scale(arcSegment.Size.Height));
                        gp.AddArc(
                            point1,
                            point2,
                            size, arcSegment.RotationAngle, arcSegment.IsLargeArc,
                            arcSegment.SweepDirection == Core2D.XSweepDirection.Clockwise ? XSweepDirection.Clockwise : XSweepDirection.Counterclockwise);
                        startPoint = arcSegment.Point;
            #endif
                    }
                    else if (segment is Core2D.XBezierSegment)
                    {
                        var bezierSegment = segment as Core2D.XBezierSegment;
                        gp.AddBezier(
                            scale(startPoint.X),
                            scale(startPoint.Y),
                            scale(bezierSegment.Point1.X),
                            scale(bezierSegment.Point1.Y),
                            scale(bezierSegment.Point2.X),
                            scale(bezierSegment.Point2.Y),
                            scale(bezierSegment.Point3.X),
                            scale(bezierSegment.Point3.Y));
                        startPoint = bezierSegment.Point3;
                    }
                    else if (segment is Core2D.XLineSegment)
                    {
                        var lineSegment = segment as Core2D.XLineSegment;
                        gp.AddLine(
                            scale(startPoint.X),
                            scale(startPoint.Y),
                            scale(lineSegment.Point.X),
                            scale(lineSegment.Point.Y));
                        startPoint = lineSegment.Point;
                    }
                    else if (segment is Core2D.XPolyBezierSegment)
                    {
                        var polyBezierSegment = segment as Core2D.XPolyBezierSegment;
                        if (polyBezierSegment.Points.Count >= 3)
                        {
                            gp.AddBezier(
                                scale(startPoint.X),
                                scale(startPoint.Y),
                                scale(polyBezierSegment.Points[0].X),
                                scale(polyBezierSegment.Points[0].Y),
                                scale(polyBezierSegment.Points[1].X),
                                scale(polyBezierSegment.Points[1].Y),
                                scale(polyBezierSegment.Points[2].X),
                                scale(polyBezierSegment.Points[2].Y));
                        }

                        if (polyBezierSegment.Points.Count > 3
                            && polyBezierSegment.Points.Count % 3 == 0)
                        {
                            for (int i = 3; i < polyBezierSegment.Points.Count; i += 3)
                            {
                                gp.AddBezier(
                                    scale(polyBezierSegment.Points[i - 1].X),
                                    scale(polyBezierSegment.Points[i - 1].Y),
                                    scale(polyBezierSegment.Points[i].X),
                                    scale(polyBezierSegment.Points[i].Y),
                                    scale(polyBezierSegment.Points[i + 1].X),
                                    scale(polyBezierSegment.Points[i + 1].Y),
                                    scale(polyBezierSegment.Points[i + 2].X),
                                    scale(polyBezierSegment.Points[i + 2].Y));
                            }
                        }

                        startPoint = polyBezierSegment.Points.Last();
                    }
                    else if (segment is Core2D.XPolyLineSegment)
                    {
                        var polyLineSegment = segment as Core2D.XPolyLineSegment;
                        if (polyLineSegment.Points.Count >= 1)
                        {
                            gp.AddLine(
                                scale(startPoint.X),
                                scale(startPoint.Y),
                                scale(polyLineSegment.Points[0].X),
                                scale(polyLineSegment.Points[0].Y));
                        }

                        if (polyLineSegment.Points.Count > 1)
                        {
                            for (int i = 1; i < polyLineSegment.Points.Count; i++)
                            {
                                gp.AddLine(
                                    scale(polyLineSegment.Points[i - 1].X),
                                    scale(polyLineSegment.Points[i - 1].Y),
                                    scale(polyLineSegment.Points[i].X),
                                    scale(polyLineSegment.Points[i].Y));
                            }
                        }

                        startPoint = polyLineSegment.Points.Last();
                    }
                    else if (segment is Core2D.XPolyQuadraticBezierSegment)
                    {
                        var polyQuadraticSegment = segment as Core2D.XPolyQuadraticBezierSegment;
                        if (polyQuadraticSegment.Points.Count >= 2)
                        {
                            var p1 = startPoint;
                            var p2 = polyQuadraticSegment.Points[0];
                            var p3 = polyQuadraticSegment.Points[1];
                            double x1 = p1.X;
                            double y1 = p1.Y;
                            double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                            double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                            double x3 = x2 + (p3.X - p1.X) / 3.0;
                            double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                            double x4 = p3.X;
                            double y4 = p3.Y;
                            gp.AddBezier(
                                scale(x1 + dx),
                                scale(y1 + dy),
                                scale(x2 + dx),
                                scale(y2 + dy),
                                scale(x3 + dx),
                                scale(y3 + dy),
                                scale(x4 + dx),
                                scale(y4 + dy));
                        }

                        if (polyQuadraticSegment.Points.Count > 2
                            && polyQuadraticSegment.Points.Count % 2 == 0)
                        {
                            for (int i = 3; i < polyQuadraticSegment.Points.Count; i += 3)
                            {
                                var p1 = polyQuadraticSegment.Points[i - 1];
                                var p2 = polyQuadraticSegment.Points[i];
                                var p3 = polyQuadraticSegment.Points[i + 1];
                                double x1 = p1.X;
                                double y1 = p1.Y;
                                double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                                double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                                double x3 = x2 + (p3.X - p1.X) / 3.0;
                                double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                                double x4 = p3.X;
                                double y4 = p3.Y;
                                gp.AddBezier(
                                    scale(x1 + dx),
                                    scale(y1 + dy),
                                    scale(x2 + dx),
                                    scale(y2 + dy),
                                    scale(x3 + dx),
                                    scale(y3 + dy),
                                    scale(x4 + dx),
                                    scale(y4 + dy));
                            }
                        }

                        startPoint = polyQuadraticSegment.Points.Last();
                    }
                    else if (segment is Core2D.XQuadraticBezierSegment)
                    {
                        var qbezierSegment = segment as Core2D.XQuadraticBezierSegment;
                        var p1 = startPoint;
                        var p2 = qbezierSegment.Point1;
                        var p3 = qbezierSegment.Point2;
                        double x1 = p1.X;
                        double y1 = p1.Y;
                        double x2 = p1.X + (2.0 * (p2.X - p1.X)) / 3.0;
                        double y2 = p1.Y + (2.0 * (p2.Y - p1.Y)) / 3.0;
                        double x3 = x2 + (p3.X - p1.X) / 3.0;
                        double y3 = y2 + (p3.Y - p1.Y) / 3.0;
                        double x4 = p3.X;
                        double y4 = p3.Y;
                        gp.AddBezier(
                            scale(x1 + dx),
                            scale(y1 + dy),
                            scale(x2 + dx),
                            scale(y2 + dy),
                            scale(x3 + dx),
                            scale(y3 + dy),
                            scale(x4 + dx),
                            scale(y4 + dy));
                        startPoint = qbezierSegment.Point2;
                    }
                    else
                    {
                        throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                    }
                }

                if (pf.IsClosed)
                {
                    gp.CloseFigure();
                }
                else
                {
                    gp.StartFigure();
                }
            }

            return gp;
        }