Rect

From Sim Innovations Wiki
Jump to navigation Jump to search

Description

_rect(x, y, width, height)
_rect(x, y, width, height, all_corners)
_rect(x, y, width, height, top_left_corner, top_right_corner, bottom_left_corner, bottom_right_corner) (from AM/AP 3.6)

_rect is used to draw a rectangle.

Info This function may only be called within a canvas draw callback

Return value

This function won't return any value.

Arguments

# Argument Type Description
1 x Number Left point of the rectangle.
2 y Number Top point of the rectangle.
3 width Number Width of the rectangle.
4 heigth Number Height of the rectangle.
5 corner Number (Optional) Radius of arcs on every corner of the rectangle, use if you want rounded corners.
5 top_left_corner Number (Optional) Radius of arcs on top left corner of the rectangle, use if you want rounded corners.
6 top_right_corner Number (Optional) Radius of arcs on top right corner of the rectangle, use if you want rounded corners.
7 bottom_left_corner Number (Optional) Radius of arcs on bottom left corner of the rectangle, use if you want rounded corners.
8 bottom_right_corner Number (Optional) Radius of arcs on bottom right corner of the rectangle, use if you want rounded corners.

Example

canvas_id = canvas_add(0, 0, 200, 200, function()
  -- Create a rectangle
  _rect(50, 50, 100, 100)

  _fill("red")
end)
Output of code above