DrawTexture2
Description
This function is used to draw a texture, pretty much similar to DrawTexture, but the origin point is centered instead of top-left corner. It also supports image rotation from 0 to 360 degrees.
function DrawTexture2(texture, x, y, width, height, rotation, red, green, blue, alpha) --[[ ... ]] end
Parameters
texture
:userdata
- The returned value from CreateTexture function.x
:number
- X screen coordinate (0 - 1)y
:number
- Y screen coordinate (0 - 1)width
:number
- Texture width (0 - 1)height
:number
- Texture height (0 - 1)rotation
:number
- Rotation in degree (0 - 360)red
:number
- RGBA format (0 - 255)green
:number
- RGBA format (0 - 255)blue
:number
- RGBA format (0 - 255)alpha
:number
- RGBA format (0 - 255)
Starting from DSL 7, the red, green, blue, and alpha arguments are optional. If omitted, DSL will use the default value (255).
Return Values
None.
Example
Drawing image with 90 degrees rotated and adjusted its width to be proportional to the screen's aspect ratio.
local Texture_UserData = CreateTexture('MyProfilePicture.png')
local Texture_AspectRatio = GetTextureDisplayAspectRatio(Texture_UserData)
while true do
DrawTexture2(Texture_UserData, 0.5, 0.5, 0.15 * Texture_AspectRatio, 0.15, 90, 255, 50, 50, 255)
Wait(0)
end
Drawing image without respect to the screen's aspect ratio (real width).
local Texture_UserData = CreateTexture('MyProfilePicture.png')
while true do
DrawTexture2(Texture_UserData, 0.5, 0.5, 0.15, 0.15, 90, 255, 50, 50, 255)
Wait(0)
end