S&box Wiki

Sandbox.UI.Panel.DrawBackground

Syntax

Arguments

Example

Draw a 30 by 30 grid with an animated rainbow pattern.

public override void DrawBackground( ref RenderState state ) { int gridSize = 30; int rainbowSpeed = 100; Rect rect = this.Box.Rect; float boxWidth = rect.width / gridSize; float boxHeight = rect.height / gridSize; for ( float x = 0; x < gridSize; x++ ) { for ( float y = 0; y < gridSize; y++ ) { float boxLeft = rect.left + x * boxWidth; float boxTop = rect.top + y * boxHeight; Color boxColor = new ColorHsv( Time.Now * rainbowSpeed + x + y, 1, 1 ); Render.UI.Box( new Rect( boxLeft, boxTop, boxWidth, boxHeight), boxColor ); } } }