render.SetScissorRect
Example
Shows how to use this function. This will cut the white rectangle from full screen to 512x512 box in top left corner
render.SetScissorRect( 0, 0, 512, 512, true ) -- Enable the rect
draw.RoundedBox( 4, 0, 0, ScrW(), ScrH(), color_white ) -- Draw a white rectangle over the whole screen
render.SetScissorRect( 0, 0, 0, 0, false ) -- Disable after you are done
Example
Draws a fake circle + cut it to look like a progress bar
local function draw_circle( x, y, radius, color, percent )
percent = percent or 1
render.SetScissorRect( x - radius, y - radius + radius * 2 * ( 1 - percent ), x + radius, y + radius * 2, true )
draw.RoundedBox( radius, x - radius, y - radius, radius * 2, radius * 2, color or color_white )
render.SetScissorRect( 0, 0, 0, 0, false )
end
hook.Add( "HUDPaint", "GMod:Wiki", function()
local w, h = ScrW(), ScrH()
local radius = h * 0.1
-- Filled circle
draw_circle( w / 2, h * 0.25, radius, Color( 255, 0, 0 ), 1 )
-- Filled circle + quarter circle
draw_circle( w / 2, h / 2, radius, Color( 255, 0, 0 ), 1 )
draw_circle( w / 2, h / 2, radius, Color( 0, 255, 0 ), 0.25 )
-- Half circle
draw_circle( w / 2, h * 0.75, radius, Color( 0, 0, 255 ), 0.5 )
end )