Rect.Center
From Xojo Documentation
Property (As Point )
aRect.Center = newPointValue
or
PointValue = aRect.Center
New in 2019r2
Supported for all project types and targets.
or
PointValue = aRect.Center
New in 2019r2
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.
Var i, j As Integer
// To demonstrate the Union feature, draw a Cyan rectangle
// around both the draggable rects.
Var u As Rect = rectone.Union(recttwo)
buffer.Graphics.DrawingColor = CyanColor
buffer.Graphics.DrawRectangle(u.Left, u.Top, u.Width, u.Height)
theSize = u.Size
Var theCenter As Point = u.Center
i = theCenter.X
j = theCenter.Y
// To demonstrate the Union feature, draw a Cyan rectangle
// around both the draggable rects.
Var u As Rect = rectone.Union(recttwo)
buffer.Graphics.DrawingColor = CyanColor
buffer.Graphics.DrawRectangle(u.Left, u.Top, u.Width, u.Height)
theSize = u.Size
Var theCenter As Point = u.Center
i = theCenter.X
j = theCenter.Y