您的位置:首页 > 其它

GDI+基础知识——画笔的线帽属性示意

2012-12-10 20:51 190 查看


 
  //线帽演示
  private void Pen_LineCap_Click(object sender, System.EventArgs e)
  {
   Graphics graphics = this.CreateGraphics();
   graphics.Clear(Color.White);
   //设置文本输出对齐方式及字体
   StringFormat fmt = new StringFormat();
   fmt.Alignment = StringAlignment.Near;
   fmt.LineAlignment = StringAlignment.Center;
   //字体
   Font font = new Font("Arial",12);
   SolidBrush sBrush = new SolidBrush(Color.Red);
   //创建宽度为15的画笔
   Pen pen = new Pen(Color.Black,15);
   //分别使用不同的线帽
   foreach (LineCap lincap in Enum.GetValues(typeof(LineCap)))
   {
    pen.StartCap = lincap;//起点
    pen.EndCap = lincap;//终点
    graphics.DrawLine(pen,50,10,300,10);
    //输出当前线帽类型(LineCap枚举成员名)
    graphics.DrawString(pen.StartCap.ToString(),
     font,sBrush,new Point(320,10),fmt);
    //平移绘图平面
    graphics.TranslateTransform(0,30);
   }
  }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: