RectangleFとは? わかりやすく解説

RectangleF コンストラクタ (Single, Single, Single, Single)

指定した位置とサイズで、RectangleF クラスの新しいインスタンスを初期化します。

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

使用例使用例

RectangleF メンバ、Round メンバ、および Truncate メンバの使用方法を示すコード例を次に示します。この例は、Windows フォームでの使用を意図してデザインされています。このコードをフォームに貼り付け、フォームの Paint イベントを処理するときに PaintEventArgs の e を渡して RoundingAndTruncatingRectangles メソッドを呼び出します。

Private Sub RoundingAndTruncatingRectangles(
 _
    ByVal e As PaintEventArgs)

    ' Construct a new RectangleF.
    Dim myRectangleF As New
 RectangleF(30.6F, 30.7F, 40.8F, 100.9F)

    ' Call the Round method.
    Dim roundedRectangle As Rectangle = Rectangle.Round(myRectangleF)

    ' Draw the rounded rectangle in red.
    Dim redPen As New Pen(Color.Red,
 4)
    e.Graphics.DrawRectangle(redPen, roundedRectangle)

    ' Call the Truncate method.
    Dim truncatedRectangle As Rectangle = _
        Rectangle.Truncate(myRectangleF)

    ' Draw the truncated rectangle in white.
    Dim whitePen As New
 Pen(Color.White, 4)
    e.Graphics.DrawRectangle(whitePen, truncatedRectangle)

    ' Dispose of the custom pens.
    redPen.Dispose()
    whitePen.Dispose()
End Sub
private void RoundingAndTruncatingRectangles(PaintEventArgs
 e)
{

    // Construct a new RectangleF.
    RectangleF myRectangleF = 
        new RectangleF(30.6F, 30.7F, 40.8F, 100.9F);

    // Call the Round method.
    Rectangle roundedRectangle = Rectangle.Round(myRectangleF);

    // Draw the rounded rectangle in red.
    Pen redPen = new Pen(Color.Red, 4);
    e.Graphics.DrawRectangle(redPen, roundedRectangle);

    // Call the Truncate method.
    Rectangle truncatedRectangle = Rectangle.Truncate(myRectangleF);

    // Draw the truncated rectangle in white.
    Pen whitePen = new Pen(Color.White, 4);
    e.Graphics.DrawRectangle(whitePen, truncatedRectangle);

    // Dispose of the custom pens.
    redPen.Dispose();
    whitePen.Dispose();
}
private:
   void RoundingAndTruncatingRectangles( PaintEventArgs^ e )
   {
      // Construct a new RectangleF.
      RectangleF myRectangleF = RectangleF(30.6F,30.7F,40.8F,100.9F);

      // Call the Round method.
      Rectangle roundedRectangle = Rectangle::Round( myRectangleF );

      // Draw the rounded rectangle in red.
      Pen^ redPen = gcnew Pen( Color::Red,4.0f );
      e->Graphics->DrawRectangle( redPen, roundedRectangle );

      // Call the Truncate method.
      Rectangle truncatedRectangle = Rectangle::Truncate( myRectangleF );

      // Draw the truncated rectangle in white.
      Pen^ whitePen = gcnew Pen( Color::White,4.0f );
      e->Graphics->DrawRectangle( whitePen, truncatedRectangle );

      // Dispose of the custom pens.
      delete redPen;
      delete whitePen;
   }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

RectangleF コンストラクタ (PointF, SizeF)

指定した位置とサイズで、RectangleF クラスの新しいインスタンスを初期化します。

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Sub New ( _
    location As PointF, _
    size As SizeF _
)
Dim location As PointF
Dim size As SizeF

Dim instance As New RectangleF(location,
 size)
public RectangleF (
    PointF location,
    SizeF size
)
public:
RectangleF (
    PointF location, 
    SizeF size
)
public RectangleF (
    PointF location, 
    SizeF size
)
public function RectangleF (
    location : PointF, 
    size : SizeF
)

パラメータ

location

四角形領域の左上隅を表す PointF。

size

四角形領域の幅と高さを表す SizeF。

使用例使用例

op_Implicit メンバ、RectangleF メンバ、および op_Equality メンバの使用方法を示すコード例を次に示します。この例は、Windows フォームでの使用を意図してデザインされています。このコードをフォームに貼り付け、フォームの Paint イベントを処理するときに PaintEventArgs の e を渡して ConvertRectangleToRectangleF メソッドを呼び出します。

Private Sub ConvertRectangleToRectangleF( _
    ByVal e As PaintEventArgs)

    ' Create a rectangle.
    Dim rectangle1 As New
 Rectangle(30, 40, 50, 100)

    ' Convert it to a RectangleF.
    Dim convertedRectangle As RectangleF =
 _
        RectangleF.op_Implicit(rectangle1)

    ' Create a new RectangleF.
    Dim rectangle2 As New
 RectangleF(New PointF(30.0F, 40.0F), _
        New SizeF(50.0F, 100.0F))

    ' Create a custom, partially transparent brush.
    Dim redBrush As New
 SolidBrush(Color.FromArgb(40, Color.Red))

    ' Compare the converted rectangle with the new one.  If they 
    ' are equal, draw and fill the rectangles on the form.
    If (RectangleF.op_Equality(convertedRectangle, rectangle2))
 Then
        e.Graphics.FillRectangle(redBrush, rectangle2)
    End If

    ' Dispose of the custom brush.
    redBrush.Dispose()
End Sub
private void ConvertRectangleToRectangleF(PaintEventArgs
 e)
{

    // Create a rectangle.
    Rectangle rectangle1 = new Rectangle(30, 40, 50, 100);

    // Convert it to a RectangleF.
    RectangleF convertedRectangle = rectangle1;

    // Create a new RectangleF.
    RectangleF rectangle2 = new RectangleF(new
 PointF(30.0F, 40.0F),
        new SizeF(50.0F, 100.0F));

    // Create a custom, partially transparent brush.
    SolidBrush redBrush = new SolidBrush(Color.FromArgb(40, Color.Red));

    // Compare the converted rectangle with the new one.  If they 
    // are equal draw and fill the rectangles on the form.
    if (convertedRectangle == rectangle2)
    {
        e.Graphics.FillRectangle(redBrush, rectangle2);
    }

    // Dispose of the custom brush.
    redBrush.Dispose();
}

private:
   void ConvertRectangleToRectangleF( PaintEventArgs^ e )
   {
      // Create a rectangle.
      Rectangle rectangle1 = Rectangle(30,40,50,100);

      // Convert it to a RectangleF.
      RectangleF convertedRectangle = rectangle1;

      // Create a new RectangleF.
      RectangleF rectangle2 = RectangleF(PointF(30.0F,40.0F),SizeF(50.0F,100.0F));

      // Create a custom, partially transparent brush.
      SolidBrush^ redBrush = gcnew SolidBrush( Color::FromArgb( 40, Color::Red )
 );

      // Compare the converted rectangle with the new one.  If they
 
      // are equal draw and fill the rectangles on the form.
      if ( convertedRectangle == rectangle2 )
      {
         e->Graphics->FillRectangle( redBrush, rectangle2 );
      }

      // Dispose of the custom brush.
      delete redBrush;
   }
};
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

RectangleF コンストラクタ


RectangleF フィールド


RectangleF プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Y この RectangleF 構造体の左上隅の y 座標を取得または設定します。
参照参照

関連項目

RectangleF 構造体
System.Drawing 名前空間

RectangleF メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Contains オーバーロードされます。 指定した点が RectangleF 構造体に含まれているかどうかを判断します。
パブリック メソッド Equals オーバーロードされます。 オーバーライドされます。 2 つの RectangleF オブジェクトが等しいかどうかを判断します。
パブリック メソッド FromLTRB 左上隅および右下隅が指定の位置に設定された RectangleF 構造体を作成します。
パブリック メソッド GetHashCode オーバーライドされます。 この RectangleF 構造体のハッシュ コードを取得します。ハッシュ コードの使い方の詳細については、Object.GetHashCodeのトピックを参照してください。
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド Inflate オーバーロードされます。 この RectangleF を指定の量だけ膨らませます。
パブリック メソッド Intersect オーバーロードされます。 2 つの四角形の交差部分を表す RectangleF 構造体を確認します。
パブリック メソッド IntersectsWith この四角形が rect と交差するかどうかを判断します。
パブリック メソッド Offset オーバーロードされます。 四角形の位置を指定した量によって調節します。
パブリック メソッド op_Equality 2 つの RectangleF 構造体の位置およびサイズが同じかどうかをテストします。
パブリック メソッド op_Implicit 指定した Rectangle 構造体を RectangleF 構造体に変換します。
パブリック メソッド op_Inequality 2 つの RectangleF 構造体の位置またはサイズが異なるかどうかをテストします。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString オーバーライドされます。 この RectangleF の Location および Size をユーザーが判読できる文字列に変換します。
パブリック メソッド Union 和集合を形成する 2 つの四角形の両方を含めることができる最小の 3 番目の四角形を作成します。
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

RectangleF 構造体
System.Drawing 名前空間

RectangleF メンバ

四角形の位置とサイズを表す 4 つの浮動小数点数を格納します。より高度な領域関数を使用する場合は Region オブジェクトを使用します。

RectangleF データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
パブリック フィールドパブリック フィールド
  名前 説明
パブリック フィールド Empty メンバを初期化しない状態で RectangleF クラスのインスタンスを表します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Y この RectangleF 構造体の左上隅の y 座標を取得または設定します。
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Contains オーバーロードされます。 指定した点が RectangleF 構造体に含まれているかどうかを判断します。
パブリック メソッド Equals オーバーロードされます。 オーバーライドされます。 2 つの RectangleF オブジェクトが等しいかどうかを判断します。
パブリック メソッド FromLTRB 左上隅および右下隅が指定の位置に設定された RectangleF 構造体を作成します。
パブリック メソッド GetHashCode オーバーライドされます。 この RectangleF 構造体のハッシュ コードを取得します。ハッシュ コードの使い方の詳細については、Object.GetHashCodeのトピックを参照してください。
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド Inflate オーバーロードされます。 この RectangleF を指定の量だけ膨らませます。
パブリック メソッド Intersect オーバーロードされます。 2 つの四角形の交差部分を表す RectangleF 構造体を確認します。
パブリック メソッド IntersectsWith この四角形が rect と交差するかどうかを判断します。
パブリック メソッド Offset オーバーロードされます。 四角形の位置を指定した量によって調節します。
パブリック メソッド op_Equality 2 つの RectangleF 構造体の位置およびサイズが同じかどうかをテストします。
パブリック メソッド op_Implicit 指定した Rectangle 構造体を RectangleF 構造体に変換します。
パブリック メソッド op_Inequality 2 つの RectangleF 構造体の位置またはサイズが異なるかどうかをテストします。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString オーバーライドされます。 この RectangleF の Location および Size をユーザーが判読できる文字列に変換します。
パブリック メソッド Union 和集合を形成する 2 つの四角形の両方を含めることができる最小の 3 番目の四角形を作成します。
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

RectangleF 構造体
System.Drawing 名前空間

RectangleF 構造体

四角形の位置とサイズを表す 4 つの浮動小数点数を格納します。より高度な領域関数を使用する場合は Region オブジェクトを使用します。

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

<SerializableAttribute> _
Public Structure RectangleF
[SerializableAttribute] 
public struct RectangleF
[SerializableAttribute] 
public value class RectangleF
/** @attribute SerializableAttribute() */ 
public final class RectangleF extends ValueType
JScript では、構造体を使用できますが、新規に宣言することはできません。
解説解説

四角形は幅、高さ、および左上隅で定義します。

スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「RectangleF」の関連用語

RectangleFのお隣キーワード

   

英語⇒日本語
日本語⇒英語
   



RectangleFのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS