次の方法で共有


GraphicsPath.AddArc メソッド (Rectangle, Single, Single)

現在の図形に楕円の円弧を追加します。

Overloads Public Sub AddArc( _
   ByVal rect As Rectangle, _   ByVal startAngle As Single, _   ByVal sweepAngle As Single _)
[C#]
public void AddArc(Rectanglerect,floatstartAngle,floatsweepAngle);
[C++]
public: void AddArc(Rectanglerect,floatstartAngle,floatsweepAngle);
[JScript]
public function AddArc(
   rect : Rectangle,startAngle : float,sweepAngle : float);

パラメータ

  • rect
    円弧の元になる楕円の外接四角形を表す Rectangle 構造体。
  • startAngle
    x 軸から時計回りに測定した、円弧の開始角度。
  • sweepAngle
    startAngle と円弧の終端との間の角度。

解説

図形の中に前回描画された直線や曲線がある場合は、前回の線分の終点と円弧の始点を結ぶ線が追加されます。

円弧は、指定した四角形が外接する楕円の周辺に沿って描画されます。円弧の開始点は、楕円の x 軸 (角度 0 度) から開始角度分だけ時計回りに測定することで決定されます。同様に、終了点の位置も、開始点から時計回りにスイープ角度を測定することで決定されます。スイープ角度が 360 度より大きいか、または -360 度未満の場合、円弧はそれぞれちょうど 360 度または -360 度でスイープされます。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • 四角形を作成します。この図形から円弧が定義されます。
  • パス myPath を作成します。
  • 0 度から 180 度までスイープする 180 度の楕円の円弧を定義し、それをパスに追加します。
  • 画面にパスを描画します。
 
Public Sub AddArcExample(e As PaintEventArgs)
' Create a GraphicsPath object.
Dim myPath As New GraphicsPath()
' Set up and call AddArc, and close the figure.
Dim rect As New Rectangle(20, 20, 50, 100)
myPath.StartFigure()
myPath.AddArc(rect, 0, 180)
myPath.CloseFigure()
' Draw the path to screen.
e.Graphics.DrawPath(New Pen(Color.Red, 3), myPath)
End Sub
        
[C#] 
private void AddArcExample(PaintEventArgs e)
{
// Create a GraphicsPath object.
GraphicsPath myPath = new GraphicsPath();
// Set up and call AddArc, and close the figure.
Rectangle rect = new Rectangle(20, 20, 50, 100);
myPath.StartFigure();
myPath.AddArc(rect, 0, 180);
myPath.CloseFigure();
// Draw the path to screen.
e.Graphics.DrawPath(new Pen(Color.Red, 3), myPath);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

GraphicsPath クラス | GraphicsPath メンバ | System.Drawing.Drawing2D 名前空間 | GraphicsPath.AddArc オーバーロードの一覧