Garry's Mod Wiki

draw.DrawText

draw.DrawText( string text, string font = "DermaDefault", number x = 0, number y = 0, table color = Color( 255, 255, 255, 255 ), number xAlign = TEXT_ALIGN_LEFT )

Description

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

This is a rendering function that requires a 2d rendering context.

This means that it will only work in 2d Rendering Hooks.

See also MarkupObject for limited width and markup support.

Arguments

1 string text
Text to be drawn.
2 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.
3 number x = 0
The X Coordinate.
4 number y = 0
The Y Coordinate.
5 table color = Color( 255, 255, 255, 255 )
Color to draw the text in. Uses the Color.
6 number xAlign = TEXT_ALIGN_LEFT
Where to align the text horizontally. Uses the Enums/TEXT_ALIGN.

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!

Page Links


Special Pages


Wikis

?

Render Time: 97ms

DB GetPage 47
Generate Html 20
SaveChanges (1) 14
Render Body 0
Render Sidebar 13