当前位置: 移动技术网 > IT编程>开发语言>c# > C#画笔Pen使用路径绘制图形的方法

C#画笔Pen使用路径绘制图形的方法

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了c#画笔pen使用路径绘制图形的方法。分享给大家供大家参考。具体实现方法如下:

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
using system.drawing.drawing2d;
namespace windowsapplication2
{
  public partial class form10 : form
  {
    public form10()
    {
      initializecomponent();
    }
    graphicspath get(rectangle rect, int radius)
    {
      int diameter = 2 * radius;
      rectangle arcrect = new rectangle(rect.location, new size(diameter, diameter));
      graphicspath path = new graphicspath();
      path.addarc(arcrect, 180, 90);
      arcrect.x=rect.right-diameter;
      path.addarc(arcrect, 270, 90);
      arcrect.y = rect.bottom - diameter;
      path.addarc(arcrect, 0, 90);
      arcrect.x = rect.left;
      path.addarc(arcrect, 90, 90);
      path.closefigure();
      return path;
    }
    private void button1_click(object sender, eventargs e)
    {
      graphics g = this.creategraphics();
      int width = this.clientrectangle.width;
      int height = this.clientrectangle.height;
      rectangle rect = new rectangle(10, 10, width - 20, height - 20);
      graphicspath path = get(rect, width / 10);
      g.fillpath(brushes.red, path);
      g.drawpath(pens.yellow, path);
    }
  }
}

希望本文所述对大家的c#程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网