Garry's Mod Wiki

render.SetScissorRect

  render.SetScissorRect( number startX, number startY, number endX, number endY, boolean enable )

Description

Sets a scissoring rect which limits the drawing area.

Arguments

1 number startX
X start coordinate of the scissor rect.
2 number startY
Y start coordinate of the scissor rect.
3 number endX
X end coordinate of the scissor rect.
4 number endY
Y end coordinate of the scissor rect.
5 boolean enable
Enable or disable the scissor rect.

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 )