![]() |
The API is no longer being updated here until further notice. |
Applies a rotation to the texture.
TextureBase:SetRotation(radians [, normalizedRotationPoint])
Arguments[]
- radians
- number - Rotation angle in radians. Positive values rotate the texture counter-clockwise.
- normalizedRotationPoint
- vector2?🔗
= {x=0.5, y=0.5}
Details[]
- The coordinates are in the image coordinate space: (0,0) is the top left corner of the image, (1,1) is the bottom right corner.
- This function doesn't quite rotate around the (cx, cy) point: for instance, asking for a zero-radian rotation around (-1, 0) makes the image vanish. The behavior is equivalent to performing the following sequence of affine transformations:
- Translate the image by (-cx, -cy)
- Scale the image by
2^-0.5 - Rotate the image by
radiansaround the origin. - Translate the image by (0.5, 0.5)
- The scaling applied by this function ensures that a square image rotated by 45 degrees around its center fits within the Texture widget's bounding box. If you're rotating circular textures, you may wish to increase the texture widget's dimensions by a factor of
2^0.5to keep the original image size.
Example[]
local tex = UIParent:CreateTexture()
tex:SetPoint("CENTER")
tex:SetTexture("interface/icons/inv_mushroom_11")
tex:SetRotation(math.pi/2)
-
counter-clockwise by 90 degrees (π/2) -
clockwise by 45 degrees
(-π/4)
