API ColorRect - shmellyorc/Box GitHub Wiki

ColorRect

Namespace: Box.Entities.Graphics

Description

Represents a rectangular entity that renders a solid color block over its area, using a one-pixel surface stretched to its Size. Includes an optional debug outline when enabled.

Constructor

public ColorRect();

Sets the initial Size to match the renderer’s dimensions and uses the default white tint for drawing.

Properties

Property Description
BoxColor Color The tint color applied when drawing the rectangle surface.

Methods

Method Signature Description Returns
protected override void OnEnter() Called when the entity enters the active state; creates a 1×1 Surface used for filling the rectangle. void
protected override void Update() Draws the filled rectangle at Position with dimensions Size and the current Color. If debug drawing is enabled, also draws an orange outline. void

Examples

// Create a semi-transparent red overlay that fills the screen
var overlay = new ColorRect
{
    Color = new BoxColor(255, 0, 0, 128),
    Size = new Vect2(800, 600),
    Layer = 100
};

mainScreen.AddEntity(overlay);