surface/DrawTexturedRectRotated

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Func |Name=DrawTexturedRectRotated |Parent=surface |Description=Draw a textured rotated rectangle with the given position and dimensions and angle on the screen, using th...")
 
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=DrawTexturedRectRotated
 
|Parent=surface
 
 
|Description=Draw a textured rotated rectangle with the given position and dimensions and angle on the screen, using the current active texture.
 
|Description=Draw a textured rotated rectangle with the given position and dimensions and angle on the screen, using the current active texture.
 
|Realm=Client
 
|Realm=Client
 
|IsClass=No
 
|IsClass=No
 +
|Name=DrawTexturedRectRotated
 +
|Parent=surface
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 30: Line 30:
 
|name=rotation
 
|name=rotation
 
|desc=The rotation of the rectangle, in degrees.
 
|desc=The rotation of the rectangle, in degrees.
 +
}}
 +
{{Example
 +
|Description=A function that allows you to override the origin of rotation.
 +
 +
x0 and y0 are relative to the center of the rectangle.
 +
|Code=function surface.DrawTexturedRectRotatedPoint( x, y, w, h, rot, x0, y0 )
 +
 +
local c = math.cos( math.rad( rot ) )
 +
local s = math.sin( math.rad( rot ) )
 +
 +
local newx = y0 * s - x0 * c
 +
local newy = y0 * c + x0 * s
 +
 +
surface.DrawTexturedRectRotated( x + newx, y + newy, w, h, rot )
 +
 +
end
 
}}
 
}}

Revision as of 16:13, 28 April 2015

 surface.DrawTexturedRectRotated( )

Contents

Description

Draw a textured rotated rectangle with the given position and dimensions and angle on the screen, using the current active texture.

Arguments

number x

The X co-ordinate, representing the center of the cube.

Arguments

number y

The Y co-ordinate, representing the center of the cube.

Arguments

number width

The width of the rectangle.

Arguments

number height

The height of the rectangle.

Arguments

number rotation

The rotation of the rectangle, in degrees.

Examples

Example

A function that allows you to override the origin of rotation.

x0 and y0 are relative to the center of the rectangle.

function surface.DrawTexturedRectRotatedPoint( x, y, w, h, rot, x0, y0 )
	
	local c = math.cos( math.rad( rot ) )
	local s = math.sin( math.rad( rot ) )
	
	local newx = y0 * s - x0 * c
	local newy = y0 * c + x0 * s
	
	surface.DrawTexturedRectRotated( x + newx, y + newy, w, h, rot )
	
end


Personal tools
Navigation