<div class="meta" robots="noindex">

</div>

Class

# Realbasic.Rect

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `Rect</api/graphics/rect>` as a replacement.

</div>

## Description

A way to represent an axis-aligned rectangular area. Rect can be used for window size/position, control size/position and drawing of controls.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                                | Type                                               | Read-Only | Shared |
|-----------------------------------------------------|----------------------------------------------------|-----------|--------|
| `Bottom<realbasic.rect.bottom>`                     | `Integer</api/data_types/integer>`                 |           |        |
| `Center<realbasic.rect.center>`                     | `Realbasic.Point</api/deprecated/realbasic.point>` |           |        |
| `Height<realbasic.rect.height>`                     | `Integer</api/data_types/integer>`                 |           |        |
| `HorizontalCenter<realbasic.rect.horizontalcenter>` | `Integer</api/data_types/integer>`                 |           |        |
| `Left<realbasic.rect.left>`                         | `Integer</api/data_types/integer>`                 |           |        |
| `Origin<realbasic.rect.origin>`                     | `Realbasic.point</api/deprecated/realbasic.point>` |           |        |
| `Right<realbasic.rect.right>`                       | `Integer</api/data_types/integer>`                 |           |        |
| `Size<realbasic.rect.size>`                         | `Realbasic.Size</api/deprecated/realbasic.size>`   |           |        |
| `Top<realbasic.rect.top>`                           | `Integer</api/data_types/integer>`                 |           |        |
| `VerticalCenter<realbasic.rect.verticalcenter>`     | `Integer</api/data_types/integer>`                 |           |        |
| `Width<realbasic.rect.width>`                       | `Integer</api/data_types/integer>`                 |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                              | Parameters                                                                                                                                                                  | Returns                            | Shared |
|---------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|--------|
| `Clone<realbasic.rect.clone>`                     |                                                                                                                                                                             | Realbasic.Rect                     |        |
| `Constructor<realbasic.rect.constructor0>`        | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`, Width As `Integer</api/data_types/integer>`, Height As `Integer</api/data_types/integer>` |                                    |        |
| `Intersection<realbasic.rect.intersection>`       | Other As Realbasic.Rect                                                                                                                                                     | Realbasic.Rect                     |        |
| `Intersects<realbasic.rect.intersects>`           | Other As Realbasic.Rect                                                                                                                                                     | `Boolean</api/data_types/boolean>` |        |
| `LocalPoint<realbasic.rect.localpoint>`           | P As `Point</api/graphics/point>`                                                                                                                                           | `Point</api/graphics/point>`       |        |
| `LocalRect<realbasic.rect.localrect>`             | P As Realbasic.Rect                                                                                                                                                         | Realbasic.Rect                     |        |
| `Offset<realbasic.rect.offset>`                   | DeltaX As `Integer</api/data_types/integer>`, DeltaY As `Integer</api/data_types/integer>`                                                                                  |                                    |        |
| `SplitHorizontal<realbasic.rect.splithorizontal>` | X As `Integer</api/data_types/integer>`                                                                                                                                     | Realbasic.Rect                     |        |
| `SplitVertical<realbasic.rect.splitvertical>`     | Y As `Integer</api/data_types/integer>`                                                                                                                                     | Realbasic.Rect                     |        |
| `Union<realbasic.rect.union>`                     | Other As Realbasic.Rect                                                                                                                                                     | Realbasic.Rect                     |        |

## Property descriptions

<div id="realbasic.rect.bottom">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Bottom

**Bottom** As `Integer</api/data_types/integer>`

The bottom edge of the rect on the Y axis. Changing this value will resize the rect.

This example enlarges the rect by 50 pixels:

``` xojo
myRect.Bottom = myRect.Bottom + 50
```

<div id="realbasic.rect.center">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Center

**Center** As `Realbasic.point</api/deprecated/realbasic.point>`

The center of the rect. Changing this value will move the rect.

This sample works in a Canvas.Paint event. It computes the center of a rect that represents the union of two rects.

``` xojo
Dim i, j As Integer
' To demonstrate the Union feature, draw a Cyan rectangle
' around both the draggable rects.
Dim u As Realbasic.Rect = rectone.Union(recttwo)
buffer.Graphics.ForeColor = CyanColor
buffer.Graphics.DrawRect(u.Left, u.Top, u.Width, u.Height)
theSize = u.Size
Dim theCenter As Realbasic.Point = u.Center
i = theCenter.X
j = theCenter.Y
```

<div id="realbasic.rect.height">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Height

**Height** As `Integer</api/data_types/integer>`

The height of the Rect.

This example increases the height of rectone by 50 pixels.

``` xojo
myRect.Height = myRect.Height + 50
```

<div id="realbasic.rect.horizontalcenter">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.HorizontalCenter

**HorizontalCenter** As `Integer</api/data_types/integer>`

The center of the Rect on the X axis. Changing this value will move the Rect.

This example is in the MouseDrag event. It gets the horizontal and vertical centers of the rect being dragged.

``` xojo
Dim i, j As Double
i = DraggingRect.HorizontalCenter
j = DraggingRect.VerticalCenter
```

<div id="realbasic.rect.left">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Left

**Left** As `Integer</api/data_types/integer>`

The left edge of the Rect on the X axis.

This example moves the rect to the left by 50 pixels, keeping its height and width intact.

``` xojo
myRect.Left = myRect.Left + 50
```

<div id="realbasic.rect.origin">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Origin

**Origin** As `Realbasic.point</api/deprecated/realbasic.point>`

The upper left coordinate of the rect.

This example is in the MouseDrag event. The position of the Rect being dragged is updated via by reseting the value of the Origin property.

``` xojo
' Update our mouse position.
mouseposition = New Realbasic.Point(x, y)

' If we're actually dragging something, move the rect.
' We update the rect's origin with a CLONE of the mouse position,
' because MousePosition is an instance of the REALbasic.Point class.
' Without the clone, when we call the offset function, we'll also update
' the MousePosition property, since both DraggingRect.Origin and MousePosition
' would point to the same variable.

' The offset function shifts the rect. Positive for right/down,
' negative for left/up.

If draggingrect <> Nil Then
  draggingrect.Origin = mouseposition.Clone
  draggingrect.Offset(mouseoffset.x, mouseoffset.y)
End If

' refresh, without erasing the background
Me.Invalidate(False)
```

<div id="realbasic.rect.right">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Right

**Right** As `Integer</api/data_types/integer>`

The right edge of the rect on the X axis. Changing this value will resize the rect.

This example moves the rect to the right by 50 pixels, keeping its height and width intact:

``` xojo
myRect.Left = myRect.Right + 50
```

<div id="realbasic.rect.size">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Size

**Size** As `Realbasic.Size</api/deprecated/realbasic.size>`

The dimensions of the Rect.

This example is in the Paint event of a project. It computes the Size of the union of two rects.

``` xojo
' To demonstrate the Union feature, we'll draw a Cyan rectangle
' around both the draggable rects.
Dim theSize As New REALbasic.Size
Dim u As Realbasic.Rect = rectone.Union(recttwo)
buffer.Graphics.ForeColor = CyanColor
buffer.Graphics.DrawRect(u.Left, u.Top, u.Width, u.Height)
theSize = u.Size
```

<div id="realbasic.rect.top">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Top

**Top** As `Integer</api/data_types/integer>`

The top edge of the rect on the Y axis.

This example is in the Paint event. It computes the top of a rect that represents the union of two rects.

``` xojo
Dim i, j As Integer
' To demonstrate the Union feature, we'll draw a Cyan rectangle
' around both the draggable rects.
Dim u As Realbasic.Rect = rectone.Union(recttwo)
buffer.Graphics.ForeColor = CyanColor
buffer.Graphics.DrawRect(u.Left, u.Top, u.Width, u.Height)
theSize = u.Size
Dim theTop As Realbasic.Point = u.Top
i = theTop.x
j = theTop.y
```

<div id="realbasic.rect.verticalcenter">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.VerticalCenter

**VerticalCenter** As `Integer</api/data_types/integer>`

The center of the rect on the Y axis. Changing this value will move the Rect.

This example is in the MouseDrag event. It gets the horizontal and vertical centers of the rect being dragged.

``` xojo
Dim i, j As Double
i = DraggingRect.HorizontalCenter
j = DraggingRect.VerticalCenter
```

<div id="realbasic.rect.width">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Width

**Width** As `Integer</api/data_types/integer>`

The width of the rect.

This example increases the width by 50 pixels:

``` xojo
myRect.Width = myWidth.Width + 50
```

## Method descriptions

<div id="realbasic.rect.clone">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Clone

**Clone** As Realbasic.Rect

Creates a duplicate of the Rect.

<div id="realbasic.rect.constructor0">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Constructor

**Constructor**(X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`, Width As `Integer</api/data_types/integer>`, Height As `Integer</api/data_types/integer>`)

<div class="note">

<div class="title">

Note

</div>

`Constructors</api/language/constructor>` are special methods called when you create an object with the `New</api/language/new>` keyword and pass in the parameters above.

</div>

Creates a <span class="title-ref">Realbasic.Rect</span> object at X,Y and the passed width and height.

This example is from the Rects example that is covered in the Notes section of the <span class="title-ref">Realbasic.Rect</span> class. The Open event of the main window contains constructors that appear in the top-left and bottom-right corners of the main window.

``` xojo
' Start by defining our two rectangles. Both will be 100 x 75.
' RectOne will be in the upper left. RectTwo will be in the lower right.
rectOne = New Realbasic.Rect(0, 0, 100, 75)
rectTwo = New Realbasic.Rect(Self.Width - 100, Self.Height - 75, 100, 75)

' Fill our point classes to avoid NilObjectException errors.
mousePosition = New Realbasic.Point(-1, -1)
mouseOffset = New Realbasic.Point(0, 0)
```

<div id="realbasic.rect.intersection">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Intersection

**Intersection**(Other As Realbasic.Rect) As Realbasic.Rect

Returns a new Rect representing the area the two Rects overlap.

<div id="realbasic.rect.intersects">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Intersects

**Intersects**(Other As Realbasic.Rect) As `Boolean</api/data_types/boolean>`

Returns `True</api/language/true>` if the Rect overlaps the passed rect.

<div id="realbasic.rect.localpoint">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.LocalPoint

**LocalPoint**(P As `Point</api/graphics/point>`) As `Point</api/graphics/point>`

Returns a new Point whose coordinates are local to the calling Rect.

<div id="realbasic.rect.localrect">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.LocalRect

**LocalRect**(P As Realbasic.Rect) As Realbasic.Rect

Returns a new Rect whose coordinates are local to the calling Rect.

<div id="realbasic.rect.offset">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Offset

**Offset**(DeltaX As `Integer</api/data_types/integer>`, DeltaY As `Integer</api/data_types/integer>`)

Moves the point the passed number of pixels. Positive numbers move the point down or to the right, negative move it up or to the left.

<div id="realbasic.rect.splithorizontal">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.SplitHorizontal

**SplitHorizontal**(X As `Integer</api/data_types/integer>`) As Realbasic.Rect

Divides the rect into two rects at the given point on the X axis.

For example, imagine a rect that is 200 pixels wide by 100 pixels tall. With a call to SplitHorizontal(50), the rect will become 50 pixels wide, and a new rect will be returned that is 150x100, positioned exactly to the right of the original rect.

This example is taken from the Paint event of a `Canvas</api/deprecated/canvas>`. It takes a rect and splits it horizontally at the midpoint of the width.

``` xojo
Dim uright As Realbasic.Rect = u.SplitHorizontal(theSize.Width / 2)
```

<div id="realbasic.rect.splitvertical">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.SplitVertical

**SplitVertical**(Y As `Integer</api/data_types/integer>`) As Realbasic.Rect

Divides the rect into two rects at the given point on the Y axis.

For example, imagine a Rect that is 200 pixels wide by 100 pixels tall. A call to SplitVertical (50) on this rect, the rect will become 50 pixels wide, and a new rect will be returned that is 150x100, positioned exactly to the top of the original rect.

This example is taken from the Paint event of a `Canvas</api/deprecated/canvas>`. It takes a rect and splits it horizontally at the midpoint of the height.

``` xojo
Dim utop As Realbasic.Rect = u.SplitVertical(theSize.Height / 2)
```

<div id="realbasic.rect.union">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Rect.Union

**Union**(Other As Realbasic.Rect) As Realbasic.Rect

Creates a new Rect containing both rects.

## Notes

You must prefix the classic Rect with "Realbasic" like this:

``` xojo
Realbasic.Rect
```

.

## Sample code

``` xojo
Dim myRect As New Realbasic.Rect(10, 10, 100, 50)
```

## Compatibility

All project types on all supported operating systems.

## See also

Object parent class; `Canvas</api/deprecated/canvas>` control; `Window</api/deprecated/window>`, `DesktopContainer</api/user_interface/desktop/desktopcontainer>`, `Point</api/graphics/point>`, `Size</api/graphics/size>` classes.
