StartFigure() public method

public StartFigure ( ) : void
return void
Ejemplo n.º 1
1
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            using (Graphics g = e.Graphics)
            {
                GraphicsPath path = new GraphicsPath();

                path.AddLine(20, 20, 170, 20);
                path.AddLine(20, 20, 20, 100);
                // рисуем новую фигуру
                path.StartFigure();
                path.AddLine(240, 140, 240, 50);
                path.AddLine(240, 140, 80, 140);
                path.AddRectangle(new Rectangle(30, 30, 200, 100));
                // локальное преобразование траектории
                //Matrix X = new Matrix();
                //X.RotateAt(45, new PointF(60.0f, 100.0f));
                //path.Transform(X);
                // рисуем  path
                Pen redPen = new Pen(Color.Red, 2);
                g.FillPath(new SolidBrush(Color.Bisque), path);
                g.DrawPath(redPen, path);

            }

        }
Ejemplo n.º 2
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            //Создаем массив точек
            Point[] points = {
                    new Point(5, 10),
                    new Point(23, 130),
                    new Point(130, 57)};

            GraphicsPath path = new GraphicsPath();
            //рисуем первую траекторию
            path.StartFigure();
            path.AddEllipse(170, 170, 100, 50);
            // заливаем траекторию цветом
            g.FillPath(Brushes.Aqua, path);
            //рисуем вторую траекторию
            path.StartFigure();
            path.AddCurve(points, 0.5F);
            path.AddArc(100, 50, 100, 100, 0, 120);
            path.AddLine(50, 150, 50, 220);
            // Закрываем траекторию
            path.CloseFigure();
            //рисуем четвертую траекторию
            path.StartFigure();
            path.AddArc(180, 30, 60, 60, 0, -170);

            g.DrawPath(new Pen(Color.Blue, 3), path);
            g.Dispose();
        }
Ejemplo n.º 3
0
        public override void DrawRegionRepresentation(Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods, PointD mousePosition)
        {
            if (m_Param.Path.PointCount > 0)
            {
                GraphicsPath fill = new GraphicsPath();
                RectangleF rect = m_Param.Path.GetBounds();
                PointD refPt = (PointD)rect.Location + ((PointD)rect.Size.ToPointF()) / 2;
                // this will draw beyond the shape's location
                for (double i = -rect.Height; i < rect.Height; i++)
                {
                    PointD orth = PointD.Orthogonal(m_Param.V);
                    PointD pt1 = refPt + orth * i * drawMethods.Spacing(m_Param.C);
                    PointD pt2 = pt1 + m_Param.V * rect.Width * rect.Height;
                    PointD pt3 = pt1 - m_Param.V * rect.Width * rect.Height;

                    PointD pt4 = refPt + m_Param.V * i * drawMethods.Spacing(m_Param.C);
                    PointD pt5 = pt4 + orth * rect.Width * rect.Height;
                    PointD pt6 = pt4 - orth * rect.Width * rect.Height;

                    fill.StartFigure();
                    fill.AddLine((Point)pt2, (Point)pt3);

                    fill.StartFigure();
                    fill.AddLine((Point)pt5, (Point)pt6);

                }

                GraphicsContainer c = gc.BeginContainer();
                gc.SetClip( (Tools.Model.VectorPath) m_Param.Path);
                gc.DrawPath(r.RegionGuides, fill);
                gc.EndContainer(c);

            }
        }
        public override void DrawYourSelf(Graphics graphics)
        {
            GraphicsPath path = new GraphicsPath();
            path.StartFigure();
            path.AddLine(Location.X, Location.Y + ModelSize.Height / 3, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 3);
            path.CloseFigure();
            path.StartFigure();
            path.AddLine(Location.X, Location.Y + (ModelSize.Height / 3) * 2, Location.X + ModelSize.Width, Location.Y + (ModelSize.Height * 2) / 3);
            path.CloseFigure();
            path.AddEllipse(new RectangleF(Location, ModelSize));
            path.CloseFigure();
            path.Transform(this.TMatrix.TransformationMatrix);

            Pen pen = new Pen(this.BorderColor, this.BorderWidth);
            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }
            graphics.DrawPath(pen, path);
            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Изчертава елипсите.
        /// </summary>
        /// <param name="graphics"></param>
        public override void DrawYourSelf(Graphics graphics)
        {
            GraphicsPath path = new GraphicsPath();
            path.StartFigure();
            path.AddEllipse(Location.X + ModelSize.Width / 3, Location.Y + ModelSize.Height / 3, ModelSize.Width / 3, ModelSize.Height / 3);
            path.CloseFigure();
            path.StartFigure();
            path.AddLine(Location.X + (ModelSize.Width * 2) / 3, Location.Y + ModelSize.Height / 2, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 2);
            path.CloseFigure();
            path.AddEllipse(new RectangleF(Location, ModelSize));
            path.CloseFigure();
            path.Transform(this.TMatrix.TransformationMatrix);

            /*
             * Създава се Pen, който изчертава контура, като използва
             * цвят и дебелина (определят се от конструктора)
             */
            Pen pen = new Pen(this.BorderColor, this.BorderWidth);
            // Правим същото, но за запълването
            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }
            graphics.DrawPath(pen, path);
            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
Ejemplo n.º 6
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            Point[] points = {
                                new Point(5,10) ,
                                new Point(23 , 130),
                                new Point(130 , 57)
                             };

            GraphicsPath path = new GraphicsPath();

            path.StartFigure();
            path.AddEllipse(170 , 170 , 100 , 50);
            g.FillPath(Brushes.Black, path);
            path.CloseFigure();

            path.StartFigure();
            path.AddCurve(points , 0.5F);
            g.FillPath(Brushes.Blue, path);

            //coords
            g.TranslateTransform(40, 40);
            Point A = new Point(0, 0);
            Point B = new Point(150 , 150);
            g.DrawLine(new Pen(Brushes.Black, 3), A, B);

            g.Dispose();
        }
Ejemplo n.º 7
0
        public virtual void NextSubpath_Int_Int_Bool() 
		{
            GraphicsPath path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.AddLine (new Point (400, 200), new Point (10, 100));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.CloseFigure ();
			path.StartFigure ();
			path.SetMarkers ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			GraphicsPathIterator iterator = new GraphicsPathIterator (path);

			int start;
			int end;
			bool isClosed;

			int count = iterator.NextSubpath (out start, out end, out isClosed);
			Assert.AreEqual (4, count);
			Assert.AreEqual (0, start);
			Assert.AreEqual (3, end);
			Assert.IsFalse (isClosed);

			count = iterator.NextSubpath (out start, out end, out isClosed);
			Assert.AreEqual (4, count);
			Assert.AreEqual (4, start);
			Assert.AreEqual (7, end);
			Assert.IsTrue (isClosed);

			count = iterator.NextSubpath (out start, out end, out isClosed);
			Assert.AreEqual (4, count);
			Assert.AreEqual (8, start);
			Assert.AreEqual (11, end);
			Assert.IsTrue (isClosed);

			count = iterator.NextSubpath (out start, out end, out isClosed);
			Assert.AreEqual (2, count);
			Assert.AreEqual (12, start);
			Assert.AreEqual (13, end);
			Assert.IsFalse (isClosed);

			count = iterator.NextSubpath (out start, out end, out isClosed);
			Assert.AreEqual (0, count);
			Assert.AreEqual (0, start);
			Assert.AreEqual (0, end);
			Assert.IsTrue (isClosed);
        }
        public override RectangleF ReturnBounds()
        {
            GraphicsPath path = new GraphicsPath();
            path.StartFigure();
            path.AddLine(Location.X, Location.Y + ModelSize.Height / 3, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 3);
            path.CloseFigure();
            path.StartFigure();
            path.AddLine(Location.X, Location.Y + (ModelSize.Height / 3) * 2, Location.X + ModelSize.Width, Location.Y + (ModelSize.Height * 2) / 3);
            path.CloseFigure();
            path.AddEllipse(new RectangleF(Location, ModelSize));
            path.CloseFigure();
            path.Transform(this.TMatrix.TransformationMatrix);

            return path.GetBounds();
        }
Ejemplo n.º 9
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (BorderRadius == 0)
            {
                Rectangle rc = ClientRectangle;
                rc.Inflate(-(int)Math.Round(BorderWidth / 2.0 + .5), -(int)Math.Round(BorderWidth / 2.0 + .5));

                rc.Y = rc.Y - 1;
                rc.Height = rc.Height + 1;

                e.Graphics.DrawRectangle(new Pen(BorderColor, BorderWidth), rc);
            }
            else
            {
                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
                GraphicsPath gp = Extensions.Create(0, 0, Width - 2, Height - 2, BorderRadius);
                Pen p = new Pen(BorderColor, BorderWidth);

                e.Graphics.DrawPath(p, gp);
                e.Graphics.FillPath(p.Brush, gp);

                StringFormat formatting = (StringFormat)StringFormat.GenericTypographic.Clone();
                formatting.Alignment = StringAlignment.Center;
                formatting.LineAlignment = StringAlignment.Center;

                float emsize = e.Graphics.DpiY * Font.Size / 72;
                gp = new GraphicsPath();
                gp.StartFigure();
                gp.AddString(Text, Font.FontFamily, (int)Font.Style, emsize, new Point(Width / 2, Height / 2), formatting);
                gp.CloseFigure();
                e.Graphics.FillPath(new Pen(ForeColor, 1).Brush, gp);
            }
        }
Ejemplo n.º 10
0
        //------------------------------------------------------------------------------
        private static void DrawBezierCtrlLines(Graphics graphics,
      MultiPathSegment mps, uint color)
        {
            int cnt = mps.Count;
              if (cnt < 2) return;
              Pen pen = new Pen(MakeColor(color));
              GraphicsPath gpath = new GraphicsPath();
              PointF[] pts = new PointF[2];
              pts[0] = PathToPointF(mps[0]);
              pts[1] = PathToPointF(mps[1]);
              gpath.StartFigure();
              gpath.AddLines(pts);

              if (mps.IsValid())
            if (mps.curvetype == CurveType.CubicBezier)
            {
              pts[0] = PathToPointF(mps[2]);
              pts[1] = PathToPointF(mps[3]);
              gpath.StartFigure();
              gpath.AddLines(pts);
            }
            else
            {
              pts[0] = PathToPointF(mps[2]);
              gpath.StartFigure();
              gpath.AddLines(pts);
            }

              graphics.DrawPath(pen, gpath);
              pen.Dispose();
              gpath.Dispose();
        }
Ejemplo n.º 11
0
        private GraphicsPath createRoundedRectangles(int x, int y, int width, int height, int radius)
        {
            int xw = x + width;
            int yh = y + height;
            int xwr = xw - radius;
            int yhr = yh - radius;
            int xr = x + radius;
            int yr = y + radius;
            int r2 = radius * 2;
            int xwr2 = xw - r2;
            int yhr2 = yh - r2;

            GraphicsPath p = new GraphicsPath();
            p.StartFigure();
            p.AddArc(x, y, r2, r2, 180, 90);
            p.AddLine(xr, y, xwr, y);
            p.AddArc(xwr2, y, r2, r2, 270, 90);
            p.AddLine(xw, yr, xw, yhr);
            p.AddArc(xwr2, yhr2, r2, r2, 0, 90);
            p.AddLine(xwr, yh, xr, yh);
            p.AddArc(x, yhr2, r2, r2, 90, 90);
            p.AddLine(x, yhr, x, yr);
            p.CloseFigure();
            return p;
        }
Ejemplo n.º 12
0
		/// <summary>
		/// creates a grid according to the loaded image
		/// </summary>
		private void CreateGrid()
		{
			if (_grid!=null){_grid.Dispose(); _grid=null;}
			if (_element==null) return;
			//create graphicspath
			_grid=new GraphicsPath();
			//create columns
			for (int x=0; x<=_element.Width; x++)
			{
				_grid.StartFigure();
				_grid.AddLine(x,0,x,_element.Height);
			}
			//create rows
			for (int y=0; y<=_element.Height; y++)
			{
				_grid.StartFigure();
				_grid.AddLine(0,y,_element.Width,y);
			}
		}
Ejemplo n.º 13
0
        public static System.Drawing.Drawing2D.GraphicsPath CreateGraphicsPath(VertexStoreSnap vxsSnap)
        {
            VertexSnapIter vxsIter     = vxsSnap.GetVertexSnapIter();
            double         prevX       = 0;
            double         prevY       = 0;
            double         prevMoveToX = 0;
            double         prevMoveToY = 0;
            var            brush_path  = new System.Drawing.Drawing2D.GraphicsPath(FillMode.Winding);//*** winding for overlapped path

            for (;;)
            {
                double    x, y;
                VertexCmd cmd = vxsIter.GetNextVertex(out x, out y);
                switch (cmd)
                {
                case PixelFarm.Agg.VertexCmd.MoveTo:
                    prevMoveToX = prevX = x;
                    prevMoveToY = prevY = y;
                    brush_path.StartFigure();
                    break;

                case PixelFarm.Agg.VertexCmd.LineTo:

                    brush_path.AddLine((float)prevX, (float)prevY, (float)x, (float)y);
                    prevX = x;
                    prevY = y;
                    break;

                case PixelFarm.Agg.VertexCmd.CloseAndEndFigure:
                    //from current point
                    //
                    brush_path.AddLine((float)prevX, (float)prevY, (float)prevMoveToX, (float)prevMoveToY);
                    prevX = prevMoveToX;
                    prevY = prevMoveToY;
                    brush_path.CloseFigure();
                    break;

                case PixelFarm.Agg.VertexCmd.EndFigure:
                    goto EXIT_LOOP;
                    break;

                case PixelFarm.Agg.VertexCmd.HasMore:
                    break;

                case PixelFarm.Agg.VertexCmd.Stop:
                    goto EXIT_LOOP;

                default:
                    throw new NotSupportedException();
                }
            }
EXIT_LOOP:
            return(brush_path);
        }
Ejemplo n.º 14
0
		public static GraphicsPath GetRectangleRegion(Rectangle rect)
		{
			GraphicsPath gp = new GraphicsPath();
			gp.StartFigure();
			gp.AddLine(rect.Left, rect.Top, rect.Right, rect.Top);
			gp.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom);
			gp.AddLine(rect.Right, rect.Bottom, rect.Left, rect.Bottom);
			gp.AddLine(rect.Left, rect.Bottom, rect.Left, rect.Top);
			gp.CloseFigure();
			return gp;
		}
    ///<summary>
    /// Creates a <see cref="GraphicsPath"/> representing a polygon ring
    /// having the given coordinate sequence.
    ///</summary>
    /// <remarks>
    /// Uses <see cref="FillMode.Alternate"/> winding rule
    /// </remarks>
    /// <param name="coordinates">A coordinate sequence</param>
    /// <returns>The path for the coordinate sequence</returns>
    private static GraphicsPath ToPath(Coordinate[] coordinates)
    {
        var path = new GraphicsPath(FillMode.Alternate);

        path.StartFigure();
        if (coordinates.Length > 0)
            path.AddLines(ToPointF(coordinates));
        path.CloseFigure();

        return path;
    }
Ejemplo n.º 16
0
        public new bool ContainsPoint(float X, float Y)
        {
            GraphicsPath Path = new GraphicsPath();
            Path.StartFigure();
            if (TypeShape == Nows.Ellip)
                Path.AddEllipse(Rectan);
            else
                Path.AddPie(Rectan.X, Rectan.Y, Rectan.Width, Rectan.Height, startAngle, sweepAngle);
            Path.CloseFigure();

            return Path.IsVisible(X, Y);
        }
Ejemplo n.º 17
0
        public static System.Drawing.Drawing2D.GraphicsPath CreateGraphicsPath(VertexStore vxs)
        {
            //render vertice in store
            int    vcount      = vxs.Count;
            double prevX       = 0;
            double prevY       = 0;
            double prevMoveToX = 0;
            double prevMoveToY = 0;
            var    brush_path  = new System.Drawing.Drawing2D.GraphicsPath(FillMode.Winding);//*** winding for overlapped path

            for (int i = 0; i < vcount; ++i)
            {
                double x, y;
                PixelFarm.Agg.VertexCmd cmd = vxs.GetVertex(i, out x, out y);
                switch (cmd)
                {
                case PixelFarm.Agg.VertexCmd.MoveTo:
                    prevMoveToX = prevX = x;
                    prevMoveToY = prevY = y;
                    brush_path.StartFigure();
                    break;

                case PixelFarm.Agg.VertexCmd.LineTo:
                    brush_path.AddLine((float)prevX, (float)prevY, (float)x, (float)y);
                    prevX = x;
                    prevY = y;
                    break;

                case PixelFarm.Agg.VertexCmd.CloseAndEndFigure:
                    brush_path.AddLine((float)prevX, (float)prevY, (float)prevMoveToX, (float)prevMoveToY);
                    prevMoveToX = prevX = x;
                    prevMoveToY = prevY = y;
                    brush_path.CloseFigure();
                    break;

                case PixelFarm.Agg.VertexCmd.EndFigure:
                    break;

                case PixelFarm.Agg.VertexCmd.HasMore:
                    break;

                case PixelFarm.Agg.VertexCmd.Stop:
                    i = vcount + 1;    //exit from loop
                    break;

                default:
                    throw new NotSupportedException();
                    break;
                }
            }
            return(brush_path);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates the leaf shape path
        /// </summary>
        /// <param name="rec">The boundary of leaf shape</param>
        /// <param name="round">The round edge of leaf</param>
        /// <returns>Then GraphicsPath of leaf shape</returns>
        public static GraphicsPath CreateLeaf(Rectangle rec, float round)
        {
            var path = new GraphicsPath();
            path.StartFigure();
            path.AddLine(rec.X, rec.Y + rec.Height, rec.X, rec.Y + round);
            path.AddArc(rec.X, rec.Y, round, round, 180F, 90F);
            path.AddLine(rec.X + round, rec.Y, rec.X + rec.Width, rec.Y);
            path.AddLine(rec.X + rec.Width, rec.Y, rec.X + rec.Width, rec.Y + rec.Height - round);
            path.AddArc(rec.X + rec.Width - round, rec.Y + rec.Height - round, round, round, 0F, 90F);
            path.CloseFigure();

            return path;
        }
 internal void AddToRing(PointF p, ref GraphicsPath ringPath)
 {
 	if (ringPath == null)
     {
 		ringPath = new GraphicsPath(FillMode.Alternate);
         ringPath.StartFigure();
 	}
 	else
     {
 		ringPath.AddLine(_lastPoint, p);
 	}
     _lastPoint = p;
 }
Ejemplo n.º 20
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            GraphicsPath Path = new GraphicsPath();

            Path.AddLine(10, 10, 50, 50);
            Path.AddLine(100, 50, 140, 10);
            Path.CloseFigure();
            Path.StartFigure();
            Path.AddLine(140, 80, 100, 120);
            Path.AddLine(100, 150, 140, 190);
            Path.CloseFigure();

            e.Graphics.DrawPath(Pens.Black, Path);
        }
Ejemplo n.º 21
0
		static GraphicsPath InitializePath ()
		{
			GraphicsPath path = new GraphicsPath();
			path.StartFigure();
			path.AddPolygon(new PointF[]{
				new PointF(0.0f, 1.9f),
				new PointF(2.0f, 1.9f),
				new PointF(2.0f, 1.0f),
				new PointF(3.0f, 2.0f),
				new PointF(2.0f, 3.0f),
				new PointF(2.0f, 2.1f),
				new PointF(0.0f, 2.1f)
			});
			path.CloseFigure();
			path.StartFigure();
			path.AddPolygon(new PointF[]{
				new PointF(2.2f, 1.4f),
				new PointF(2.7f, 2.0f),
				new PointF(2.2f, 2.6f)
			});
			path.FillMode = FillMode.Alternate;
			path.CloseFigure();
			return path;
		}
Ejemplo n.º 22
0
        public static GraphicsPath CreateRoundedRectanglePath(int x, int y, int width, int height, int radius)
        {
            if (radius < 0)
                throw new ArgumentOutOfRangeException("radius", "radius cannot be negative");
            else if (radius > int.MaxValue / 2)
                throw new ArgumentOutOfRangeException(
                    "radius",
                    "radius cannot be greater than " + (int.MaxValue / 2).ToDataString());

            if (width < 0) throw new ArgumentOutOfRangeException("width", "width cannot be negative");
            if (height < 0) throw new ArgumentOutOfRangeException("height", "height cannot be negative");

            GraphicsPath path = new GraphicsPath();
            path.StartFigure();

            int cornerSize = 2 * radius;

            // top left corner
            if (radius > 0)
                path.AddArc(x, y, cornerSize, cornerSize, 180, 90);

            // top edge
            path.AddLine(x + radius, y, x + width - radius, y);

            // top right corner
            if (radius > 0)
                path.AddArc(x + width - cornerSize, y, cornerSize, cornerSize, 290, 90);

            // right edge
            path.AddLine(x + width, y + radius, x + width, y + height - radius);

            // bottom right corner
            if (radius > 0)
                path.AddArc(x + width - cornerSize, y + height - cornerSize, cornerSize, cornerSize, 0, 90);

            // bottom edge
            path.AddLine(x + width - radius, y + height, x + radius, y + height);

            // bottom left corner
            if (radius > 0)
                path.AddArc(x, y + height - cornerSize, cornerSize, cornerSize, 90, 90);

            // left edge
            path.AddLine(x, y + height - radius, x, y + radius);

            path.CloseFigure();
            return path;
        }
Ejemplo n.º 23
0
        public void DrawPath(System.Windows.Point start, IList<IPathCommand> commands, double thickness, bool fill = false)
        {
            m_pen.Width = (float)thickness;

            GraphicsPath path = new GraphicsPath();
            System.Windows.Point previous = start;
            foreach (var command in commands)
            {
                switch (command.Type)
                {
                    case CommandType.MoveTo:
                        {
                            path.StartFigure();
                            break;
                        }
                    case CommandType.LineTo:
                        {
                            LineTo line = command as LineTo;
                            path.AddLine((float)previous.X, (float)previous.Y, (float)line.X + (float)start.X, (float)line.Y + (float)start.Y);
                            break;
                        }
                    case CommandType.CurveTo:
                        {
                            CurveTo curveTo = command as CurveTo;

                            break;
                        }
                    case CommandType.EllipticalArcTo:
                        {
                            EllipticalArcTo ellipticalArcTo = command as EllipticalArcTo;
                            //path.AddArc((float)previous.X, (float)previous.Y, (float)ellipticalArcTo.Size.Width, (float)ellipticalArcTo.Size.Height, (float)ellipticalArcTo.RotationAngle, (float)ellipticalArcTo.RotationAngle);
                            break;
                        }
                    case CommandType.QuadraticBeizerCurveTo:
                        {
                            QuadraticBeizerCurveTo qbCurveTo = command as QuadraticBeizerCurveTo;
                            //path.AddBezier((float)previous.X, (float)previous.Y, (float)qbCurveTo.Control.X, (float)qbCurveTo.Control.Y, (float)qbCurveTo.Control.X, (float)qbCurveTo.Control.Y, (float)qbCurveTo.End.X, (float)qbCurveTo.End.Y);
                            break;
                        }
                }

                previous = new System.Windows.Point(start.X + command.End.X, start.Y + command.End.Y);
            }

            if (fill)
                m_graphics.FillPath(Brushes.Black, path);
            m_graphics.DrawPath(m_pen, path);
        }
Ejemplo n.º 24
0
        // The CreateClipRegion method creates a Region from an
        // elliptical GraphicsPath.
        private Region CreateClipRegion()
        {
            GraphicsPath path = new GraphicsPath();

            path.StartFigure();

            path.AddEllipse(new System.Drawing.Rectangle(
                0,
                0,
                (int)wfHost.ActualWidth,
                (int)wfHost.ActualHeight ) );

            path.CloseFigure();

            return( new Region(path) );
        }
Ejemplo n.º 25
0
        private void DrawEllipse(Ellipse ellipse, Graphics graphs)
        {
            var path = new GraphicsPath();
            path.StartFigure();
            path.AddEllipse(Util.GetShapeBound(ellipse));
            path.CloseFigure();

            using (var b = new SolidBrush(ellipse.FillColor))
            using (var p = new Pen(ellipse.OutlineColor, ellipse.OutlineWidth))
            {
                p.DashStyle = ellipse.OutlineDash;
                graphs.FillPath(b, path);
                //_filler.FillByScanline(graphs, ellipse, ellipse.FillColor);
                graphs.DrawPath(p, path);
            }
        }
Ejemplo n.º 26
0
 private static GraphicsPath CreateRoundRectangle(int w, int h, int r)
 {
     int d = r << 1;
     GraphicsPath path = new GraphicsPath();
     path.StartFigure();
     path.AddArc(new Rectangle(0, 0, d, d), 180, 90);
     path.AddLine(r, 0, w - r, 0);
     path.AddArc(new Rectangle(w - d, 0, d, d), 270, 90);
     path.AddLine(w + 1, r, w + 1, h - r);
     path.AddArc(new Rectangle(w - d, h - d, d, d), 0, 90);
     path.AddLine(w - r, h + 1, r, h + 1);
     path.AddArc(new Rectangle(0, h - d, d, d), 90, 90);
     path.AddLine(0, h - r, 0, r);
     path.CloseFigure();
     return path;
 }
Ejemplo n.º 27
0
        public static GraphicsPath Convert(Path2D path)
        {
            GdiPath gdiPath = new GdiPath(FillMode.Winding);

            foreach (Figure2D figure in path.Figures)
            {
                gdiPath.StartFigure();

                gdiPath.AddLines(Convert(figure.Points));

                if (figure.IsClosed)
                {
                    gdiPath.CloseFigure();
                }
            }

            return(gdiPath);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// The get rounded rectangle path.
        /// </summary>
        /// <param name="rect">
        /// The rect.
        /// </param>
        /// <param name="radius">
        /// The radius.
        /// </param>
        /// <param name="borderWidth">
        /// The border width.
        /// </param>
        /// <returns>
        /// The <see cref="GraphicsPath"/>.
        /// </returns>
        internal static GraphicsPath GetRoundedRectanglePath(Rectangle rect, int radius, int borderWidth)
        {
            int x = rect.X, y = rect.Y, h = rect.Height - borderWidth, w = rect.Width - borderWidth;

            var p = new GraphicsPath();
            p.StartFigure();
            p.AddArc(x, y, 2 * radius, 2 * radius, 180, 90);
            p.AddLine(x + radius, y, x + w - radius, y);
            p.AddArc(x + w - 2 * radius, y, 2 * radius, 2 * radius, 270, 90);
            p.AddLine(x + w, y + radius, x + w, y + h - radius);
            p.AddArc(x + w - 2 * radius, y + h - 2 * radius, 2 * radius, 2 * radius, 0, 90);
            p.AddLine(x + w - radius, y + h, x + radius, y + h);
            p.AddArc(x, y + h - 2 * radius, 2 * radius, 2 * radius, 90, 90);
            p.AddLine(x, y + h - radius, x, y + radius);
            p.CloseFigure();

            return p;
        }
Ejemplo n.º 29
0
		public static GraphicsPath GetCornerlessRectangleRegionFill(Rectangle rect, int drawOffset, bool roundLeft, bool roundRight)
		{
			int offset = 0;

			GraphicsPath gp = new GraphicsPath();
			gp.StartFigure();

			offset = roundRight ? drawOffset : 0;
			gp.AddLine(rect.Right - offset, rect.Top, rect.Right, rect.Top + offset);
			gp.AddLine(rect.Right, rect.Bottom - offset, rect.Right - offset - 1, rect.Bottom + 1);

			offset = roundLeft ? drawOffset : 0;
			gp.AddLine(rect.Left + offset + 1, rect.Bottom + 1, rect.Left, rect.Bottom - offset);
			gp.AddLine(rect.Left, rect.Top + offset, rect.Left + offset, rect.Top);

			gp.CloseFigure();
			return gp;
		}
Ejemplo n.º 30
0
        //------------------------------------------------------------------------------
        private static void DoublePointsToGraphicsPath(List<DoublePoint> path, GraphicsPath gp, bool closed)
        {
            if (closed && path.Count < 2) return;
              else if (!closed && path.Count < 3) return;

              PointF[] pts = new PointF[path.Count];
              for (int i = 0; i < path.Count; ++i)
              {
            pts[i] = new PointF((float)(path[i].X / scale), (float)(path[i].Y / scale));
              }
              if (closed)
            gp.AddPolygon(pts);
              else
              {
            gp.StartFigure();
            gp.AddLines(pts);
              }
        }
Ejemplo n.º 31
0
        protected void DrawFilledPath(List <SeriesFigure> figures, System.Drawing.Pen gdiPen, System.Drawing.SolidBrush gdiBrush)
        {
            var path = new System.Drawing.Drawing2D.GraphicsPath();

            foreach (var figure in figures) // could do parallel For loop here...
            {
                path.StartFigure();

                var points     = figure.Points;
                var pointCount = figure.Points.Count;
                for (int i = 0; i < pointCount - 1; i++)
                {
                    path.AddLine(points[i], points[i + 1]);
                }
            }
            path.CloseAllFigures();
            GdiGraphics.FillPath(gdiBrush, path);
            GdiGraphics.DrawPath(gdiPen, path);
        }
Ejemplo n.º 32
0
        private void DrawPolygon(PolygonBase polygon, Graphics graphs)
        {
            if (polygon.Vertices.Count < 2)
                return;

            var path = new GraphicsPath();
            if (polygon.IsClosedFigure) path.StartFigure();
            path.AddLines(polygon.Vertices.ToPoints());
            if (polygon.IsClosedFigure) path.CloseFigure();

            using (var b = new SolidBrush(polygon.FillColor))
            using (var p = new Pen(polygon.OutlineColor, polygon.OutlineWidth))
            {
                p.DashStyle = polygon.OutlineDash;
                if (polygon.GetShapeType() != ShapeType.FreePencil) graphs.FillPath(b, path);
                //_filler.FillByScanline(graphs, polygon, polygon.FillColor);
                graphs.DrawPath(p, path);
            }
        }
Ejemplo n.º 33
0
        /// <summary>
        /// we do NOT store vxsSnap
        /// </summary>
        /// <param name="vxsSnap"></param>
        /// <returns></returns>
        public static System.Drawing.Drawing2D.GraphicsPath CreateGraphicsPath(VertexStoreSnap vxsSnap)
        {
            VertexSnapIter vxsIter = vxsSnap.GetVertexSnapIter();
            double prevX = 0;
            double prevY = 0;
            double prevMoveToX = 0;
            double prevMoveToY = 0;
            var brush_path = new System.Drawing.Drawing2D.GraphicsPath(FillMode.Winding);//*** winding for overlapped path  

            for (; ; )
            {
                double x, y;
                VertexCmd cmd = vxsIter.GetNextVertex(out x, out y);
                switch (cmd)
                {
                    case PixelFarm.Agg.VertexCmd.MoveTo:
                        prevMoveToX = prevX = x;
                        prevMoveToY = prevY = y;
                        brush_path.StartFigure();
                        break;
                    case PixelFarm.Agg.VertexCmd.LineTo:
                        brush_path.AddLine((float)prevX, (float)prevY, (float)x, (float)y);
                        prevX = x;
                        prevY = y;
                        break;
                    case PixelFarm.Agg.VertexCmd.CloseAndEndFigure:
                        //from current point                         
                        brush_path.AddLine((float)prevX, (float)prevY, (float)prevMoveToX, (float)prevMoveToY);
                        prevX = prevMoveToX;
                        prevY = prevMoveToY;
                        brush_path.CloseFigure();
                        break;
                    case PixelFarm.Agg.VertexCmd.EndFigure:
                        goto EXIT_LOOP;
                    case PixelFarm.Agg.VertexCmd.Stop:
                        goto EXIT_LOOP;
                    default:
                        throw new NotSupportedException();
                }
            }
        EXIT_LOOP:
            return brush_path;
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Bygger og returnerer en et rektangel, med eventuelle avrundede hjørner
        /// </summary>
        /// <param name="x">Startpunktets x-koordinat</param>
        /// <param name="y">Startpunktet y-koordinat</param>
        /// <param name="width">Bredden på rektangelet</param>
        /// <param name="height">Høyden på rektangelet</param>
        /// <param name="leftTopRadius">Avrundingsverdi for hjørne oppe til venstre</param>
        /// <param name="rightTopRadius">Avrundingsverdi for hjørne oppe til høyre</param>
        /// <param name="rightBottomRadius">Avrundingsverdi for hjørne nede til høyre</param>
        /// <param name="leftBottomRadius">Avrundingsverdi for hjørne nede til venstre</param>
        /// <returns>Et GraphicsPath-objekt som representerer rektangelet</returns>
        public static GraphicsPath Rectangle(int x, int y, int width, int height, int leftTopRadius, int rightTopRadius, int rightBottomRadius, int leftBottomRadius)
        {
            GraphicsPath p = new GraphicsPath();

            //Punkter for øvre venstre hjørne
            Point leftTopStart = new Point(x, y + leftTopRadius);
            Point leftTopStop = new Point(x + leftTopRadius, y);
            Point topLeftControlPoint = new Point(x, y);

            //Punkter for øvre høyre hjørne
            Point rightTopStart = new Point(x + width- rightTopRadius, y);
            Point rightTopStop = new Point(x + width, y + rightTopRadius);
            Point topRightControlPoint = new Point(x + width, y);

            //Punkter for nedre høyre hjørne
            Point rightBottomStart = new Point(x + width, y + height - rightBottomRadius);
            Point rightBottomStop = new Point(x + width - rightBottomRadius, y + height);
            Point bottomRightControlPoint = new Point(x + width, y + height);

            //Punkter for nedre venstre hjørne
            Point leftBottomStart = new Point(x + leftBottomRadius, y + height);
            Point leftBottomStop = new Point(x, y + height - leftBottomRadius);
            Point bottomLeftControlPoint = new Point(x, y + height);

            p.StartFigure();
            p.AddBezier(leftTopStart, topLeftControlPoint, topLeftControlPoint, leftTopStop); //Top left corner

            p.AddLine(x + leftTopRadius, y, x + width - rightTopRadius, y); //Top edge

            p.AddBezier(rightTopStart, topRightControlPoint, topRightControlPoint, rightTopStop); //Top right corner

            p.AddLine(x + width, y + rightTopRadius, x + width, y + height - rightBottomRadius); //Right edge

            p.AddBezier(rightBottomStart, bottomRightControlPoint, bottomRightControlPoint, rightBottomStop); // Bottom right corner

            p.AddLine(x + width - rightBottomRadius, y + height, x + leftBottomRadius, y + height); //Bottom edge

            p.AddBezier(leftBottomStart, bottomLeftControlPoint, bottomLeftControlPoint, leftBottomStop); // Bottom right corner

            p.CloseFigure();
            return p;
        }
Ejemplo n.º 35
0
        public static SD2D.GraphicsPath RoundRect(RectangleF rectangle, float roundRadius)
        {
            var path = new SD2D.GraphicsPath();

            roundRadius = Math.Min(roundRadius, Math.Min(rectangle.Width / 2, rectangle.Height / 2));
            if (roundRadius <= 1)
            {
                path.AddRectangle(rectangle.ToSystemDrawingObject());
                return(path);
            }
            RectangleF innerRect = RectangleF.Inflate(rectangle, -roundRadius, -roundRadius);

            path.StartFigure();
            path.AddArc(RoundBounds(innerRect.Right - 1, innerRect.Bottom - 1, roundRadius), 0, 90);
            path.AddArc(RoundBounds(innerRect.Left, innerRect.Bottom - 1, roundRadius), 90, 90);
            path.AddArc(RoundBounds(innerRect.Left, innerRect.Top, roundRadius), 180, 90);
            path.AddArc(RoundBounds(innerRect.Right - 1, innerRect.Top, roundRadius), 270, 90);
            path.CloseFigure();
            return(path);
        }
Ejemplo n.º 36
0
        public static System.Drawing.Drawing2D.GraphicsPath Create(Rectangle bounds,
                                                                   int topoffset, int bottomoffset, int shrink)
        {
            System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath();
            p.StartFigure();

            //____
            p.AddLine(bounds.X + topoffset + shrink, bounds.Y + shrink, bounds.Width - bottomoffset - shrink, bounds.Y + shrink);
            // \
            p.AddLine(bounds.Width - bottomoffset - shrink, bounds.Y + shrink, bounds.Width - shrink, bounds.Y + bottomoffset + shrink);
            // |
            p.AddLine(bounds.Width - shrink, bounds.Y + bottomoffset + shrink, bounds.Width - topoffset - shrink, bounds.Height - shrink);
            // /
            p.AddLine(bounds.Width - topoffset - shrink, bounds.Height - shrink, bounds.X + bottomoffset + shrink, bounds.Height - shrink);
            //____
            p.AddLine(bounds.X + bottomoffset + shrink, bounds.Height - shrink, bounds.X + shrink, bounds.Height - bottomoffset - shrink);
            // \
            p.AddLine(bounds.X + shrink, bounds.Height - bottomoffset - shrink, bounds.X + topoffset + shrink, bounds.Y + shrink);

            p.CloseFigure();
            return(p);
        }
Ejemplo n.º 37
0
        public static System.Drawing.Drawing2D.GraphicsPath RoundedRect(RectangleF rect, int cornerradius, int margin, Corner roundedcorners)
        {
            System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath();
            float x = rect.X;
            float y = rect.Y;
            float w = rect.Width;
            float h = rect.Height;
            int   m = margin;
            int   r = cornerradius;

            p.StartFigure();
            //top left arc
            if (System.Convert.ToBoolean(roundedcorners & Corner.TopLeft))
            {
                p.AddArc(CtrlHelper.CheckedRectangleF(x + m, y + m, 2 * r, 2 * r), 180, 90);
            }
            else
            {
                p.AddLine(new PointF(x + m, y + m + r), new PointF(x + m, y + m));
                p.AddLine(new PointF(x + m, y + m), new PointF(x + m + r, y + m));
            }

            //top line
            p.AddLine(new PointF(x + m + r, y + m), new PointF(x + w - m - r, y + m));

            //top right arc
            if (System.Convert.ToBoolean(roundedcorners & Corner.TopRight))
            {
                p.AddArc(CtrlHelper.CheckedRectangleF(x + w - m - 2 * r, y + m, 2 * r, 2 * r), 270, 90);
            }
            else
            {
                p.AddLine(new PointF(x + w - m - r, y + m), new PointF(x + w - m, y + m));
                p.AddLine(new PointF(x + w - m, y + m), new PointF(x + w - m, y + m + r));
            }

            //right line
            p.AddLine(new PointF(x + w - m, y + m + r), new PointF(x + w - m, y + h - m - r));

            //bottom right arc
            if (System.Convert.ToBoolean(roundedcorners & Corner.BottomRight))
            {
                p.AddArc(CtrlHelper.CheckedRectangleF(x + w - m - 2 * r, y + h - m - 2 * r, 2 * r, 2 * r), 0, 90);
            }
            else
            {
                p.AddLine(new PointF(x + w - m, y + h - m - r), new PointF(x + w - m, y + h - m));
                p.AddLine(new PointF(x + w - m, y + h - m), new PointF(x + w - m - r, y + h - m));
            }

            //bottom line
            p.AddLine(new PointF(x + w - m - r, y + h - m), new PointF(x + m + r, y + h - m));

            //bottom left arc
            if (System.Convert.ToBoolean(roundedcorners & Corner.BottomLeft))
            {
                p.AddArc(CtrlHelper.CheckedRectangleF(x + m, y + h - m - 2 * r, 2 * r, 2 * r), 90, 90);
            }
            else
            {
                p.AddLine(new PointF(x + m + r, y + h - m), new PointF(x + m, y + h - m));
                p.AddLine(new PointF(x + m, y + h - m), new PointF(x + m, y + h - m - r));
            }

            //left line
            p.AddLine(new PointF(x + m, y + h - m - r), new PointF(x + m, y + m + r));

            //close figure...
            p.CloseFigure();

            return(p);
        }
Ejemplo n.º 38
0
        public static D2D.GraphicsPath ToGraphicsPath(this PathGeometryViewModel pg, Func <double, float> scale)
        {
            var gp = new D2D.GraphicsPath
            {
                FillMode = pg.FillRule == FillRule.EvenOdd ? D2D.FillMode.Alternate : D2D.FillMode.Winding
            };

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

                foreach (var segment in pf.Segments)
                {
                    if (segment is ArcSegmentViewModel arcSegment)
                    {
                        // TODO: Convert WPF/SVG elliptical arc segment format to GDI+ bezier curves.
                        startPoint = arcSegment.Point;
                    }
                    else if (segment is CubicBezierSegmentViewModel 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 LineSegmentViewModel lineSegment)
                    {
                        gp.AddLine(
                            scale(startPoint.X),
                            scale(startPoint.Y),
                            scale(lineSegment.Point.X),
                            scale(lineSegment.Point.Y));
                        startPoint = lineSegment.Point;
                    }
                    else if (segment is QuadraticBezierSegmentViewModel 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);
        }
Ejemplo n.º 39
0
 public void StartFigure()
 {
     Control.StartFigure();
 }
Ejemplo n.º 40
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pg"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public static D2D.GraphicsPath ToGraphicsPath(this IPathGeometry pg, double dx, double dy, Func <double, float> scale)
        {
            var gp = new D2D.GraphicsPath
            {
                FillMode = pg.FillRule == FillRule.EvenOdd ? D2D.FillMode.Alternate : D2D.FillMode.Winding
            };

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

                foreach (var segment in pf.Segments)
                {
                    if (segment is IArcSegment arcSegment)
                    {
                        throw new NotSupportedException("Not supported segment type: " + segment.GetType());
                        // TODO: Convert WPF/SVG elliptical arc segment format to GDI+ bezier curves.
                        //startPoint = arcSegment.Point;
                    }
                    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 lineSegment)
                    {
                        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);
        }