Drawing

Drawing.new

Creates a new Drawing object of the requested type and adds it to Real's tracked Drawing object list.

Syntax

Drawing.new(objectType: "Image" | "Line" | "Text" | "Circle" | "Square" | "Quad" | "Triangle"): DrawingObject

Arguments

NameTypeDescription
objectType"Image" | "Line" | "Text" | "Circle" | "Square" | "Quad" | "Triangle"Exact Drawing type name to create. Supported values are "Line", "Text", "Circle", "Square", "Quad", "Triangle", and "Image".

Returns

NameTypeDescription
objectDrawingObjectCreated Drawing object with the Drawing object type.

Description

Creates a new Drawing object of the requested type and adds it to Real's tracked Drawing object list. The type string must be one of the exact supported names: "Line", "Text", "Circle", "Square", "Quad", "Triangle", or "Image". Missing, non-string, or unsupported type values raise a Lua error. the Drawing API registers this API only when the required rendering environment is active is true; when that check is false, the initializer returns before creating these globals.

Call it with 1 parameter(s): objectType. The argument table explains which values are required and which ones only refine the behavior.

It returns object (DrawingObject). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Create a visible square and configure its basic drawing properties.

local square = Drawing.new("Square")
square.Position = Vector2.new(120, 120)
square.Size = Vector2.new(220, 120)
square.Color = Color3.fromRGB(120, 170, 255)
square.Filled = true
square.Visible = true