在 C# 中繪製橢圓
若要繪製橢圓,請使用屬於 Graphics 物件的 C# 中的 drawEllipse() 方法。它既包含筆物件又包含矩形物件。
在 C# 中繪製形狀需要 Windows 窗體。
設定圖形物件。
Graphics g = this.CreateGraphics();
現在是筆物件。
Pen p = new Pen(new SolidBrush(Color.Red), 15);
以下是矩形物件。
Rectangle r = new Rectangle(120, 60, 180, 180);
現在,使用帶圖形物件的 drawEllipse() 方法,並在其中新增兩個物件以繪製橢圓。
s.DrawEllipse(p, r);
廣告