Class

# RectShape

<div class="rst-class">

forsearch

</div>

Shape

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

## Description

Draws a two-dimensional rectangle in a vector graphics environment.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                     | Type                             | Read-Only | Shared |
|------------------------------------------|----------------------------------|-----------|--------|
| `BorderColor<rectshape.bordercolor>`     | `Color</api/data_types/color>`   |           |        |
| `BorderOpacity<rectshape.borderopacity>` | `Double</api/data_types/double>` |           |        |
| `BorderWidth<rectshape.borderwidth>`     | `Double</api/data_types/double>` |           |        |
| `FillColor<rectshape.fillcolor>`         | `Color</api/data_types/color>`   |           |        |
| `FillOpacity<rectshape.fillopacity>`     | `Double</api/data_types/double>` |           |        |
| `Height<rectshape.height>`               | `Double</api/data_types/double>` |           |        |
| `Rotation<rectshape.rotation>`           | `Double</api/data_types/double>` |           |        |
| `Scale<rectshape.scale>`                 | `Double</api/data_types/double>` |           |        |
| `Width<rectshape.width>`                 | `Double</api/data_types/double>` |           |        |
| `X<rectshape.x>`                         | `Double</api/data_types/double>` |           |        |
| `Y<rectshape.y>`                         | `Double</api/data_types/double>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                           | Parameters                                                                   | Returns                            | Shared |
|--------------------------------|------------------------------------------------------------------------------|------------------------------------|--------|
| `Contains<rectshape.contains>` | x As `Double</api/data_types/double>`, y As `Double</api/data_types/double>` | `Boolean</api/data_types/boolean>` |        |

## Property descriptions

<div id="rectshape.bordercolor">

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

</div>

<div class="rst-class">

forsearch

</div>

RectShape.BorderColor

**BorderColor** As `Color</api/data_types/color>`

> The color of the object's border.

<div id="rectshape.borderopacity">

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

</div>

<div class="rst-class">

forsearch

</div>

RectShape.BorderOpacity

**BorderOpacity** As `Double</api/data_types/double>`

> Indicates the level of opacity.
>
> Degrees of transparency is currently supported only on macOS and Windows. On other platforms, the border is either visible (100%) or invisible.
>
> The following code adds a border to a \`RectShape\`:
>
> ``` xojo
> Var a As New RectShape
> a.BorderOpacity = 100
> g.DrawObject(a)
> ```

<div id="rectshape.borderwidth">

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

</div>

<div class="rst-class">

forsearch

</div>

RectShape.BorderWidth

**BorderWidth** As `Double</api/data_types/double>`

> The width of the border, in points. The default is 1.
>
> The width a `Double</api/data_types/double>` value with a default of 1.0.

<div id="rectshape.fillcolor">

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

</div>

<div class="rst-class">

forsearch

</div>

RectShape.FillColor

**FillColor** As `Color</api/data_types/color>`

> The color of the interior of the shape.

<div id="rectshape.fillopacity">

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

</div>

<div class="rst-class">

forsearch

</div>

RectShape.FillOpacity

**FillOpacity** As `Double</api/data_types/double>`

> The opacity of the interior, from 0 (completely transparent) to 100 (opaque).
>
> This example sets the Fill to 50% opacity.
>
> ``` xojo
> Var a As New RectShape
> a.BorderOpacity = 100
> a.BorderColor = Color.Black
> a.BorderWidth = 2.75
> a.FillOpacity = 50
> a.FillColor = Color.Red
> g.DrawObject(a)
> ```

<div id="rectshape.height">

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

</div>

<div class="rst-class">

forsearch

</div>

RectShape.Height

**Height** As `Double</api/data_types/double>`

> The height of the rectangle.
>
> This example sets the height and width of the shape to 150 pixels.
>
> ``` xojo
> Var r As New RectShape
> r.Width = 150
> r.Height = 150
> r.BorderOpacity = 100
> r.BorderColor = Color.Black
> r.FillColor = Color.Teal
> r.BorderWidth = 2.5
> r.Rotation = -0.78
> g.DrawObject(r)
> ```

<div id="rectshape.rotation">

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

</div>

<div class="rst-class">

forsearch

</div>

RectShape.Rotation

**Rotation** As `Double</api/data_types/double>`

> Clockwise rotation, in radians, around the X, Y point. Only set the rotation after you have drawn all your objects.
>
> This code rotates the <span class="title-ref">RectShape</span> 0.9 radians.
>
> ``` xojo
> Var a As New RectShape
> a.Height = 150
> a.Width = 150
> a.Rotation = 0.90
> g.DrawObject(a)
> ```

<div id="rectshape.scale">

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

</div>

<div class="rst-class">

forsearch

</div>

RectShape.Scale

**Scale** As `Double</api/data_types/double>`

> The scaling factor relative to the object's original size.
>
> The following code rescales the <span class="title-ref">RectShape</span> by a factor of 1.5.
>
> ``` xojo
> Var a As New RectShape
> a.Scale = 1.5
> g.DrawObject(a)
> ```

<div id="rectshape.width">

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

</div>

<div class="rst-class">

forsearch

</div>

RectShape.Width

**Width** As `Double</api/data_types/double>`

> The width of the rectangle.
>
> This example sets the Width to 150 pixels.
>
> ``` xojo
> Var r As New RectShape
> r.Width = 150
> r.Height = 150
> r.BorderOpacity = 100
> r.BorderColor =Color.Black
> r.FillColor =Color.Teal
> r.BorderWidth = 2.5
> r.Rotation = -0.78
> g.DrawObject(r)
> ```

<div id="rectshape.x">

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

</div>

<div class="rst-class">

forsearch

</div>

RectShape.X

**X** As `Double</api/data_types/double>`

> The horizontal position of the center or main anchor point.
>
> This example sets the horizontal position to 100 pixels from the left of the containing `Canvas</api/user_interface/desktop/desktopcanvas>`.
>
> ``` xojo
> Var a As New RectShape
> a.Height = 150
> a.Width = 150
> a.X = 100
> g.DrawObject(a)
> ```

<div id="rectshape.y">

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

</div>

<div class="rst-class">

forsearch

</div>

RectShape.Y

**Y** As `Double</api/data_types/double>`

> The vertical position (down from top) position of the center or anchor point.
>
> This example moves the position of the <span class="title-ref">RectShape</span> down 100 pixels from the top of the containing `Canvas</api/user_interface/desktop/desktopcanvas>`.
>
> ``` xojo
> Var a As New RectShape
> a.Height = 150
> a.Width = 150
> a.Y = 100
> g.DrawObject(a)
> ```

## Method descriptions

<div id="rectshape.contains">

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

</div>

<div class="rst-class">

forsearch

</div>

RectShape.Contains

**Contains**(x As `Double</api/data_types/double>`, y As `Double</api/data_types/double>`) As `Boolean</api/data_types/boolean>`

> Tests whether the object contains the point *x*, *y*. Returns `True</api/language/true>` if the rectangle contains the point specified by *x*, *y*.
>
> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> If you want to use Contains, make sure to set the *X* and *Y* properties and **do not** pass the these to the `Graphics.DrawObject<graphics.drawobject>` method. `Graphics.DrawObject<graphics.drawobject>` parameters are the offset where the object will be drawn.
>
> </div>
>
> This code tests whether the <span class="title-ref">RectShape</span> contains the passed point:
>
> ``` xojo
> Var r As New RectShape
> r.Width = 75
> r.Height = 75
> r.BorderOpacity = 100
> r.Bordercolor =Color.Black
> r.FillColor =Color.Teal
> r.BorderWidth = 2.5
> r.Rotation = -0.78
> If r.Contains(50, 50) Then
> ' draw something here..
> End If
> g.DrawObject(r)
> ```

## Sample code

The following code in the `Canvas.Paint<desktopcanvas.paint>` event handler draws a diamond shaped rectangle:

``` xojo
Var r As New RectShape
r.Width = 75
r.Height = 75
r.BorderOpacity = 100
r.BorderColor =Color.Black
r.FillColor =Color.Teal
r.BorderWidth = 2.5
r.Rotation = -0.78
g.DrawObject(r)
```

## Compatibility

|                       |                       |
|-----------------------|-----------------------|
| **Project Types**     | Console, Desktop, Web |
| **Operating Systems** | All                   |

<div class="seealso">

`Object2D</api/graphics/object2d>` parent class; `ArcShape</api/graphics/arcshape>`, `CurveShape</api/graphics/curveshape>`, `FigureShape</api/graphics/figureshape>`, `FolderItem</api/files/folderitem>`, `Group2D</api/graphics/group2d>`, `Graphics</api/graphics/graphics>`, `OvalShape</api/graphics/ovalshape>`, `Picture</api/graphics/picture>`, `PixmapShape</api/graphics/pixmapshape>`, `RoundRectShape</api/graphics/roundrectshape>`, `TextShape</api/graphics/textshape>` classes.

</div>
