Garry's Mod Wiki

MarkupObject:Draw

  MarkupObject:Draw( number xOffset, number yOffset, number xAlign = TEXT_ALIGN_LEFT, number yAlign = TEXT_ALIGN_TOP, number alphaoverride = 255, number textAlign = TEXT_ALIGN_LEFT )

Description

Draws the computed markupobject to the screen. See markup.Parse.

Arguments

1 number xOffset
The X coordinate on the screen.
2 number yOffset
The Y coordinate on the screen.
3 number xAlign = TEXT_ALIGN_LEFT
The alignment of the x coordinate within the text using TEXT_ALIGN enum
4 number yAlign = TEXT_ALIGN_TOP
The alignment of the y coordinate within the text using TEXT_ALIGN enum
5 number alphaoverride = 255
Sets the alpha of all drawn objects to this value.
6 number textAlign = TEXT_ALIGN_LEFT
The alignment of the text horizontally using TEXT_ALIGN enum

Example

Shows the difference between xAlign and textAlign.

local parsed = markup.Parse( "<font=Default>changed font</font>\n<color=255,0,255,255>changed color with a long text</color>" ) hook.Add( "HUDPaint", "MarkupTest", function() -- xAlign = LEFT draw.RoundedBox( 0, 200, 300, parsed:GetWidth(), parsed:GetHeight(), Color( 0, 0, 0, 100 ) ) parsed:Draw( 200, 300 ) -- xAlign = CENTER draw.RoundedBox( 0, 200 - parsed:GetWidth() / 2, 350, parsed:GetWidth(), parsed:GetHeight(), Color( 0, 0, 0, 100 ) ) parsed:Draw( 200, 350, TEXT_ALIGN_CENTER ) -- textAlign = RIGHT draw.RoundedBox( 0, 200, 400, parsed:GetMaxWidth(), parsed:GetHeight(), Color( 0, 0, 0, 100 ) ) parsed:Draw( 200, 400, nil, nil, nil, TEXT_ALIGN_RIGHT ) end )
Output:
image.png