GDI+基礎知識——畫筆的線帽屬性示意

來源:互聯網
上載者:User

 

  //線帽示範
  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);
   }
  }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.