Garry's Mod Wiki

Revision Difference

draw.DrawText#515299

<function name="DrawText" parent="draw" type="libraryfunc">⤶ <description>⤶ Simple draw text at position, but this will expand newlines and tabs.⤶ ⤶ <rendercontext hook="false" type="2D"/>⤶ ⤶ See also <page>MarkupObject</page> for limited width and markup support.⤶ </description>⤶ <realm>Client and Menu</realm>⤶ <file line="116-L162">lua/includes/modules/draw.lua</file>⤶ <args>⤶ <arg name="text" type="string">Text to be drawn.</arg>⤶ <arg name="font" type="string" default="DermaDefault">Name of font to draw the text in. See &lt;page&gt;surface.CreateFont&lt;/page&gt; to create your own, or &lt;page&gt;Default Fonts&lt;/page&gt; for a list of default fonts.</arg>⤶ <arg name="x" type="number" default="0">The X Coordinate.</arg>⤶ <arg name="y" type="number" default="0">The Y Coordinate.</arg>⤶ <arg name="color" type="table" default="Color( 255, 255, 255, 255 )">Color to draw the text in. Uses the &lt;page&gt;Color&lt;/page&gt;.</arg>⤶ <arg name="xAlign" type="number" default="TEXT_ALIGN_LEFT">Where to align the text horizontally. Uses the &lt;page&gt;TEXT_ALIGN&lt;/page&gt;.</arg>⤶ </args>⤶ </function>⤶ ⤶ <example>⤶ <description>Makes a message saying "Hello there!" pop up in the center of your screen.</description>⤶ <code>⤶ 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)⤶ </code>⤶ <output>Hello there!</output>⤶ ⤶ </example>