Skip to main content

DrawRectangle

This function was added in DSL 1

Description

Draws a rectangle on the screen with the specified position, size, and color.

Position and size in normalized coords, relative to the screen, 0-1.

Keep the general rules of rendering in mind. x and y define the top left of the rectangle.

function DrawRectangle(x, y, width, height, red, green, blue, alpha) --[[ ... ]] end

Parameters

  • x: number - The x-coordinate of the rectangle's top-left corner (0-1).
  • y: number - The y-coordinate of the rectangle's top-left corner (0-1).
  • width: number - The width of the rectangle (0-1).
  • height: number - The height of the rectangle (0-1).
  • red?: number|nil - (Optional) The red component of the rectangle's color (0-255), default 255.
  • green?: number|nil - (Optional) The green component of the rectangle's color (0-255), default 255.
  • blue?: number|nil - (Optional) The blue component of the rectangle's color (0-255), default 255.
  • alpha?: number|nil - (Optional) The alpha component of the rectangle's color (0-255), default 255.

Return Values

None.

Versions

  • DSL 4 - alpha is now optional, and 255 will be used if it is not present.

Example

Draws a red rectangle at (10%, 10%) with size (20%, 20%)

DrawRectangle(0.1, 0.1, 0.2, 0.2, 255, 0, 0, 255)