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


C# Drawing2D.GraphicsPath类代码示例

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


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

示例1: Form1_Paint

        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);

            }

        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:25,代码来源:Form1.cs

示例2: CalculateGraphicsPathFromBitmap

		// From http://edu.cnzz.cn/show_3281.html
		public static GraphicsPath CalculateGraphicsPathFromBitmap(Bitmap bitmap, Color colorTransparent) 
		{ 
			GraphicsPath graphicsPath = new GraphicsPath(); 
			if (colorTransparent == Color.Empty)
				colorTransparent = bitmap.GetPixel(0, 0); 

			for(int row = 0; row < bitmap.Height; row ++) 
			{ 
				int colOpaquePixel = 0;
				for(int col = 0; col < bitmap.Width; col ++) 
				{ 
					if(bitmap.GetPixel(col, row) != colorTransparent) 
					{ 
						colOpaquePixel = col; 
						int colNext = col; 
						for(colNext = colOpaquePixel; colNext < bitmap.Width; colNext ++) 
							if(bitmap.GetPixel(colNext, row) == colorTransparent) 
								break;
 
						graphicsPath.AddRectangle(new Rectangle(colOpaquePixel, row, colNext - colOpaquePixel, 1)); 
						col = colNext; 
					} 
				} 
			} 
			return graphicsPath; 
		} 
开发者ID:hanistory,项目名称:hasuite,代码行数:27,代码来源:DrawHelper.cs

示例3: Task1_Paint

 private void Task1_Paint(object sender, PaintEventArgs e)
 {
     e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     switch (_current)
     {
         case TextType.In:
             e.Graphics.DrawString("Sample", new Font("Arial", 50), new SolidBrush(Color.DarkSlateGray), 10, 75);
             e.Graphics.DrawString("Sample", new Font("Arial", 50), new SolidBrush(Color.Black), 12, 77);
             break;
         case TextType.Out:
             e.Graphics.DrawString("Sample", new Font("Arial", 50), new SolidBrush(Color.Black), 10, 75);
             e.Graphics.DrawString("Sample", new Font("Arial", 50), new SolidBrush(Color.DarkSlateGray), 12, 77);
             break;
         case TextType.Kon:
             GraphicsPath path = new GraphicsPath();
             path.AddString("Sample",
                 new FontFamily("Arial"),
                 (int) FontStyle.Italic,
                 50,
                 new Point(10, 75),
                 StringFormat.GenericDefault);
             e.Graphics.DrawPath(new Pen(Color.Black), path);
             break;
     }
 }
开发者ID:npzxcf,项目名称:ComputerGraphics,代码行数:25,代码来源:Task1.cs

示例4: GetBrush

        public static System.Drawing.Brush GetBrush(this Brush brush, Rect frame)
        {
            var cb = brush as SolidBrush;
            if (cb != null) {
                return new System.Drawing.SolidBrush (cb.Color.GetColor ());
            }

            var lgb = brush as LinearGradientBrush;
            if (lgb != null) {
                var s = lgb.Absolute ? lgb.Start : frame.Position + lgb.Start * frame.Size;
                var e = lgb.Absolute ? lgb.End : frame.Position + lgb.End * frame.Size;
                var b = new System.Drawing.Drawing2D.LinearGradientBrush (GetPointF (s), GetPointF (e), System.Drawing.Color.Black, System.Drawing.Color.Black);
                var bb = BuildBlend (lgb.Stops);
                if (bb != null) {
                    b.InterpolationColors = bb;
                }
                return b;
            }

            var rgb = brush as RadialGradientBrush;
            if (rgb != null) {
                var r = rgb.GetAbsoluteRadius (frame);
                var c = rgb.GetAbsoluteCenter (frame);
                var path = new GraphicsPath ();
                path.AddEllipse (GetRectangleF (new Rect (c - r, 2 * r)));
                var b = new PathGradientBrush (path);
                var bb = BuildBlend (rgb.Stops, true);
                if (bb != null) {
                    b.InterpolationColors = bb;
                }
                return b;
            }

            throw new NotImplementedException ("Brush " + brush);
        }
开发者ID:sami1971,项目名称:NGraphics,代码行数:35,代码来源:SystemDrawingPlatform.cs

示例5: createRoundedRectangles

        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;
        }
开发者ID:stormholder,项目名称:dotnet_alarmclock,代码行数:25,代码来源:Form1.cs

示例6: DrawRegionRepresentation

        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 pt1 = refPt + PointD.Orthogonal(m_Param.V) * 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;

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

                }

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

            }
        }
开发者ID:rhfung,项目名称:KinematicTemplates,代码行数:26,代码来源:FakeHatchingFilter.cs

示例7: SimpleShapedForm_Load

		private void SimpleShapedForm_Load(object sender, EventArgs e)
		{
			GraphicsPath path = new GraphicsPath();
			path.AddEllipse(0, 0, this.Width, this.Height);
			this.Region = new Region(path);

		}
开发者ID:ehershey,项目名称:development,代码行数:7,代码来源:SimpleShapedForm.cs

示例8: GetTopRoundedRect

        //public static GraphicsPath GetBottomRoundRect(RectangleF r, int offset)
        //{
        //    int left = Math.Min((int)r.Left, (int)r.Right);
        //    int right = Math.Max((int)r.Left, (int)r.Right);
        //    int top = Math.Min((int)r.Top, (int)r.Bottom);
        //    int bottom = Math.Max((int)r.Top, (int)r.Bottom);
        //    GraphicsPath path = new GraphicsPath();
        //    path.AddLine(r.Right, r.Top, r.Right, r.Top);
        //    path.AddArc(right - offset, bottom - offset, offset, offset, 0.0f, 90.0f);
        //    path.AddArc(left, bottom - offset, offset, offset, 90.0f, 90.0f);
        //    path.AddLine(r.Left, r.Top, r.Left, r.Top);
        //    path.CloseFigure();
        //    return path;
        //}
        public static GraphicsPath GetTopRoundedRect(RectangleF r, int offset)
        {
            int left = Math.Min((int)r.Left, (int)r.Right);
            int right = Math.Max((int)r.Left, (int)r.Right);

            int top = Math.Min((int)r.Top, (int)r.Bottom);
            int bottom = Math.Max((int)r.Top, (int)r.Bottom);

            GraphicsPath path = new GraphicsPath();
            try
            {
                path.AddArc(right - offset, top, offset, offset, 270.0f, 90.0f);
                path.AddLine(r.Right, r.Bottom, r.Right, r.Bottom);
                path.AddLine(r.Left, r.Bottom, r.Left, r.Bottom);
                path.AddArc(left, top, offset, offset, 180.0f, 90.0f);
                path.CloseFigure();

                return path;
            }
            catch
            {
                path.Dispose();
                throw;
            }
        }
开发者ID:helgihaf,项目名称:Alpha,代码行数:39,代码来源:PathHelper.cs

示例9: MeasureTextHeight

        public static float MeasureTextHeight(Font font, string text, bool bold)
        {
            using (var sf = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near })
            {
                using (var path = new GraphicsPath())
                {

                    var sb = new StringBuilder(text);
                    bool newLine = false;
                    const int leftMargin = 0;
                    int pathPointsStart = -1;
                    DrawText(font, sf, path, sb, false, bold, false, 0, 0, ref newLine, leftMargin, ref pathPointsStart);

                    float height = 0;
                    var list = (PointF[])path.PathPoints.Clone(); // avoid using very slow path.PathPoints indexer!!!
                    int index = list.Length - 80;
                    if (index < 0)
                        index = 0;
                    for (int i = index; i < list.Length; i += 2)
                    {
                        if (list[i].Y > height)
                            height = list[i].Y;
                    }

                    for (int i = 0; i < list.Length; i += 2)
                    {
                        if (list[i].Y > height)
                            height = list[i].Y;
                    }

                    return height;
                }
            }
        }
开发者ID:socialpercon,项目名称:subtitleedit,代码行数:34,代码来源:TextDraw.cs

示例10: AddTabBorder

        public override void AddTabBorder(GraphicsPath path, Rectangle tabBounds)
        {

            switch (tabControl.Alignment)
            {
                case TabAlignment.Top:
                    path.AddLine(tabBounds.X, tabBounds.Bottom, tabBounds.X, tabBounds.Y + this.radius);
                    path.AddArc(tabBounds.X, tabBounds.Y, this.radius * 2, this.radius * 2, 180, 90);
                    path.AddLine(tabBounds.X + this.radius, tabBounds.Y, tabBounds.Right - this.radius, tabBounds.Y);
                    path.AddArc(tabBounds.Right - this.radius * 2, tabBounds.Y, this.radius * 2, this.radius * 2, 270, 90);
                    path.AddLine(tabBounds.Right, tabBounds.Y + this.radius, tabBounds.Right, tabBounds.Bottom);
                    break;
                case TabAlignment.Bottom:
                    path.AddLine(tabBounds.Right, tabBounds.Y, tabBounds.Right, tabBounds.Bottom - this.radius);
                    path.AddArc(tabBounds.Right - this.radius * 2, tabBounds.Bottom - this.radius * 2, this.radius * 2, this.radius * 2, 0, 90);
                    path.AddLine(tabBounds.Right - this.radius, tabBounds.Bottom, tabBounds.X + this.radius, tabBounds.Bottom);
                    path.AddArc(tabBounds.X, tabBounds.Bottom - this.radius * 2, this.radius * 2, this.radius * 2, 90, 90);
                    path.AddLine(tabBounds.X, tabBounds.Bottom - this.radius, tabBounds.X, tabBounds.Y);
                    break;
                case TabAlignment.Left:
                    path.AddLine(tabBounds.Right, tabBounds.Bottom, tabBounds.X + this.radius, tabBounds.Bottom);
                    path.AddArc(tabBounds.X, tabBounds.Bottom - this.radius * 2, this.radius * 2, this.radius * 2, 90, 90);
                    path.AddLine(tabBounds.X, tabBounds.Bottom - this.radius, tabBounds.X, tabBounds.Y + this.radius);
                    path.AddArc(tabBounds.X, tabBounds.Y, this.radius * 2, this.radius * 2, 180, 90);
                    path.AddLine(tabBounds.X + this.radius, tabBounds.Y, tabBounds.Right, tabBounds.Y);
                    break;
                case TabAlignment.Right:
                    path.AddLine(tabBounds.X, tabBounds.Y, tabBounds.Right - this.radius, tabBounds.Y);
                    path.AddArc(tabBounds.Right - this.radius * 2, tabBounds.Y, this.radius * 2, this.radius * 2, 270, 90);
                    path.AddLine(tabBounds.Right, tabBounds.Y + this.radius, tabBounds.Right, tabBounds.Bottom - this.radius);
                    path.AddArc(tabBounds.Right - this.radius * 2, tabBounds.Bottom - this.radius * 2, this.radius * 2, this.radius * 2, 0, 90);
                    path.AddLine(tabBounds.Right - this.radius, tabBounds.Bottom, tabBounds.X, tabBounds.Bottom);
                    break;
            }
        }
开发者ID:h3tch,项目名称:ProtoFX,代码行数:35,代码来源:TabStyleRoundedProvider.cs

示例11: DrawRoundedRectangle

        public static void DrawRoundedRectangle(Graphics newGraphics, Color boxColor, Color gradFillColor1, Color gradFillColor2, int xPosition, int yPosition,
                   int height, int width, int cornerRadius)
        {
            using (var boxPen = new Pen(boxColor))
            {
                using (var path = new GraphicsPath())
                {
                    path.AddLine(xPosition + cornerRadius, yPosition, xPosition + width - (cornerRadius * 2), yPosition);
                    path.AddArc(xPosition + width - (cornerRadius * 2), yPosition, cornerRadius * 2, cornerRadius * 2, 270, 90);
                    path.AddLine(xPosition + width, yPosition + cornerRadius, xPosition + width,
                                 yPosition + height - (cornerRadius * 2));
                    path.AddArc(xPosition + width - (cornerRadius * 2), yPosition + height - (cornerRadius * 2), cornerRadius * 2,
                                cornerRadius * 2, 0, 90);
                    path.AddLine(xPosition + width - (cornerRadius * 2), yPosition + height, xPosition + cornerRadius,
                                 yPosition + height);
                    path.AddArc(xPosition, yPosition + height - (cornerRadius * 2), cornerRadius * 2, cornerRadius * 2, 90, 90);
                    path.AddLine(xPosition, yPosition + height - (cornerRadius * 2), xPosition, yPosition + cornerRadius);
                    path.AddArc(xPosition, yPosition, cornerRadius * 2, cornerRadius * 2, 180, 90);
                    path.CloseFigure();
                    newGraphics.DrawPath(boxPen, path);

                    var b = new LinearGradientBrush(new Point(xPosition, yPosition),
                                                    new Point(xPosition + width, yPosition + height), gradFillColor1,
                                                    gradFillColor2);

                    newGraphics.FillPath(b, path);
                }
            }
        }
开发者ID:hithto,项目名称:Captcha,代码行数:29,代码来源:HtmlExtensions.cs

示例12: MakePath

 public override GraphicsPath MakePath()
 {
     GraphicsPath path1 = new GraphicsPath(FillMode.Winding);
     RectangleF ef1 = this.Bounds;
     path1.AddEllipse(ef1.X, ef1.Y, ef1.Width, ef1.Height);
     return path1;
 }
开发者ID:JBTech,项目名称:Dot.Utility,代码行数:7,代码来源:EllipseGraph.cs

示例13: Get

 public override GraphicsPath Get()
 {
     var shape = new GraphicsPath();
     var bounds = new Rectangle(this.state.Left, this.state.Top, this.state.Width, this.state.Height);
     shape.AddEllipse(bounds);
     return shape;
 }
开发者ID:attila3453,项目名称:alsing,代码行数:7,代码来源:EllipseShape.cs

示例14: DrawYourSelf

        /// <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);
            }
        }
开发者ID:ferry2,项目名称:2D-Vector-Graphics,代码行数:35,代码来源:ConnectedEllipses.cs

示例15: Draw

        public new void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons) {

            GraphicsPath gpSeekPosition = new GraphicsPath();
            gpSeekPosition.AddLine(new PointF(6.0F, 2), new PointF(this.SeekerBounds.Width - this.SeekerPosition * (this.SeekerBounds.Width - 15) - 5, 2));
            gpSeekPosition.Widen(this.m_pOneWidth);
            this.DrawBwShape(g, gpSeekPosition, this.ButtonOpacity, 4.0F, Color.Black, ControlPaint.LightLight(Color.LightSeaGreen));

            if (this.m_isMouseDown == true) {

                if (pntMouseLocation.X < pntDrawOffset.X) {
                    this.SeekerPosition = 0.0F;
                }
                else if (pntMouseLocation.X > pntDrawOffset.X + this.SeekerBounds.Width - 15) {
                    this.SeekerPosition = 1.0F;
                }
                else {
                    this.SeekerPosition = (pntMouseLocation.X - pntDrawOffset.X - 6) / (this.SeekerBounds.Width - 15);
                }
            }

            float xBeginningOffset = pntDrawOffset.X;

            pntDrawOffset.X += this.SeekerPosition * (this.SeekerBounds.Width - 15);

            this.HotSpot = new RectangleF(-pntDrawOffset.X + xBeginningOffset, -15, this.SeekerBounds.Width, 20);

            base.Draw(g, pntDrawOffset, pntMouseLocation, mbButtons);

            gpSeekPosition.Dispose();
        }
开发者ID:EBassie,项目名称:Procon-1,代码行数:30,代码来源:MapTimelineSeekButton.cs


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