当前位置: 首页>>代码示例>>C#>>正文


C# GraphicsPath.AddCurve方法代码示例

本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.AddCurve方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.AddCurve方法的具体用法?C# GraphicsPath.AddCurve怎么用?C# GraphicsPath.AddCurve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Drawing2D.GraphicsPath的用法示例。


在下文中一共展示了GraphicsPath.AddCurve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Form1_Paint

        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();
        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:30,代码来源:Form1.cs

示例2: Form1_Paint

        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();
        }
开发者ID:RoykoSerhiy,项目名称:visualStudio_projects,代码行数:29,代码来源:Form1.cs

示例3: Demo0

        private void Demo0(Graphics g)
        {
            renderXY(g);//初始化坐标轴

            //========划线-画点
            Pen pen1 = new Pen(Color.Red, 1);
            Pen pen2 = new Pen(Color.Blue);
            int total_point_num=1000;
            PointF[] CurvePoints = new PointF[total_point_num];
            for (int x = 0; x < total_point_num; x += 10)
            {
                //计算点坐标-正弦曲线
                float y = (float)( 100*Math.Sin(x*300) );
                //坐标轴置换
                y = -y + this.pictureBox1.Height-200;
                //点保存到数组中,供下文创建路径用
                CurvePoints[x] = new PointF(x, y);
                //画空心点-画笔,矩形(坐标x,坐标y,宽度,高度);
                g.DrawEllipse(pen2, new RectangleF(x, y, 3, 3));
            }

            //创建路径
            GraphicsPath myPath = new GraphicsPath();
            //AddCurve(点阵,起点,终点,弯曲程度)
            //myPath.AddCurve(CurvePoints, 0, 7, 0.8f);
            myPath.AddCurve(CurvePoints,0,300,0.01F);
            //定义画笔
            Pen myPen = new Pen(Color.Red, 1);
            //划线--------------------------------------------bug为什么点稀疏的时候不是两两连接?
            //g.DrawPath(myPen, myPath);

            //g.DrawCurve(pen1, CurvePoints, 0.05F);
        }
开发者ID:DawnEve,项目名称:learngit,代码行数:33,代码来源:Form1.cs

示例4: ReturnBounds

        public override RectangleF ReturnBounds()
        {
            Point[] points = (Point[])pointsList.ToArray(typeof(Point));
            GraphicsPath path = new GraphicsPath();
            path.AddCurve(points,1);

            path.Transform(this.TMatrix.TransformationMatrix);
            return  path.GetBounds();
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:9,代码来源:CurveShape.cs

示例5: Form1

        public Form1()
        {
            InitializeComponent();
              SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserMouse | ControlStyles.ResizeRedraw, true);

              //create graph path
              path = new GraphicsPath();
              path.AddCurve(new Point[] { new Point(10, 20), new Point(102, 203), new Point(150, 20) });
              path.AddEllipse(new Rectangle(100, 200, 300, 300));
              path.AddRectangle(new Rectangle(150, 100, 240, 50));
        }
开发者ID:Mexahoid,项目名称:CSF,代码行数:11,代码来源:Form1.cs

示例6: UpdatePath

		protected override void UpdatePath()
		{
            if (this.Points == null || this.Points.Length == 0) return;

			InternalPath = new GraphicsPath();
			InternalPath.AddCurve(this.Points);

			Matrix mtx = new Matrix();
			mtx.RotateAt(this.Rotation, InternalRotationBasePoint);
			InternalPath.Transform(mtx);
		}
开发者ID:westybsa,项目名称:MP.LSharp,代码行数:11,代码来源:ShapeCurve.cs

示例7: CreatePath

        private GraphicsPath CreatePath(Rectangle rect)
        {
            GraphicsPath path = new GraphicsPath();

            path.AddArc(rect.X, rect.Y + 30, 8, 8, 180, 90);

            path.AddCurve(new Point[] {
                new Point(rect.X + rect.Width/2 + 5,rect.Y + 30),
                new Point(rect.X + rect.Width/2,rect.Y + 15),
                new Point(rect.X + rect.Width/2 - 10,rect.Y)}, 1f);

            path.AddCurve(new Point[] {
                new Point(rect.X + rect.Width/2 - 10,rect.Y),
                new Point(rect.X + rect.Width/2+ 10,rect.Y + 15),
                new Point(rect.X + rect.Width/2 + 20,rect.Y + 30)}, 1f);

            path.AddArc(rect.Right - 9, rect.Y + 30, 8, 8, 270, 90);
            path.AddArc(rect.Right - 9, rect.Bottom - 9, 8, 8, 0, 90);
            path.AddArc(rect.X, rect.Bottom - 9, 8, 8, 90, 90);
            path.CloseFigure();
            return path;
        }
开发者ID:carreygroup,项目名称:RelayMgr,代码行数:22,代码来源:RegionControl.cs

示例8: GetArcPath

        public static GraphicsPath GetArcPath(RectangleF container, double dStartDegrees, double dArcLengthDegrees)
        {
            GraphicsPath arcPath = new GraphicsPath();

            int nPoints = 100;
            double dEachPointDelta = dArcLengthDegrees / (double)(nPoints);
            List<PointF> arcPts = new List<PointF>();
            for (int i = 0; i <= nPoints; i++)
            {
                double curDeg = dStartDegrees - (i * dEachPointDelta);
                arcPts.Add(GetPointInArc(container, curDeg, 0));
            }

            arcPath.AddCurve(arcPts.ToArray());

            return arcPath;
        }
开发者ID:yahiafarghaly,项目名称:wcontrols,代码行数:17,代码来源:GraphicsHelper.cs

示例9: GenerateLineGraph

        public static void GenerateLineGraph(int width, int height, int maxValue, int[] values, string saveLocation, int leftBuffer, int bottomBuffer, int low)
        {
            Bitmap bm = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            Graphics graphics = Graphics.FromImage(bm);
            SolidBrush brush = new SolidBrush(Color.Aquamarine);
            graphics.FillRectangle(brush, leftBuffer, 0, width, height - bottomBuffer);
            brush.Dispose();

            SolidBrush foreground = new SolidBrush(Color.DarkCyan);
            Pen p = new Pen(foreground);
            Point lastp = new Point(leftBuffer, (height - bottomBuffer) - (int)(((float)values[0] / maxValue) * (height - bottomBuffer)));
            GraphicsPath gp = new GraphicsPath();
            gp.AddLine(new Point(leftBuffer, height - bottomBuffer), lastp);
            Point[] curve = new Point[values.Length];
            curve[0] = lastp;
            for (int x = 0; x < values.Length; x++)
            {
                Point top = new Point(leftBuffer + (int)(((float)(width - leftBuffer) / (float)(values.Length)) * x), 0);
                Point bottom = new Point(leftBuffer + (int)(((float)(width - leftBuffer) / (float)(values.Length)) * x), height);
                graphics.DrawLine(p, top, bottom);
                Point pnt = new Point(leftBuffer + (int)(((float)(width - leftBuffer) / (float)(values.Length)) * x), (height - bottomBuffer) - (int)(((float)values[x] / maxValue) * (height - bottomBuffer)));
                curve[x] = pnt;
                lastp = pnt;
            }
            curve[values.Length - 1] = new Point(width, (height - bottomBuffer) - (int)(((float)values[values.Length - 1] / maxValue) * (height - bottomBuffer)));
            gp.AddCurve(curve);
            gp.AddLine(curve[values.Length - 1], new Point(width, (height - bottomBuffer)));
            gp.AddLine(new Point(leftBuffer, height), new Point(width, (height - bottomBuffer)));
            LinearGradientBrush lgb = new LinearGradientBrush(new Point(width / 2, (height - bottomBuffer)), new Point(width / 2, 0), Color.DarkBlue, Color.Cyan);
            graphics.FillRegion(lgb, new Region(gp));
            for (int x = 0; x < values.Length; x++)
            {
                SizeF stringSize = new SizeF();
                Font arial = new Font("Monospace", 12);
                stringSize = graphics.MeasureString(x.ToString(), arial);
                int shift = (int)(((float)(width - leftBuffer) / (float)(values.Length)) / 2) - (int)(stringSize.Width / 2);
                Point bottom = new Point(leftBuffer + (int)(((float)(width - leftBuffer) / (float)(values.Length)) * x) + shift, height - bottomBuffer);
                graphics.DrawString(x.ToString(), arial, foreground, bottom);
            }
            p.Dispose();
            foreground.Dispose();
            bm.Save(saveLocation, ImageFormat.Bmp);
        }
开发者ID:bwall,项目名称:bwall-s-smaller-projects,代码行数:43,代码来源:GraphGenerator.cs

示例10: DrawYourSelf

        public override void DrawYourSelf(Graphics graphics)
        {
            if (pointsList.Count < 4) return;
            Point[] points = (Point[])pointsList.ToArray(typeof(Point));

            GraphicsPath path = new GraphicsPath();
            path.AddCurve(points,1);
            path.Transform(this.TMatrix.TransformationMatrix);

            Pen pen = new Pen(this.BorderColor, this.BorderWidth);

            graphics.DrawPath(pen, path);

            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:19,代码来源:CurveShape.cs

示例11: ContainsPoint

        /// <summary>
        /// Проверяет попадание точки в фигуру
        /// </summary>
        /// <param name="p"></param>
        /// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
        public int ContainsPoint(Point p)
        {
            if (this.IsSelected)
            {
                for (int i = 1; i <= KeyPoints.Length; i++)
                {
                    if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
                        return i;
                }
            }

            var path = new GraphicsPath();
            Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);
            path.AddCurve(points.ToArray());
            path.Widen(pen);
            Region region = new Region(path);
            pen.Dispose();
            if (region.IsVisible(p))
                return 0;
            return -1;
        }
开发者ID:tsiganoff,项目名称:PFSOFT_Test,代码行数:26,代码来源:Curve.cs

示例12: Get3DShinePath

        private const double ROUNDED_RECT_RAD_PERCENT = .05d; //5 percent

        #endregion Fields

        #region Methods

        public static GraphicsPath Get3DShinePath(Rectangle container, ControlShape shape)
        {
            GraphicsPath path = new GraphicsPath();

            Rectangle pathRect = container;
            pathRect.Width -= 1;
            pathRect.Height -= 1;

            RectangleF halfRect = new RectangleF(pathRect.X, pathRect.Y,
                                                    pathRect.Width, pathRect.Height / 2f);

            if (pathRect.Height > 0 && pathRect.Width > 0)
            {
                switch (shape)
                {
                    case ControlShape.Rect:
                        path.AddRectangle(halfRect);
                        break;
                    case ControlShape.RoundedRect:
                        //radius is 10% of smallest side
                        int rad = (int)(Math.Min(halfRect.Height, halfRect.Width) * ROUNDED_RECT_RAD_PERCENT);
                        path.AddRoundedRectangle(halfRect, rad);
                        break;
                    case ControlShape.Circular:
                        path.AddArc(pathRect, 180, 142);
                        PointF[] pts = new PointF[]
                    {
                        path.GetLastPoint(),
                        new PointF(container.Width * .70f, container.Height * .33f),
                        new PointF(container.Width * .25f, container.Height * .5f),
                        path.PathPoints[0]
                    };
                        path.AddCurve(pts);
                        path.CloseFigure();
                        break;
                }
            }

            return path;
        }
开发者ID:yahiafarghaly,项目名称:wcontrols,代码行数:46,代码来源:GraphicsHelper.cs

示例13: Curve_GetRegionScans

		public void Curve_GetRegionScans ()
		{
			Point[] points = new Point[2] { new Point (-4194304, -4194304), new Point (4194304, 4194304) };
			GraphicsPath gp = new GraphicsPath ();
			gp.AddCurve (points);
			Region region = new Region (gp);
			// too big, returns 0
			Assert.AreEqual (0, region.GetRegionScans (matrix).Length, "GetRegionScans");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:RegionNonRectTest.cs

示例14: Region_Curve_IsInfinite

		public void Region_Curve_IsInfinite ()
		{
			Point[] points = new Point[2] { new Point (-4194304, -4194304), new Point (4194304, 4194304) };
			GraphicsPath gp = new GraphicsPath ();
			gp.AddCurve (points);
			CheckInfiniteBounds (gp);

			Region region = new Region (gp);
			Assert.IsFalse (region.IsInfinite (graphic), "IsInfinite");
			// note: infinity isn't based on the bounds
		}
开发者ID:nlhepler,项目名称:mono,代码行数:11,代码来源:RegionNonRectTest.cs

示例15: DrawSmoothFilledCurve

        /// <summary>
        /// Draw the this <see cref="CurveItem"/> to the specified <see cref="Graphics"/>
        /// device using the specified smoothing property (<see cref="ZedGraph.Line.SmoothTension"/>).
        /// The routine draws the line segments and the area fill (if any, see <see cref="FillType"/>;
        /// the symbols are drawn by the <see cref="Symbol.Draw"/> method.  This method
        /// is normally only called by the Draw method of the
        /// <see cref="CurveItem"/> object.  Note that the <see cref="StepType"/> property
        /// is ignored for smooth lines (e.g., when <see cref="ZedGraph.Line.IsSmooth"/> is true).
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="GraphPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="points">A <see cref="PointPairList"/> of point values representing this
        /// curve.</param>
        /// <param name="isY2Axis">A value indicating to which Y axis this curve is assigned.
        /// true for the "Y2" axis, false for the "Y" axis.</param>
        public void DrawSmoothFilledCurve( Graphics g, GraphPane pane,
                                PointPairList points, bool isY2Axis, double scaleFactor)
        {
            PointF[]	arrPoints;
            int			count;

            if ( this.IsVisible && !this.Color.IsEmpty && points != null &&
                BuildPointsArray( pane, points, isY2Axis, out arrPoints, out count ) &&
                count > 2 )
            {
                Pen pen = new Pen(this.Color, pane.ScaledPenWidth(width, scaleFactor));
                pen.DashStyle = this.Style;
                float tension = this.isSmooth ? this.smoothTension : 0f;

                // Fill the curve if needed
                if ( this.Fill.IsVisible )
                {
                    GraphicsPath path = new GraphicsPath( FillMode.Winding );
                    path.AddCurve( arrPoints, 0, count-2, tension );

                    double yMin = pane.YAxis.Min < 0 ? 0.0 : pane.YAxis.Min;
                    //double yMin = pane.YAxis.Min;

                    CloseCurve( pane, arrPoints, isY2Axis, count, yMin, path );

                    Brush brush = this.fill.MakeBrush( path.GetBounds() );
                    g.FillPath( brush, path );

                    brush.Dispose();
                }

                // Stroke the curve
                g.DrawCurve( pen, arrPoints, 0, count-2, tension );
            }
        }
开发者ID:InsungChoi,项目名称:dddd,代码行数:62,代码来源:Line.cs


注:本文中的System.Drawing.Drawing2D.GraphicsPath.AddCurve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。