draw/DrawText

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Added See also: MarkupObject)
Line 3: Line 3:
  
 
{{RenderingContext|Function|2D}}
 
{{RenderingContext|Function|2D}}
 +
 +
See also {{Type|MarkupObject}} for limited width and markup support.
 
|Realm=Client and Menu
 
|Realm=Client and Menu
 
|IsClass=No
 
|IsClass=No
|Name=DrawText
 
|Parent=draw
 
 
}}
 
}}
 
{{Arg
 
{{Arg

Revision as of 22:45, 5 May 2017

 draw.DrawText( )

Contents

Description

Simple draw text at position, but this will expand newlines and tabs.

NOTE

This is a rendering function that requires a 2D rendering context.
This means that it will only work in hooks with a 2D rendering context.

See also MarkupObject for limited width and markup support.

Arguments

string text

Text to be drawn.

Arguments

string font="DermaDefault"

Name of font to draw the text in. See surface.CreateFont to create your own, or Default Fonts for a list of default fonts.

Arguments

number x=0

The X Coordinate.

Arguments

number y=0

The Y Coordinate.

Arguments

table color=Color( 255, 255, 255, 255 )

Color to draw the text in. Uses the Color structure.

Arguments

number xAlign=TEXT_ALIGN_LEFT

Where to align the text horizontally. Uses the TEXT_ALIGN_ Enums.

Examples

Example

Makes a message saying "Hello there!" pop up in the center of your screen.

hook.Add("HUDPaint", "HelloThere", function() 
	draw.DrawText("Hello there!", "TargetID", ScrW() * 0.5, ScrH() * 0.25, Color(255,255,255,255), TEXT_ALIGN_CENTER)
end)

Output:

Hello there!
Personal tools
Navigation