Garry's Mod Wiki

Revision Difference

surface.DrawOutlinedRect#528110

<function name="DrawOutlinedRect" parent="surface" type="libraryfunc"> <description> Draws a hollow box with a border width of 1 px. <rendercontext hook="false" type="2D"></rendercontext> </description> <realm>Client and Menu</realm> <args> <arg name="x" type="number">The start x integer coordinate.</arg> <arg name="y" type="number">The start y integer coordinate.</arg> <arg name="w" type="number">The integer width.</arg> <arg name="h" type="number">The integer height.</arg> </args> </function> <example> <description>Draws a 100x100 outlined rectangle in top left corner.</description> <code> surface.SetDrawColor( Color( 255, 255, 255, 255 ) ) surface.DrawOutlinedRect( 0, 0, 100, 100 ) </code>⤶ ⤶ </example>⤶ ⤶ ⤶ <example>⤶ <description>A convenience function to draw an outlined rect with given color and thickness</description>⤶ <code>⤶ function draw.OutlinedBox( x, y, w, h, thickness, clr )⤶ surface.SetDrawColor( clr )⤶ for i=0, thickness - 1 do⤶ surface.DrawOutlinedRect( x + i, y + i, w - i * 2, h - i * 2 )⤶ end⤶ end⤶ ⤶ // Usage⤶ hook.Add( "HUDPaint", "OutlinedRectExample", function()⤶ draw.OutlinedBox( 0, 0, 100, 100, 2, Color( 255, 255, 255 ) )⤶ end )⤶ hook.Add( "HUDPaint", "DrawOutlinedRect", function() surface.SetDrawColor( 255, 255, 255, 128 ) surface.DrawOutlinedRect( 25, 25, 100, 100, math.floor( math.sin( CurTime() * 5 ) * 5 ) + 10 )⤶ ⤶ end )⤶ </code> </example>