draw/DrawText

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Argument had undocumented default value)
Line 15: Line 15:
 
|name=font
 
|name=font
 
|desc=Name of font to draw the text in. See {{LibraryFunction|surface|CreateFont}} to create your own, or [[Default Fonts]] for a list of default fonts.
 
|desc=Name of font to draw the text in. See {{LibraryFunction|surface|CreateFont}} to create your own, or [[Default Fonts]] for a list of default fonts.
 +
|default="DermaDefault"
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 20: Line 21:
 
|name=x
 
|name=x
 
|desc=The X Coordinate.
 
|desc=The X Coordinate.
 +
|default=0
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 25: Line 27:
 
|name=y
 
|name=y
 
|desc=The Y Coordinate.
 
|desc=The Y Coordinate.
 +
|default=0
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 36: Line 39:
 
|name=xAlign
 
|name=xAlign
 
|desc=Where to align the text horizontally. Uses the {{Enum|TEXT_ALIGN}}.
 
|desc=Where to align the text horizontally. Uses the {{Enum|TEXT_ALIGN}}.
 +
|default=TEXT_ALIGN_LEFT
 
}}
 
}}
 
{{Example
 
{{Example

Revision as of 08:00, 6 July 2016

 draw.DrawText( )

Contents

Description

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

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