surface.DrawTexturedRect

From GMod Wiki

Jump to: navigation, search
Function
Syntax surface.DrawTexturedRect( Number x, Number y, Number width, Number height )
Where is this used?
Description:
Draws a textured rect, assuming that the required values have been set. The texture is set by Surface.SetTexture.
Returns: nil
Part of Library: surface
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Surface.DrawTexturedRect]Surface.DrawTexturedRect [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionDraw a box in the middle of the screen of size 128 by 128.
Used onNewerClient.png
Code
local ExampleTexture = surface.GetTextureID( "Example" );
 
function PaintBoxToScreen()
	local BoxSize = 128;
	local Offset = BoxSize / 2;
 
	surface.SetDrawColor( 255, 255, 255, 255 );
	surface.SetTexture( ExampleTexture );
	surface.DrawTexturedRect( ( ScrW() / 2 ) - Offset, ( ScrH() / 2 ) - Offset, BoxSize, BoxSize );
end
hook.Add( "HUDPaint", "PaintBoxToScreen", PaintBoxToScreen );
 
OutputN/A


Additional Notes

Note that the origin of the Rect is the left upper corner (x,y), not the center. Also note that all these values are PIXELS, not a scale. (Unlike Gmod9 lua)

If you are unable to modify the color of this texture with Surface.SetDrawColor, please see this post.

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox