參數說明
C# Code,稍微修正文章內範例
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace GraphicsSample
{
public partial class FrmArcAngle : Form
{
public FrmArcAngle()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
ArcAngle(e);
base.OnPaint(e);
}
private void ArcAngle(PaintEventArgs e)
{
// 設定一個正方形
Rectangle rect = new Rectangle(130, 20, 100, 100);
// 透過 GraphicsPath 來畫橢圓弧形
GraphicsPath myPath = new GraphicsPath();
myPath.StartFigure();
// X 軸角度為 0 並從 X 軸為 0 度開始畫一個 180 度橢圓弧形
myPath.AddArc(rect, 0, 180);
// 把起點和終點連起來
myPath.CloseFigure();
// 進行繪製
e.Graphics.DrawRectangle(Pens.Black, rect);
e.Graphics.DrawPath(new Pen(Color.Red, 5), myPath);
}
}
}