GraphicsPath.GetBounds メソッド

定義

この GraphicsPath に外接する四角形を返します。

オーバーロード

GetBounds()

この GraphicsPath に外接する四角形を返します。

GetBounds(Matrix)

このパスが指定された GraphicsPath に変換されたときに、この Matrix に外接する四角形を返します。

GetBounds(Matrix, Pen)

現在のパスが指定された GraphicsPath によって変換され、指定された Matrix で描画されるときに、この Pen に外接する四角形を返します。

GetBounds()

ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs

この GraphicsPath に外接する四角形を返します。

public:
 System::Drawing::RectangleF GetBounds();
public System.Drawing.RectangleF GetBounds ();
member this.GetBounds : unit -> System.Drawing.RectangleF
Public Function GetBounds () As RectangleF

戻り値

この RectangleF に外接する四角形を表す GraphicsPath

次のコード例は、Windows フォームで使用するように設計されており、イベント オブジェクトがOnPaint必要PaintEventArgseです。 コードは、次のアクションを実行します。

  • グラフィックス パスを作成します。

  • 楕円 (円) を追加し、画面に描画します。

  • を呼び出 GetBounds して円の外接する四角形を取得し、画面に四角形を描画します。

  • 2 番目のグラフィックス パスを作成します。

  • 円を追加し、パスの幅を 10 に拡大します。

  • 画面へのパスを描画します。

  • 2 番目の円の外接する四角形を取得します。

  • 外接する四角形を画面に描画します。

  • ダイアログ ボックスに四角形のサイズを表示します。

右側の外接する四角形が大きくなっています (線の余分な幅を考慮するため)。

public:
   void GetBoundsExample( PaintEventArgs^ e )
   {
      // Create path number 1 and a Pen for drawing.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Pen^ pathPen = gcnew Pen( Color::Black,1.0f );

      // Add an Ellipse to the path and Draw it (circle in start
      // position).
      myPath->AddEllipse( 20, 20, 100, 100 );
      e->Graphics->DrawPath( pathPen, myPath );

      // Get the path bounds for Path number 1 and draw them.
      RectangleF boundRect = myPath->GetBounds();
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red,1.0f ), boundRect.X, boundRect.Y, boundRect.Height, boundRect.Width );

      // Create a second graphics path and a wider Pen.
      GraphicsPath^ myPath2 = gcnew GraphicsPath;
      Pen^ pathPen2 = gcnew Pen( Color::Black,10.0f );

      // Create a new ellipse with a width of 10.
      myPath2->AddEllipse( 150, 20, 100, 100 );
      myPath2->Widen( pathPen2 );
      e->Graphics->FillPath( Brushes::Black, myPath2 );

      // Get the second path bounds.
      RectangleF boundRect2 = myPath2->GetBounds();

      // Draw the bounding rectangle.
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red,1.0f ), boundRect2.X, boundRect2.Y, boundRect2.Height, boundRect2.Width );

      // Display the rectangle size.
      MessageBox::Show( boundRect2.ToString() );
   }
public void GetBoundsExample(PaintEventArgs e)
{
             
    // Create path number 1 and a Pen for drawing.
    GraphicsPath myPath = new GraphicsPath();
    Pen pathPen = new Pen(Color.Black, 1);
             
    // Add an Ellipse to the path and Draw it (circle in start
             
    // position).
    myPath.AddEllipse(20, 20, 100, 100);
    e.Graphics.DrawPath(pathPen, myPath);
             
    // Get the path bounds for Path number 1 and draw them.
    RectangleF boundRect = myPath.GetBounds();
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1),
        boundRect.X,
        boundRect.Y,
        boundRect.Height,
        boundRect.Width);
             
    // Create a second graphics path and a wider Pen.
    GraphicsPath myPath2 = new GraphicsPath();
    Pen pathPen2 = new Pen(Color.Black, 10);
             
    // Create a new ellipse with a width of 10.
    myPath2.AddEllipse(150, 20, 100, 100);
    myPath2.Widen(pathPen2);
    e.Graphics.FillPath(Brushes.Black, myPath2);
             
    // Get the second path bounds.
    RectangleF boundRect2 = myPath2.GetBounds();
             
    // Draw the bounding rectangle.
    e.Graphics.DrawRectangle(new Pen(Color.Red, 1),
        boundRect2.X,
        boundRect2.Y,
        boundRect2.Height,
        boundRect2.Width);
             
    // Display the rectangle size.
    MessageBox.Show(boundRect2.ToString());
}
Public Sub GetBoundsExample(ByVal e As PaintEventArgs)

    ' Create path number 1 and a Pen for drawing.
    Dim myPath As New GraphicsPath
    Dim pathPen As New Pen(Color.Black, 1)

    ' Add an Ellipse to the path and Draw it (circle in start

    ' position).
    myPath.AddEllipse(20, 20, 100, 100)
    e.Graphics.DrawPath(pathPen, myPath)

    ' Get the path bounds for Path number 1 and draw them.
    Dim boundRect As RectangleF = myPath.GetBounds()
    e.Graphics.DrawRectangle(New Pen(Color.Red, 1), boundRect.X, _
    boundRect.Y, boundRect.Height, boundRect.Width)

    ' Create a second graphics path and a wider Pen.
    Dim myPath2 As New GraphicsPath
    Dim pathPen2 As New Pen(Color.Black, 10)

    ' Create a new ellipse with a width of 10.
    myPath2.AddEllipse(150, 20, 100, 100)
    myPath2.Widen(pathPen2)
    e.Graphics.FillPath(Brushes.Black, myPath2)

    ' Get the second path bounds.
    Dim boundRect2 As RectangleF = myPath2.GetBounds()

    ' Show the bounds in a message box.
    e.Graphics.DrawString("Rectangle2 Bounds: " + _
    boundRect2.ToString(), New Font("Arial", 8), Brushes.Black, _
    20, 150)

    ' Draw the bounding rectangle.
    e.Graphics.DrawRectangle(New Pen(Color.Red, 1), boundRect2.X, _
    boundRect2.Y, boundRect2.Height, boundRect2.Width)
End Sub

注釈

返される外接する四角形のサイズは、エンド キャップ、ペンの幅、およびペンマイターの制限の種類の影響を受けるので、境界パスに "緩いフィット" が生成されます。 おおよその数式は、最初の外接する四角形がペンの幅で拡張され、この結果にマイターの制限と、エンド キャップを可能にする追加の余白が乗算されます。

適用対象

GetBounds(Matrix)

ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs

このパスが指定された GraphicsPath に変換されたときに、この Matrix に外接する四角形を返します。

public:
 System::Drawing::RectangleF GetBounds(System::Drawing::Drawing2D::Matrix ^ matrix);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix matrix);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix? matrix);
member this.GetBounds : System.Drawing.Drawing2D.Matrix -> System.Drawing.RectangleF
Public Function GetBounds (matrix As Matrix) As RectangleF

パラメーター

matrix
Matrix

外接する四角形を計算する前に、このパスに適用される変換を指定する Matrix。 パスは恒久的に変換されるわけではありません。変換は、外接する四角形を計算する処理の中だけで使用されます。

戻り値

この RectangleF に外接する四角形を表す GraphicsPath

例については、「GetBounds()」を参照してください。

注釈

返される外接する四角形のサイズは、エンド キャップ、ペンの幅、およびペンマイターの制限の種類の影響を受けるので、境界パスに "緩いフィット" が生成されます。 おおよその数式は、最初の外接する四角形がペンの幅で拡張され、この結果にマイターの制限と、エンド キャップを可能にする追加の余白が乗算されます。

適用対象

GetBounds(Matrix, Pen)

ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs
ソース:
GraphicsPath.cs

現在のパスが指定された GraphicsPath によって変換され、指定された Matrix で描画されるときに、この Pen に外接する四角形を返します。

public:
 System::Drawing::RectangleF GetBounds(System::Drawing::Drawing2D::Matrix ^ matrix, System::Drawing::Pen ^ pen);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Pen pen);
public System.Drawing.RectangleF GetBounds (System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Pen? pen);
member this.GetBounds : System.Drawing.Drawing2D.Matrix * System.Drawing.Pen -> System.Drawing.RectangleF
Public Function GetBounds (matrix As Matrix, pen As Pen) As RectangleF

パラメーター

matrix
Matrix

外接する四角形を計算する前に、このパスに適用される変換を指定する Matrix。 パスは恒久的に変換されるわけではありません。変換は、外接する四角形を計算する処理の中だけで使用されます。

pen
Pen

Pen の描画に使用する GraphicsPath

戻り値

この RectangleF に外接する四角形を表す GraphicsPath

例については、「GetBounds()」を参照してください。

注釈

返される外接する四角形のサイズは、エンド キャップ、ペンの幅、およびペンマイターの制限の種類の影響を受けるので、境界パスに "緩いフィット" が生成されます。 おおよその数式は、最初の外接する四角形がペンの幅で拡張され、この結果にマイターの制限と、エンド キャップを可能にする追加の余白が乗算されます。

適用対象