Links |
---|
![]() |
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()
Returns
The following returns only apply if the region has a defined position and size (nil otherwise).
- left
- Number - Distance between the region and left edge of the screen (negative values are beyond the screen edge)
- bottom
- Number - Distance between the region and bottom edge of the screen (negative values are beyond the screen edge)
- width
- Number - Width between the region's left and right edges
- height
- Number - Height between the region's bototm and top edges
Example
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
Notes
- GetScaledRect() is reproducable by multiplying the four returns of GetRect() with Region:GetEffectiveScale()
Patch changes
Patch 8.2.0 (2019-06-25): Neither function permitted on restricted frames.[1]
Patch 8.1.0 (2018-12-11): GetScaledRect() appears in FrameXML.[2]
Patch 2.0.1 (2006-12-05): GetRect() added.[3]
See also
- 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
References
- ^
Kaivax 2019-06-19. UI Changes in Rise of Azshara.
- ^ 2018-12-07, Util.lua, version 8.1.0.28724, near line 1462, archived at Townlong-Yak
- ^
Slouken 2006-10-06. Re: Expansion Changes - Concise List)6. Archived from the original