draw.DrawText

From Garry's Mod
Jump to: navigation, search
 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