The xmiddle of and ymiddle of functions can be applied to any object. The values returned are the X and Y coordinates corresponding to the middle of the specified object's contents, and are based upon the values of the top of, bottom of, left of, and right of functions. The values returned are expressed in the coordinates of the object. If the object has no contents, ESL returns values of zero for these functions.
Caution: Avoid using the xmiddle of or ymiddle of functions for a scaled graphical region that contains text, or in a program whose defined screen size is different from the display resolution. Because you cannot scale text, these functions might not work when used at compile time. You can use these functions with text at runtime.
For a graphical object, the values are calculated as follows:
xmiddle (left + right)
_______________
2
ymiddle (top + bottom)
________________
2
For example, if function values are:
top = 100
bottom = 50
left = 0
right = 100
then:
(0 + 100)
xmiddle = --------- = 50
2
(100 + 50)
xmiddle = ---------- = 75
2
The following example draws a dot at the center of the key Box:
response to MakeDot
add to Box
move to (xmiddle of Box) (ymiddle of Box)
circle radius 1