|This function becomes protected when affecting frames or regions that are protected.
Regions, abstract rectangular areas to position something on the screen, provide two functions for quickly returning position and size from the lower-left screen corner:
- GetRect() uses the region's own coordinate system (affected by its scale)
- GetScaledRect() uses a standard coordinate system (scale = 1)
left, bottom, width, height = GetRect() left, bottom, width, height = GetScaledRect() -- multiplied by GetEffectiveScale()
The following returns only apply if the region has a defined position and size (nil otherwise).
- Number - Distance between the region and left edge of the screen (negative values are beyond the screen edge)
- Number - Distance between the region and bottom edge of the screen (negative values are beyond the screen edge)
- Number - Width between the region's left and right edges
- Number - Height between the region's bototm and top edges
The example below shows the difference between each function using a tiny 1x1 box a short distance from the lower-left corner of the screen.
local myFrame = CreateFrame("Frame") -- a frame is a type of region myFrame:SetScale(2) -- the frame's coordinate system is 2x larger myFrame:SetPoint("BOTTOMLEFT", 100, 100) myFrame:SetSize(1,1) print(myFrame:GetRect()) -- 100, 100, 1, 1 print(myFrame:GetScaledRect()) -- 200, 200, 2, 2
- GetScaledRect() is reproducable by multiplying the four returns of GetRect() with Region:GetEffectiveScale()
- Patch 8.2.0 / API (2019-06-25): Neither function permitted on restricted frames.
- Patch 8.1.0 / API (2018-12-11): GetScaledRect() appears in FrameXML.
- Patch 2.0.1 / API (2006-12-05): GetRect() added.
- Region:GetLeft() - Like the first return value of GetRect()
- Region:GetBottom() - Like the second return value of GetRect()
- Region:GetWidth() - Like the third return value of GetRect()
- Region:GetHeight() - Like the fourth return value of GetRect()
- Region:GetEffectiveScale() - The product of a region's scale with that of all its parents
- GetUnscaledFrameRect(frame, scale) - FrameXML utility to use any arbitrary coordinate system defined by scale