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


C# GraphicsPath类代码示例

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


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

示例1: ResimOlustur

    private void ResimOlustur(int genislik, int yukseklik)
    {
        Bitmap bitmap = new Bitmap(genislik, yukseklik, PixelFormat.Format32bppArgb);

        Graphics g = Graphics.FromImage(bitmap);
        g.SmoothingMode = SmoothingMode.AntiAlias;
        Rectangle rect = new Rectangle(0, 0, genislik, yukseklik);

        HatchBrush hatchBrush = new HatchBrush(HatchStyle.SmallConfetti, Color.LightGray, Color.White);
        g.FillRectangle(hatchBrush, rect);

        SizeF size;
        float fontSize = rect.Height + 1;
        Font font;

        do
        {
            fontSize--;
            font = new Font(System.Drawing.FontFamily.GenericSerif.Name, fontSize, FontStyle.Bold);
            size = g.MeasureString(this.text, font);
        } while (size.Width > rect.Width);

        StringFormat format = new StringFormat();
        format.Alignment = StringAlignment.Center;
        format.LineAlignment = StringAlignment.Center;

        GraphicsPath path = new GraphicsPath();
        path.AddString(this.text, font.FontFamily, (int)font.Style, font.Size, rect, format);
        float v = 4F;
        PointF[] points =
   {
    new PointF(this.random.Next(rect.Width) / v, this.random.Next(rect.Height) / v),
    new PointF(rect.Width - this.random.Next(rect.Width) / v, this.random.Next(rect.Height) / v),
    new PointF(this.random.Next(rect.Width) / v, rect.Height - this.random.Next(rect.Height) / v),
    new PointF(rect.Width - this.random.Next(rect.Width) / v, rect.Height - this.random.Next(rect.Height) / v)
   };
        Matrix matrix = new Matrix();
        matrix.Translate(0F, 0F);
        path.Warp(points, rect, matrix, WarpMode.Perspective, 0F);

        hatchBrush = new HatchBrush(HatchStyle.LargeConfetti, Color.LightGray, Color.DarkGray);
        g.FillPath(hatchBrush, path);

        int m = Math.Max(rect.Width, rect.Height);
        for (int i = 0; i < (int)(rect.Width * rect.Height / 30F); i++)
        {
            int x = this.random.Next(rect.Width);
            int y = this.random.Next(rect.Height);
            int w = this.random.Next(m / 50);
            int h = this.random.Next(m / 50);
            g.FillEllipse(hatchBrush, x, y, w, h);
        }

        font.Dispose();
        hatchBrush.Dispose();
        g.Dispose();

        this.Image = bitmap;
    }
开发者ID:,项目名称:,代码行数:59,代码来源:

示例2: MainForm_Paint

	void MainForm_Paint (object sender, PaintEventArgs e)
	{
		Graphics g = e.Graphics;
		GraphicsPath path = new GraphicsPath ();

		Rectangle borderect = new Rectangle (49, 49, 252, 252);
		g.FillRectangle (new SolidBrush (Color.White), borderect);

		int Diameter = 16;
		Rectangle baserect = new Rectangle (50, 50, 249, 249);

		Rectangle arcrect = new Rectangle (baserect.Location, new Size (Diameter, Diameter));

		// handle top left corner
		path.AddArc (arcrect, 180, 90);

		// handle top right corner
		arcrect.X = baserect.Right - Diameter;
		path.AddArc (arcrect, 270, 90);

		// handle baserect right corner
		arcrect.Y = baserect.Bottom - Diameter;
		path.AddArc (arcrect, 0, 90);

		// handle bottom left corner
		arcrect.X = baserect.Left;
		path.AddArc (arcrect, 90, 90);

		path.CloseFigure ();

		g.DrawPath (Pens.SteelBlue, path);
	}
开发者ID:mono,项目名称:gert,代码行数:32,代码来源:MainForm.cs

示例3: OnPaint

    protected override void OnPaint(PaintEventArgs e)
    {
        e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
        e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
        e.Graphics.CompositingMode = CompositingMode.SourceOver;

        GraphicsPath stroke = new GraphicsPath();
        stroke.AddString(this.Text, this.Font.FontFamily, (int)FontStyle.Regular, this.Font.Size * 1.2f, new Point(0, 0), StringFormat.GenericDefault);
        string tmp = this.Text;
        while (stroke.GetBounds().Width > this.Width - 8) {
            tmp = tmp.Substring(0, tmp.Length - 1);
            stroke = new GraphicsPath();
            stroke.AddString(tmp + "...", this.Font.FontFamily, (int)FontStyle.Regular, this.Font.Size * 1.2f, new Point(0, 0), StringFormat.GenericDefault);
        }

        RectangleF bounds = stroke.GetBounds();
        Matrix translationMatrix = new Matrix();
        if (this.TextAlign == ContentAlignment.TopRight || this.TextAlign == ContentAlignment.MiddleRight || this.TextAlign == ContentAlignment.BottomRight) {
            translationMatrix.Translate(this.Width - bounds.Width - 8, 0);
        } else if (this.TextAlign == ContentAlignment.TopCenter || this.TextAlign == ContentAlignment.MiddleCenter || this.TextAlign == ContentAlignment.BottomCenter) {
            translationMatrix.Translate((this.Width - bounds.Width - 8) / 2, 0);
        }
        if (this.TextAlign == ContentAlignment.MiddleLeft || this.TextAlign == ContentAlignment.MiddleRight || this.TextAlign == ContentAlignment.MiddleCenter) {
            translationMatrix.Translate(0, (this.Height - bounds.Height - 5) / 2);
        } else if (this.TextAlign == ContentAlignment.BottomLeft || this.TextAlign == ContentAlignment.BottomCenter || this.TextAlign == ContentAlignment.BottomRight) {
            translationMatrix.Translate(0, (this.Height - bounds.Height - 5));
        }
        stroke.Transform(translationMatrix);
        e.Graphics.DrawPath(new Pen(Brushes.Black, 3.0f), stroke); /* Stroke */
        e.Graphics.FillPath(Brushes.White, stroke); /* Text */
    }
开发者ID:klange,项目名称:acoustics-windows,代码行数:31,代码来源:TransparentLabel.cs

示例4: OnPaint

 protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
 {
     GraphicsPath grPath = new GraphicsPath();
     grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
     this.Region = new System.Drawing.Region(grPath);
     base.OnPaint(e);
 }
开发者ID:tomskim,项目名称:Four-In-A-Line,代码行数:7,代码来源:RoundButton.cs

示例5: DrawPath

        public override void DrawPath(GraphicsPath gfxPath)
        {


            throw new NotSupportedException();
            //gx.DrawPath(internalPen, gfxPath.InnerPath as System.Drawing.Drawing2D.GraphicsPath);
        }
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:7,代码来源:3_MyGLCanvas_DrawGraphics.cs

示例6: DrawPath

 public override void DrawPath(GraphicsPath gfxPath)
 {
     //convert graphics path to skia path 
     using (SKPath p = ResolveGraphicsPath(gfxPath))
     {
         skCanvas.DrawPath(p, stroke);
     }
 }
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:8,代码来源:3_MySkiaCanvas_DrawGraphics.cs

示例7: OnResize

 protected override void OnResize(EventArgs e)
 {
     using (var path = new GraphicsPath())
     {
         path.AddEllipse(new Rectangle(2, 2, this.Width - 4, this.Height - 4));
         this.Region = new Region(path);
     }
     base.OnResize(e);
 }
开发者ID:Programacao8,项目名称:Academia,代码行数:9,代码来源:RoundButton.cs

示例8: Quadrilateral

        /// <summary>
        ///   Initilizes <c>Quadrilateral</c> object with given corner points.
        /// </summary>
        /// <param name="point1">
        ///   First <c>PointF</c>.
        /// </param>
        /// <param name="point2">
        ///   Second <c>PointF</c>.
        /// </param>
        /// <param name="point3">
        ///   Third <c>PointF</c>.
        /// </param>
        /// <param name="point4">
        ///   Fourth <c>PointF</c>.
        /// </param>
        /// <param name="toClose">
        ///   Indicator should the quadrilateral be closed by the line.
        /// </param>
        public Quadrilateral(PointF point1, PointF point2, PointF point3, PointF point4, bool toClose)
        {
            byte[] pointTypes = (byte[])s_quadrilateralPointTypes.Clone();
            if (toClose)
                pointTypes[3] |= (byte)PathPointType.PathPointTypeCloseSubpath;//CloseSubpath;

            m_path = new GraphicsPath();//new GraphicsPath(new PointF[] { point1, point2, point3, point4 }, pointTypes);
            //m_path.
        }
开发者ID:intille,项目名称:mitessoftware,代码行数:27,代码来源:Quadrilateral.cs

示例9: MainForm_Load

	void MainForm_Load (object sender, EventArgs e)
	{
		GraphicsPath gp = new GraphicsPath ();
		gp.AddArc (_changeShapeButton.ClientRectangle, 0.0f, 360.0f);
		_changeShapeButton.Region = new Region (gp);

		InstructionsForm instructionsForm = new InstructionsForm ();
		instructionsForm.Show ();
	}
开发者ID:mono,项目名称:gert,代码行数:9,代码来源:MainForm.cs

示例10: OnResize

 protected override void OnResize(EventArgs e)
 {
     base.OnResize(e);
     using (var gp = new GraphicsPath())
     {
         gp.AddEllipse(new Rectangle(0, 0, this.Width - 1, this.Height - 1));
         this.Region = new Region(gp);
     }
 }
开发者ID:VforVentordici,项目名称:GameReViews,代码行数:9,代码来源:CircularPictureBox.cs

示例11: CustomLineCap

	public CustomLineCap(GraphicsPath fillPath,
						 GraphicsPath strokePath,
						 LineCap baseCap, float baseInset)
			{
				this.fillPath = fillPath;
				this.strokePath = strokePath;
				this.baseCap = baseCap;
				this.baseInset = baseInset;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:CustomLineCap.cs

示例12: CreateRound

 static internal GraphicsPath CreateRound(Rectangle r, int slope)
 {
     CreateRoundPath = new GraphicsPath(FillMode.Winding);
     CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180f, 90f);
     CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270f, 90f);
     CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0f, 90f);
     CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90f, 90f);
     CreateRoundPath.CloseFigure();
     return CreateRoundPath;
 }
开发者ID:massimoca,项目名称:Wedit,代码行数:10,代码来源:Theme.cs

示例13: GetArrowLinePath

    public static GraphicsPath GetArrowLinePath(float x1, float y1, float x2, float y2,  bool include_arrow, float extra_thickness = 0)
    {
        var newPoints = GetArrowLinePoints(x1, y1, x2, y2, extra_thickness);

        var path = new GraphicsPath(FillMode.Winding);
        path.AddLines(newPoints.ToArray());
        //if (include_arrow)
        //    path.AddLines(GetArrowPoints(x2, y2, extra_thickness).ToArray());
        //path.CloseFigure();
        return path;
    }
开发者ID:idursun,项目名称:StateMachines,代码行数:11,代码来源:GraphUtils.cs

示例14: RoundRect

 public static GraphicsPath RoundRect(Rectangle rect, int Curve)
 {
     GraphicsPath P = new GraphicsPath();
     int ArcRectWidth = Curve * 2;
     P.AddArc(new Rectangle(rect.X, rect.Y, ArcRectWidth, ArcRectWidth), -180, 90);
     P.AddArc(new Rectangle(rect.Width - ArcRectWidth + rect.X, rect.Y, ArcRectWidth, ArcRectWidth), -90, 90);
     P.AddArc(new Rectangle(rect.Width - ArcRectWidth + rect.X, rect.Height - ArcRectWidth + rect.Y, ArcRectWidth, ArcRectWidth), 0, 90);
     P.AddArc(new Rectangle(rect.X, rect.Height - ArcRectWidth + rect.Y, ArcRectWidth, ArcRectWidth), 90, 90);
     P.AddLine(new Point(rect.X, rect.Height - ArcRectWidth + rect.Y), new Point(rect.X, Curve + rect.Y));
     return P;
 }
开发者ID:MrAdder,项目名称:Launcher_Arma3,代码行数:11,代码来源:Theme_Perplex.cs

示例15: CustomLineCap

		public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset)
		{
			IntPtr fill = IntPtr.Zero;
			IntPtr stroke = IntPtr.Zero;

			if (fillPath != null)
				fill = fillPath.nativePath;
			if (strokePath != null)
				stroke = strokePath.nativePath;

			Status status = GDIPlus.GdipCreateCustomLineCap (fill, stroke, baseCap, baseInset, out nativeObject);
			GDIPlus.CheckStatus (status);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:13,代码来源:CustomLineCap.cs


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