A plugin for the Godot game engine (version 4.x) for rendering primitive 2d shapes.
While the CanvasItem
class supports a number of methods for rendering primitive shapes, the engine only offers the Line2D and Polygon2D nodes for adding primitive shapes to a scene. This plugin introduces the following node types in a similar fashion:
The nodes simply use the builtin CanvasItem
methods for drawing primitive shapes: draw_rect
, draw_circle
and draw_arc
.
- Create an
addons
directory inside your project directory. - Get the plugin from the AssetLib or from GitHub
- From the AssetLib: Open the AssetLib from the Godot editor and search for "Primitives2D". Click download to install the plugin.
- From GitHub: Run
git clone https://github.com/peter-kish/primitives2d.git
and copy the contents of theaddons
directory to your projectsaddons
directory.
- Enable the plugin in
Project Settings > Plugins
.
Add a Rectangle2D, Circle2D or Arc2D node to your scene and set the node properties described below.
Draws a 2D rectangle.
color: Color
- The color of the rectangle.size: Vector2
- The size of the rectangle.filled: bool
- Iffalse
, the rectangle will be drawn as a stroke with thecolor
andline_width
specified.line_width: float
- Width of the stroke (in casefilled
istrue
).centered: bool
- Iftrue
, the rectangle will be drawn centered.
Draws a 2D circle.
color: Color
- The color of the circle.radius: float
- The radius of the circle.filled: bool
- Iffalse
, the circle will be drawn as a stroke with thecolor
andline_width
specified.line_width: float
- Width of the stroke (in casefilled
istrue
).antialiased: bool
- Iftrue
, the lines will attempt to perform antialiasing using OpenGL line smoothing.detail: int
- The number of line segments.
Draws a unfilled 2D arc.
color: Color
- The color of the arc.radius: float
- The radius of the arc.filled: bool
- Iffalse
, the arc will be drawn as a stroke with thecolor
andline_width
specified.line_width: float
- Width of the stroke (in casefilled
istrue
).antialiased: bool
- Iftrue
, the lines will attempt to perform antialiasing using OpenGL line smoothing.detail: int
- The number of line segments.