Drawing
The Drawing API allows you to create and manipulate 2D shapes and text overlays in the Roblox window.
Drawing.new(type: string, collect: boolean?): DrawingObject
Creates a new drawing object of the specified type.
type
: The type of drawing object to create ("Line", "Circle", "Square", "Triangle", "Quad", "Text", or "Image")collect
: (Optional) Whether the object should be automatically collected
Returns: A new DrawingObject
Drawing.clear()
Clears all drawing objects.
Drawing Fonts
Constants for text fonts:
Constant | Description |
---|---|
Drawing.Fonts.UI |
UI font |
Drawing.Fonts.System |
System font |
Drawing.Fonts.Plex |
Plex font |
Drawing.Fonts.Monospace |
Monospace font |
DrawingObject Common Properties
All drawing objects have the following common properties:
Property | Type | Description |
---|---|---|
Visible |
boolean | Whether the object is visible |
ZIndex |
number | The rendering order of the object |
Transparency |
number | The transparency of the object (0-1) |
Color |
Color3 | The color of the object |
Remove() |
function | Function to remove the object |
Specific DrawingObject Properties
Line Properties
Property | Type | Description |
---|---|---|
From |
Vector2 | Starting point of the line |
To |
Vector2 | Ending point of the line |
Thickness |
number | Thickness of the line |
Circle Properties
Property | Type | Description |
---|---|---|
Position |
Vector2 | Center position of the circle |
Radius |
number | Radius of the circle |
Filled |
boolean | Whether the circle is filled |
Thickness |
number | Thickness of the circle outline |
NumSides |
number | Number of sides (for approximating the circle) |
Square Properties
Property | Type | Description |
---|---|---|
Position |
Vector2 | Top-left position of the square |
Size |
Vector2 | Size of the square |
Filled |
boolean | Whether the square is filled |
Thickness |
number | Thickness of the square outline |
Triangle Properties
Property | Type | Description |
---|---|---|
PointA |
Vector2 | First point of the triangle |
PointB |
Vector2 | Second point of the triangle |
PointC |
Vector2 | Third point of the triangle |
Filled |
boolean | Whether the triangle is filled |
Thickness |
number | Thickness of the triangle outline |
Quad Properties
Property | Type | Description |
---|---|---|
PointA |
Vector2 | First point of the quad |
PointB |
Vector2 | Second point of the quad |
PointC |
Vector2 | Third point of the quad |
PointD |
Vector2 | Fourth point of the quad |
Filled |
boolean | Whether the quad is filled |
Thickness |
number | Thickness of the quad outline |
Text Properties
Property | Type | Description |
---|---|---|
Text |
string | The text to display |
Font |
Drawing.Fonts | The font of the text |
Size |
number | The size of the text |
Position |
Vector2 | The position of the text |
Outline |
boolean | Whether the text has an outline |
OutlineColor |
Color3 | The color of the text outline |
Center |
boolean | Whether the text is centered |
TextBounds |
Vector2 | The bounding box of the text (read-only) |
Image Properties
Property | Type | Description |
---|---|---|
Position |
Vector2 | The position of the image |
Size |
Vector2 | The size of the image |
Data |
string | The image data (write-only) |
Rounding |
number | The rounding of the image corners |
Global Functions
getrenderproperty(object: DrawingObject, property: string): any
Gets a property of a drawing object.
setrenderproperty(object: DrawingObject, property: string, value: any)
Sets a property of a drawing object.
isrenderobj(object: any): boolean
Checks if the given object is a drawing object.
cleardrawcache()
Clears the internal drawing cache.
Example Usage
local line = Drawing.new("Line")
line.From = Vector2.new(100, 100)
line.To = Vector2.new(200, 200)
line.Color = Color3.new(1, 0, 0)
line.Thickness = 2
line.Visible = true
local text = Drawing.new("Text")
text.Text = "Hello, World!"
text.Position = Vector2.new(150, 150)
text.Color = Color3.new(0, 1, 0)
text.Size = 18
text.Font = Drawing.Fonts.UI
text.Visible = true
-- Later, when you're done with the drawings
line:Remove()
text:Remove()