RectangleF.Union メソッドとは? わかりやすく解説

RectangleF.Union メソッド

和集合形成する 2 つ四角形両方含めることができる最小3 番目の四角形作成します

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

Public Shared Function Union
 ( _
    a As RectangleF, _
    b As RectangleF _
) As RectangleF
Dim a As RectangleF
Dim b As RectangleF
Dim returnValue As RectangleF

returnValue = RectangleF.Union(a, b)
public static RectangleF Union (
    RectangleF a,
    RectangleF b
)
public:
static RectangleF Union (
    RectangleF a, 
    RectangleF b
)
public static RectangleF Union (
    RectangleF a, 
    RectangleF b
)
public static function Union
 (
    a : RectangleF, 
    b : RectangleF
) : RectangleF

パラメータ

a

結合する四角形

b

結合する四角形

戻り値
和集合形成する 2 つ四角形両方含まれる 3 番目の RectangleF 構造体

使用例使用例

この例は、Windows フォームでの使用意図してデザインされており、OnPaint のイベント オブジェクトである PaintEventArgs e が必要です。このコードでは、2 つRectangleF作成し画面に黒および赤で描画ます。描画するには Rectangle変換する必要があります。そのため、このコードでは、Union メソッド使用して 3 番目の RectangleF作成し、これを Rectangle変換し画面に青で描画ます。3 番目の (青の) 四角形残り2 つ四角形両方含めることができる最小四角形となります

Public Sub RectangleFUnionExample(ByVal
 e As PaintEventArgs)

    ' Create two rectangles and draw them to the screen.
    Dim firstRectangleF As New
 RectangleF(0, 0, 75, 50)
    Dim secondRectangleF As New
 RectangleF(100, 100, 20, 20)

    ' Convert the RectangleF structures to Rectangle structures and

    ' draw them to the screen.
    Dim firstRect As Rectangle = Rectangle.Truncate(firstRectangleF)
    Dim secondRect As Rectangle = Rectangle.Truncate(secondRectangleF)
    e.Graphics.DrawRectangle(Pens.Black, firstRect)
    e.Graphics.DrawRectangle(Pens.Red, secondRect)

    ' Get the union rectangle.
    Dim unionRectangleF As RectangleF = _
    RectangleF.Union(firstRectangleF, secondRectangleF)

    ' Draw the unionRectangleF to the screen.
    Dim unionRect As Rectangle = Rectangle.Truncate(unionRectangleF)
    e.Graphics.DrawRectangle(Pens.Blue, unionRect)
End Sub
public void RectangleFUnionExample(PaintEventArgs
 e)
{
             
    // Create two rectangles and draw them to the screen.
    RectangleF firstRectangleF = new RectangleF(0, 0, 75, 50);
    RectangleF secondRectangleF = new RectangleF(100, 100, 20,
 20);
             
    // Convert the RectangleF structures to Rectangle structures and
 draw them to the
             
    // screen.
    Rectangle firstRect = Rectangle.Truncate(firstRectangleF);
    Rectangle secondRect = Rectangle.Truncate(secondRectangleF);
    e.Graphics.DrawRectangle(Pens.Black, firstRect);
    e.Graphics.DrawRectangle(Pens.Red, secondRect);
             
    // Get the union rectangle.
    RectangleF unionRectangleF = RectangleF.Union(firstRectangleF,
        secondRectangleF);
             
    // Draw the unionRectangleF to the screen.
    Rectangle unionRect = Rectangle.Truncate(unionRectangleF);
    e.Graphics.DrawRectangle(Pens.Blue, unionRect);
}
public:
   void RectangleFUnionExample( PaintEventArgs^ e )
   {
      // Create two rectangles and draw them to the screen.
      RectangleF firstRectangleF = RectangleF(0,0,75,50);
      RectangleF secondRectangleF = RectangleF(100,100,20,20);

      // Convert the RectangleF structures to Rectangle structures and
 draw them to the
      // screen.
      Rectangle firstRect = Rectangle::Truncate( firstRectangleF );
      Rectangle secondRect = Rectangle::Truncate( secondRectangleF );
      e->Graphics->DrawRectangle( Pens::Black, firstRect );
      e->Graphics->DrawRectangle( Pens::Red, secondRect );

      // Get the union rectangle.
      RectangleF unionRectangleF = RectangleF::Union( firstRectangleF, secondRectangleF
 );

      // Draw the unionRectangleF to the screen.
      Rectangle unionRect = Rectangle::Truncate( unionRectangleF );
      e->Graphics->DrawRectangle( Pens::Blue, unionRect );
   }
public void RectangleFUnionExample(PaintEventArgs
 e)
{
    // Create two rectangles and draw them to the screen.
    RectangleF firstRectangleF = new RectangleF(0, 0, 75, 50);
    RectangleF secondRectangleF = new RectangleF(100, 100, 20,
 20);

    // Convert the RectangleF structures to Rectangle structures and
 
    // draw them to the screen.
    Rectangle firstRect = Rectangle.Truncate(firstRectangleF);
    Rectangle secondRect = Rectangle.Truncate(secondRectangleF);

    e.get_Graphics().DrawRectangle(Pens.get_Black(), firstRect);
    e.get_Graphics().DrawRectangle(Pens.get_Red(), secondRect);

    // Get the union rectangle.
    RectangleF unionRectangleF = RectangleF.Union(firstRectangleF,
        secondRectangleF);

    // Draw the unionRectangleF to the screen.
    Rectangle unionRect = Rectangle.Truncate(unionRectangleF);

    e.get_Graphics().DrawRectangle(Pens.get_Blue(), unionRect);
} //RectangleFUnionExample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

RectangleF.Union メソッドのお隣キーワード
検索ランキング

   

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



RectangleF.Union メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS