Appearance
Rendering API
The Rendering API allows you to draw 2D geometry and text on the screen, as well as 3D geometry in the world.
Rendering Events
2D Rendering
All 2D drawing must happen within the prepare_ui_canvas event handler.
lua
feature.on("prepare_ui_canvas", function(event)
local canvas = event.canvas
-- Draw here
end)3D Rendering
All 3D world drawing must happen within the prepare_world_canvas event handler.
lua
feature.on("prepare_world_canvas", function(event)
local canvas = event.canvas
-- Draw here
end)Drawable Types (2D)
The following builders are available under types.* for use with ui_canvas.
Rectangles (rect_drawable)
lua
types.rect_drawable.new()
.position(10, 10)
.bounds(100, 50)
.base_color(types.color.BLACK)
.corner_radii(5)
.outline(1, types.color.WHITE)
.insert(canvas)Text (text_drawable)
lua
types.text_drawable.new()
.text("Hello Neon")
.position(10, 70)
.scale(12)
.align(enums.align.left)
.insert(canvas)Circles (circle_drawable)
lua
types.circle_drawable.new()
.position(150, 35)
.size(20)
.base_color(types.color.RED)
.insert(canvas)Lines (line_drawable)
lua
types.line_drawable.new()
.color(types.color.WHITE)
.point(10, 100)
.point(110, 150)
.insert(canvas)Canvas Utilities
Scissor Mask (push_scissor_mask)
Clips all rendering within the callback to the specified rectangle.
lua
canvas.push_scissor_mask(x, y, width, height, function()
-- Everything drawn here will be clipped to the rectangle
end)Drawable Types (3D)
The following builders are available under types.* for use with world_canvas.
3D Boxes (world_box_drawable)
lua
types.world_box_drawable.new()
.min(x1, y1, z1)
.max(x2, y2, z2)
.fill_color(types.color.BLUE)
.outline_color(types.color.WHITE)
.insert(canvas)3D Lines (world_line_drawable)
lua
types.world_line_drawable.new()
.color(types.color.RED)
.point(x1, y1, z1)
.point(x2, y2, z2)
.insert(canvas)3D Flat Circles (world_flat_circle_drawable)
lua
types.world_flat_circle_drawable.new()
.center(x, y, z)
.radius(5)
.fill_color(types.color.GREEN)
.insert(canvas)