Realbasic.Rect.Center

From Xojo Documentation

Property (As Realbasic.Point )
aRealbasic.Rect.Center = newRealbasic.PointValue
or
Realbasic.PointValue = aRealbasic.Rect.Center

Supported for all project types and targets.

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

Sample Code

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

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