2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2022-02-14 13:18:53 +00:00
<class name= "CanvasItem" inherits= "Node" version= "4.0" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 20:42:36 +00:00
<brief_description >
Base class of anything 2D.
</brief_description>
<description >
2020-01-23 10:14:14 +00:00
Base class of anything 2D. Canvas items are laid out in a tree; children inherit and extend their parent's transform. [CanvasItem] is extended by [Control] for anything GUI-related, and by [Node2D] for anything related to the 2D engine.
Any [CanvasItem] can draw. For this, [method update] must be called, then [constant NOTIFICATION_DRAW] will be received on idle time to request redraw. Because of this, canvas items don't need to be redrawn on every frame, improving the performance significantly. Several functions for drawing on the [CanvasItem] are provided (see [code]draw_*[/code] functions). However, they can only be used inside the [method Object._notification], signal or [method _draw] virtual functions.
Canvas items are drawn in tree order. By default, children are on top of their parents so a root [CanvasItem] will be drawn behind everything. This behavior can be changed on a per-item basis.
A [CanvasItem] can also be hidden, which will also hide its children. It provides many ways to change parameters such as modulation (for itself and its children) and self modulation (only for itself), as well as its blend mode.
2017-09-12 20:42:36 +00:00
Ultimately, a transform notification can be requested, which will notify the node that its global position changed in case the parent tree changed.
2021-01-04 13:33:44 +00:00
[b]Note:[/b] Unless otherwise specified, all methods that have angle parameters must have angles specified as [i]radians[/i]. To convert degrees to radians, use [method @GlobalScope.deg2rad].
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
2021-11-15 09:43:07 +00:00
<link title= "Viewport and canvas transforms" > $DOCS_URL/tutorials/2d/2d_transforms.html</link>
<link title= "Custom drawing in 2D" > $DOCS_URL/tutorials/2d/custom_drawing_in_2d.html</link>
2020-10-01 08:34:47 +00:00
<link title= "Audio Spectrum Demo" > https://godotengine.org/asset-library/asset/528</link>
2017-09-12 20:42:36 +00:00
</tutorials>
<methods >
<method name= "_draw" qualifiers= "virtual" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
2020-01-23 10:14:14 +00:00
Overridable function called by the engine (if defined) to draw the canvas item.
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-06-17 14:30:20 +00:00
<method name= "draw_animation_slice" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "animation_length" type= "float" />
<param index= "1" name= "slice_begin" type= "float" />
<param index= "2" name= "slice_end" type= "float" />
<param index= "3" name= "offset" type= "float" default= "0.0" />
2021-06-17 14:30:20 +00:00
<description >
Subsequent drawing commands will be ignored unless they fall within the specified animation slice. This is a faster way to implement animations that loop on background rather than redrawing constantly.
</description>
</method>
2019-10-26 14:40:31 +00:00
<method name= "draw_arc" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "center" type= "Vector2" />
<param index= "1" name= "radius" type= "float" />
<param index= "2" name= "start_angle" type= "float" />
<param index= "3" name= "end_angle" type= "float" />
<param index= "4" name= "point_count" type= "int" />
<param index= "5" name= "color" type= "Color" />
<param index= "6" name= "width" type= "float" default= "1.0" />
<param index= "7" name= "antialiased" type= "bool" default= "false" />
2019-10-26 14:40:31 +00:00
<description >
2021-12-01 17:05:34 +00:00
Draws a unfilled arc between the given angles. The larger the value of [code]point_count[/code], the smoother the curve. See also [method draw_circle].
2019-10-26 14:40:31 +00:00
</description>
</method>
2020-08-12 11:49:10 +00:00
<method name= "draw_char" qualifiers= "const" >
2022-05-09 09:47:10 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "font" type= "Font" />
<param index= "1" name= "pos" type= "Vector2" />
<param index= "2" name= "char" type= "String" />
<param index= "3" name= "font_size" type= "int" default= "16" />
<param index= "4" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
2022-05-09 09:47:10 +00:00
<description >
Draws a string first character using a custom font.
</description>
</method>
<method name= "draw_char_outline" qualifiers= "const" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "font" type= "Font" />
<param index= "1" name= "pos" type= "Vector2" />
<param index= "2" name= "char" type= "String" />
<param index= "3" name= "font_size" type= "int" default= "16" />
<param index= "4" name= "size" type= "int" default= "-1" />
<param index= "5" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
2017-09-12 20:42:36 +00:00
<description >
2022-05-09 09:47:10 +00:00
Draws a string first character outline using a custom font.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "draw_circle" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "position" type= "Vector2" />
<param index= "1" name= "radius" type= "float" />
<param index= "2" name= "color" type= "Color" />
2017-09-12 20:42:36 +00:00
<description >
2022-06-01 08:38:09 +00:00
Draws a colored, filled circle. See also [method draw_arc], [method draw_polyline] and [method draw_polygon].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "draw_colored_polygon" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "points" type= "PackedVector2Array" />
<param index= "1" name= "color" type= "Color" />
<param index= "2" name= "uvs" type= "PackedVector2Array" default= "PackedVector2Array()" />
<param index= "3" name= "texture" type= "Texture2D" default= "null" />
2017-09-12 20:42:36 +00:00
<description >
2021-12-01 17:05:34 +00:00
Draws a colored polygon of any amount of points, convex or concave. Unlike [method draw_polygon], a single color must be specified for the whole polygon.
2017-09-12 20:42:36 +00:00
</description>
</method>
2022-02-21 17:34:16 +00:00
<method name= "draw_dashed_line" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "from" type= "Vector2" />
<param index= "1" name= "to" type= "Vector2" />
<param index= "2" name= "color" type= "Color" />
<param index= "3" name= "width" type= "float" default= "1.0" />
<param index= "4" name= "dash" type= "float" default= "2.0" />
2022-02-21 17:34:16 +00:00
<description >
Draws a dashed line from a 2D point to another, with a given color and width. See also [method draw_multiline] and [method draw_polyline].
</description>
</method>
2021-06-17 14:30:20 +00:00
<method name= "draw_end_animation" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2021-06-17 14:30:20 +00:00
<description >
After submitting all animations slices via [method draw_animation_slice], this function can be used to revert drawing to its default state (all subsequent drawing commands will be visible). If you don't care about this particular use case, usage of this function after submitting the slices is not required.
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "draw_line" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "from" type= "Vector2" />
<param index= "1" name= "to" type= "Vector2" />
<param index= "2" name= "color" type= "Color" />
<param index= "3" name= "width" type= "float" default= "1.0" />
<param index= "4" name= "antialiased" type= "bool" default= "false" />
2017-09-12 20:42:36 +00:00
<description >
2022-04-11 17:42:46 +00:00
Draws a line from a 2D point to another, with a given color and width. It can be optionally antialiased. See also [method draw_multiline] and [method draw_polyline].
2017-09-12 20:42:36 +00:00
</description>
</method>
2018-02-25 06:19:42 +00:00
<method name= "draw_mesh" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "mesh" type= "Mesh" />
<param index= "1" name= "texture" type= "Texture2D" />
<param index= "2" name= "transform" type= "Transform2D" default= "Transform2D(1, 0, 0, 1, 0, 0)" />
<param index= "3" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
2018-02-25 06:19:42 +00:00
<description >
2020-01-23 10:14:14 +00:00
Draws a [Mesh] in 2D, using the provided texture. See [MeshInstance2D] for related documentation.
2018-02-25 06:19:42 +00:00
</description>
</method>
2020-12-27 13:30:33 +00:00
<method name= "draw_msdf_texture_rect_region" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "texture" type= "Texture2D" />
<param index= "1" name= "rect" type= "Rect2" />
<param index= "2" name= "src_rect" type= "Rect2" />
<param index= "3" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
<param index= "4" name= "outline" type= "float" default= "0.0" />
<param index= "5" name= "pixel_range" type= "float" default= "4.0" />
2020-12-27 13:30:33 +00:00
<description >
2022-05-09 09:47:10 +00:00
Draws a textured rectangle region of the multi-channel signed distance field texture at a given position, optionally modulated by a color. See [member FontFile.multichannel_signed_distance_field] for more information and caveats about MSDF font rendering.
2020-12-27 13:30:33 +00:00
If [code]outline[/code] is positive, each alpha channel value of pixel in region is set to maximum value of true distance in the [code]outline[/code] radius.
Value of the [code]pixel_range[/code] should the same that was used during distance field texture generation.
</description>
</method>
2017-12-09 23:43:30 +00:00
<method name= "draw_multiline" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "points" type= "PackedVector2Array" />
<param index= "1" name= "color" type= "Color" />
<param index= "2" name= "width" type= "float" default= "1.0" />
2017-12-09 23:43:30 +00:00
<description >
2021-12-01 17:05:34 +00:00
Draws multiple disconnected lines with a uniform [code]color[/code]. When drawing large amounts of lines, this is faster than using individual [method draw_line] calls. To draw interconnected lines, use [method draw_polyline] instead.
2017-12-09 23:43:30 +00:00
</description>
</method>
<method name= "draw_multiline_colors" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "points" type= "PackedVector2Array" />
<param index= "1" name= "colors" type= "PackedColorArray" />
<param index= "2" name= "width" type= "float" default= "1.0" />
2017-12-09 23:43:30 +00:00
<description >
2021-12-01 17:05:34 +00:00
Draws multiple disconnected lines with a uniform [code]width[/code] and segment-by-segment coloring. Colors assigned to line segments match by index between [code]points[/code] and [code]colors[/code]. When drawing large amounts of lines, this is faster than using individual [method draw_line] calls. To draw interconnected lines, use [method draw_polyline_colors] instead.
2017-12-09 23:43:30 +00:00
</description>
</method>
2020-08-12 11:49:10 +00:00
<method name= "draw_multiline_string" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "font" type= "Font" />
<param index= "1" name= "pos" type= "Vector2" />
<param index= "2" name= "text" type= "String" />
<param index= "3" name= "alignment" type= "int" enum= "HorizontalAlignment" default= "0" />
<param index= "4" name= "width" type= "float" default= "-1" />
<param index= "5" name= "font_size" type= "int" default= "16" />
<param index= "6" name= "max_lines" type= "int" default= "-1" />
<param index= "7" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
<param index= "8" name= "brk_flags" type= "int" enum= "TextServer.LineBreakFlag" default= "3" />
<param index= "9" name= "jst_flags" type= "int" enum= "TextServer.JustificationFlag" default= "3" />
<param index= "10" name= "direction" type= "int" enum= "TextServer.Direction" default= "0" />
<param index= "11" name= "orientation" type= "int" enum= "TextServer.Orientation" default= "0" />
2020-08-12 11:49:10 +00:00
<description >
Breaks [code]text[/code] to the lines and draws it using the specified [code]font[/code] at the [code]position[/code] (top-left corner). The text will have its color multiplied by [code]modulate[/code]. If [code]clip_w[/code] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
</description>
</method>
2022-05-09 09:47:10 +00:00
<method name= "draw_multiline_string_outline" qualifiers= "const" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "font" type= "Font" />
<param index= "1" name= "pos" type= "Vector2" />
<param index= "2" name= "text" type= "String" />
<param index= "3" name= "alignment" type= "int" enum= "HorizontalAlignment" default= "0" />
<param index= "4" name= "width" type= "float" default= "-1" />
<param index= "5" name= "font_size" type= "int" default= "16" />
<param index= "6" name= "max_lines" type= "int" default= "-1" />
<param index= "7" name= "size" type= "int" default= "1" />
<param index= "8" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
<param index= "9" name= "brk_flags" type= "int" enum= "TextServer.LineBreakFlag" default= "3" />
<param index= "10" name= "jst_flags" type= "int" enum= "TextServer.JustificationFlag" default= "3" />
<param index= "11" name= "direction" type= "int" enum= "TextServer.Direction" default= "0" />
<param index= "12" name= "orientation" type= "int" enum= "TextServer.Orientation" default= "0" />
2022-05-09 09:47:10 +00:00
<description >
Breaks [code]text[/code] to the lines and draws text outline using the specified [code]font[/code] at the [code]position[/code] (top-left corner). The text will have its color multiplied by [code]modulate[/code]. If [code]clip_w[/code] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
</description>
</method>
2018-02-25 06:19:42 +00:00
<method name= "draw_multimesh" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "multimesh" type= "MultiMesh" />
<param index= "1" name= "texture" type= "Texture2D" />
2018-02-25 06:19:42 +00:00
<description >
2020-01-23 10:14:14 +00:00
Draws a [MultiMesh] in 2D with the provided texture. See [MultiMeshInstance2D] for related documentation.
2018-02-25 06:19:42 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "draw_polygon" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "points" type= "PackedVector2Array" />
<param index= "1" name= "colors" type= "PackedColorArray" />
<param index= "2" name= "uvs" type= "PackedVector2Array" default= "PackedVector2Array()" />
<param index= "3" name= "texture" type= "Texture2D" default= "null" />
2017-09-12 20:42:36 +00:00
<description >
2021-12-01 17:05:34 +00:00
Draws a solid polygon of any amount of points, convex or concave. Unlike [method draw_colored_polygon], each point's color can be changed individually. See also [method draw_polyline] and [method draw_polyline_colors].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "draw_polyline" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "points" type= "PackedVector2Array" />
<param index= "1" name= "color" type= "Color" />
<param index= "2" name= "width" type= "float" default= "1.0" />
<param index= "3" name= "antialiased" type= "bool" default= "false" />
2017-09-12 20:42:36 +00:00
<description >
2022-04-11 17:42:46 +00:00
Draws interconnected line segments with a uniform [code]color[/code] and [code]width[/code] and optional antialiasing. When drawing large amounts of lines, this is faster than using individual [method draw_line] calls. To draw disconnected lines, use [method draw_multiline] instead. See also [method draw_polygon].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "draw_polyline_colors" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "points" type= "PackedVector2Array" />
<param index= "1" name= "colors" type= "PackedColorArray" />
<param index= "2" name= "width" type= "float" default= "1.0" />
<param index= "3" name= "antialiased" type= "bool" default= "false" />
2017-09-12 20:42:36 +00:00
<description >
2022-04-11 17:42:46 +00:00
Draws interconnected line segments with a uniform [code]width[/code] and segment-by-segment coloring, and optional antialiasing. Colors assigned to line segments match by index between [code]points[/code] and [code]colors[/code]. When drawing large amounts of lines, this is faster than using individual [method draw_line] calls. To draw disconnected lines, use [method draw_multiline_colors] instead. See also [method draw_polygon].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "draw_primitive" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "points" type= "PackedVector2Array" />
<param index= "1" name= "colors" type= "PackedColorArray" />
<param index= "2" name= "uvs" type= "PackedVector2Array" />
<param index= "3" name= "texture" type= "Texture2D" default= "null" />
<param index= "4" name= "width" type= "float" default= "1.0" />
2017-09-12 20:42:36 +00:00
<description >
2022-01-05 01:05:56 +00:00
Draws a custom primitive. 1 point for a point, 2 points for a line, 3 points for a triangle, and 4 points for a quad. If 0 points or more than 4 points are specified, nothing will be drawn and an error message will be printed. See also [method draw_line], [method draw_polyline], [method draw_polygon], and [method draw_rect].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "draw_rect" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "rect" type= "Rect2" />
<param index= "1" name= "color" type= "Color" />
<param index= "2" name= "filled" type= "bool" default= "true" />
<param index= "3" name= "width" type= "float" default= "1.0" />
2017-09-12 20:42:36 +00:00
<description >
2020-02-12 08:59:06 +00:00
Draws a rectangle. If [code]filled[/code] is [code]true[/code], the rectangle will be filled with the [code]color[/code] specified. If [code]filled[/code] is [code]false[/code], the rectangle will be drawn as a stroke with the [code]color[/code] and [code]width[/code] specified.
[b]Note:[/b] [code]width[/code] is only effective if [code]filled[/code] is [code]false[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "draw_set_transform" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "position" type= "Vector2" />
<param index= "1" name= "rotation" type= "float" default= "0.0" />
<param index= "2" name= "scale" type= "Vector2" default= "Vector2(1, 1)" />
2017-09-12 20:42:36 +00:00
<description >
2017-12-07 19:17:08 +00:00
Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "draw_set_transform_matrix" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "xform" type= "Transform2D" />
2017-09-12 20:42:36 +00:00
<description >
2017-12-07 19:17:08 +00:00
Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this.
2017-09-12 20:42:36 +00:00
</description>
</method>
2020-08-12 11:49:10 +00:00
<method name= "draw_string" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "font" type= "Font" />
<param index= "1" name= "pos" type= "Vector2" />
<param index= "2" name= "text" type= "String" />
<param index= "3" name= "alignment" type= "int" enum= "HorizontalAlignment" default= "0" />
<param index= "4" name= "width" type= "float" default= "-1" />
<param index= "5" name= "font_size" type= "int" default= "16" />
<param index= "6" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
<param index= "7" name= "jst_flags" type= "int" enum= "TextServer.JustificationFlag" default= "3" />
<param index= "8" name= "direction" type= "int" enum= "TextServer.Direction" default= "0" />
<param index= "9" name= "orientation" type= "int" enum= "TextServer.Orientation" default= "0" />
2017-09-12 20:42:36 +00:00
<description >
2021-03-17 13:42:00 +00:00
Draws [code]text[/code] using the specified [code]font[/code] at the [code]position[/code] (bottom-left corner using the baseline of the font). The text will have its color multiplied by [code]modulate[/code]. If [code]clip_w[/code] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
2020-07-29 08:39:57 +00:00
[b]Example using the default project font:[/b]
2020-09-12 15:06:13 +00:00
[codeblocks]
[gdscript]
2020-07-29 08:39:57 +00:00
# If using this method in a script that redraws constantly, move the
# `default_font` declaration to a member variable assigned in `_ready()`
# so the Control is only created once.
var default_font = Control.new().get_font("font")
2020-08-12 11:49:10 +00:00
var default_font_size = Control.new().get_font_size("font_size")
2021-11-25 02:58:47 +00:00
draw_string(default_font, Vector2(64, 64), "Hello world", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size)
2020-09-12 15:06:13 +00:00
[/gdscript]
[csharp]
// If using this method in a script that redraws constantly, move the
// `default_font` declaration to a member variable assigned in `_ready()`
// so the Control is only created once.
Font defaultFont = new Control().GetFont("font");
2020-08-12 11:49:10 +00:00
int defaultFontSize = new Control().GetFontSize("font_size");
2021-11-25 02:58:47 +00:00
DrawString(defaultFont, new Vector2(64, 64), "Hello world", HORIZONTAL_ALIGNMENT_LEFT, -1, defaultFontSize);
2020-09-12 15:06:13 +00:00
[/csharp]
[/codeblocks]
2020-08-12 11:49:10 +00:00
See also [method Font.draw_string].
2017-09-12 20:42:36 +00:00
</description>
</method>
2022-05-09 09:47:10 +00:00
<method name= "draw_string_outline" qualifiers= "const" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "font" type= "Font" />
<param index= "1" name= "pos" type= "Vector2" />
<param index= "2" name= "text" type= "String" />
<param index= "3" name= "alignment" type= "int" enum= "HorizontalAlignment" default= "0" />
<param index= "4" name= "width" type= "float" default= "-1" />
<param index= "5" name= "font_size" type= "int" default= "16" />
<param index= "6" name= "size" type= "int" default= "1" />
<param index= "7" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
<param index= "8" name= "jst_flags" type= "int" enum= "TextServer.JustificationFlag" default= "3" />
<param index= "9" name= "direction" type= "int" enum= "TextServer.Direction" default= "0" />
<param index= "10" name= "orientation" type= "int" enum= "TextServer.Orientation" default= "0" />
2022-05-09 09:47:10 +00:00
<description >
Draws [code]text[/code] outline using the specified [code]font[/code] at the [code]position[/code] (bottom-left corner using the baseline of the font). The text will have its color multiplied by [code]modulate[/code]. If [code]clip_w[/code] is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "draw_style_box" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "style_box" type= "StyleBox" />
<param index= "1" name= "rect" type= "Rect2" />
2017-09-12 20:42:36 +00:00
<description >
2017-12-11 19:05:26 +00:00
Draws a styled rectangle.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "draw_texture" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "texture" type= "Texture2D" />
<param index= "1" name= "position" type= "Vector2" />
<param index= "2" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
2017-09-12 20:42:36 +00:00
<description >
2017-12-11 19:05:26 +00:00
Draws a texture at a given position.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "draw_texture_rect" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "texture" type= "Texture2D" />
<param index= "1" name= "rect" type= "Rect2" />
<param index= "2" name= "tile" type= "bool" />
<param index= "3" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
<param index= "4" name= "transpose" type= "bool" default= "false" />
2017-09-12 20:42:36 +00:00
<description >
2019-05-14 07:08:22 +00:00
Draws a textured rectangle at a given position, optionally modulated by a color. If [code]transpose[/code] is [code]true[/code], the texture will have its X and Y coordinates swapped.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "draw_texture_rect_region" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "texture" type= "Texture2D" />
<param index= "1" name= "rect" type= "Rect2" />
<param index= "2" name= "src_rect" type= "Rect2" />
<param index= "3" name= "modulate" type= "Color" default= "Color(1, 1, 1, 1)" />
<param index= "4" name= "transpose" type= "bool" default= "false" />
<param index= "5" name= "clip_uv" type= "bool" default= "true" />
2017-09-12 20:42:36 +00:00
<description >
2019-05-14 07:08:22 +00:00
Draws a textured rectangle region at a given position, optionally modulated by a color. If [code]transpose[/code] is [code]true[/code], the texture will have its X and Y coordinates swapped.
2017-09-12 20:42:36 +00:00
</description>
</method>
2018-09-10 22:18:05 +00:00
<method name= "force_update_transform" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2018-09-10 22:18:05 +00:00
<description >
2019-11-01 09:37:39 +00:00
Forces the transform to update. Transform changes in physics are not instant for performance reasons. Transforms are accumulated and then set. Use this if you need an up-to-date transform when doing physics operations.
2018-09-10 22:18:05 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_canvas" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "RID" />
2017-09-12 20:42:36 +00:00
<description >
2019-05-24 02:15:43 +00:00
Returns the [RID] of the [World2D] canvas where this item is in.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_canvas_item" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "RID" />
2017-09-12 20:42:36 +00:00
<description >
2020-03-30 16:22:57 +00:00
Returns the canvas item RID used by [RenderingServer] for this item.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_canvas_transform" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform2D" />
2017-09-12 20:42:36 +00:00
<description >
2020-01-23 10:14:14 +00:00
Returns the transform matrix of this item's canvas.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_global_mouse_position" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2" />
2017-09-12 20:42:36 +00:00
<description >
2022-01-28 15:19:07 +00:00
Returns the mouse's position in the [CanvasLayer] that this [CanvasItem] is in using the coordinate system of the [CanvasLayer].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_global_transform" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform2D" />
2017-09-12 20:42:36 +00:00
<description >
2020-01-23 10:14:14 +00:00
Returns the global transform matrix of this item.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_global_transform_with_canvas" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform2D" />
2017-09-12 20:42:36 +00:00
<description >
2020-01-23 10:14:14 +00:00
Returns the global transform matrix of this item in relation to the canvas.
2017-09-12 20:42:36 +00:00
</description>
</method>
2017-09-10 13:37:49 +00:00
<method name= "get_local_mouse_position" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2" />
2017-09-12 20:42:36 +00:00
<description >
2022-01-28 15:19:07 +00:00
Returns the mouse's position in this [CanvasItem] using the local coordinate system of this [CanvasItem].
2017-09-12 20:42:36 +00:00
</description>
</method>
2022-03-13 15:02:24 +00:00
<method name= "get_screen_transform" qualifiers= "const" >
<return type= "Transform2D" />
<description >
Returns the transform of this [CanvasItem] in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.
Equals to [method get_global_transform] if the window is embedded (see [member Viewport.gui_embed_subwindows]).
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_transform" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform2D" />
2017-09-12 20:42:36 +00:00
<description >
2020-01-23 10:14:14 +00:00
Returns the transform matrix of this item.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_viewport_rect" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Rect2" />
2017-09-12 20:42:36 +00:00
<description >
2020-01-23 10:14:14 +00:00
Returns the viewport's boundaries as a [Rect2].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_viewport_transform" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform2D" />
2017-09-12 20:42:36 +00:00
<description >
2020-01-23 10:14:14 +00:00
Returns this item's transform in relation to the viewport.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_world_2d" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "World2D" />
2017-09-12 20:42:36 +00:00
<description >
2020-01-23 10:14:14 +00:00
Returns the [World2D] where this item is in.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "hide" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
2021-12-01 17:05:34 +00:00
Hide the [CanvasItem] if it's currently visible. This is equivalent to setting [member visible] to [code]false[/code].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "is_local_transform_notification_enabled" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2017-12-07 19:17:08 +00:00
Returns [code]true[/code] if local transform notifications are communicated to children.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "is_transform_notification_enabled" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2017-12-07 19:17:08 +00:00
Returns [code]true[/code] if global transform notifications are communicated to children.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "is_visible_in_tree" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2020-07-27 10:09:51 +00:00
Returns [code]true[/code] if the node is present in the [SceneTree], its [member visible] property is [code]true[/code] and all its antecedents are also visible. If any antecedent is hidden, this node will not be visible in the scene tree.
2017-09-12 20:42:36 +00:00
</description>
</method>
2017-09-10 13:37:49 +00:00
<method name= "make_canvas_position_local" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "screen_point" type= "Vector2" />
2017-09-12 20:42:36 +00:00
<description >
2017-12-07 19:17:08 +00:00
Assigns [code]screen_point[/code] as this node's new local transform.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "make_input_local" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "InputEvent" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "event" type= "InputEvent" />
2017-09-12 20:42:36 +00:00
<description >
2017-12-07 19:17:08 +00:00
Transformations issued by [code]event[/code]'s inputs are applied in local space instead of global space.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_notify_local_transform" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "enable" type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2022-03-20 13:59:15 +00:00
If [code]enable[/code] is [code]true[/code], this node will receive [constant NOTIFICATION_LOCAL_TRANSFORM_CHANGED] when its local transform changes.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_notify_transform" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "enable" type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2022-03-20 13:59:15 +00:00
If [code]enable[/code] is [code]true[/code], this node will receive [constant NOTIFICATION_TRANSFORM_CHANGED] when its global transform changes.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "show" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
2021-12-01 17:05:34 +00:00
Show the [CanvasItem] if it's currently hidden. This is equivalent to setting [member visible] to [code]true[/code]. For controls that inherit [Popup], the correct way to make them visible is to call one of the multiple [code]popup*()[/code] functions instead.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "update" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
2020-01-23 10:14:14 +00:00
Queue the [CanvasItem] for update. [constant NOTIFICATION_DRAW] will be called on idle time to request redraw.
2017-09-12 20:42:36 +00:00
</description>
</method>
</methods>
<members >
2020-11-04 14:38:26 +00:00
<member name= "clip_children" type= "bool" setter= "set_clip_children" getter= "is_clipping_children" default= "false" >
</member>
2019-06-29 10:38:01 +00:00
<member name= "light_mask" type= "int" setter= "set_light_mask" getter= "get_light_mask" default= "1" >
2019-06-29 13:24:23 +00:00
The rendering layers in which this [CanvasItem] responds to [Light2D] nodes.
2017-09-12 20:42:36 +00:00
</member>
2019-07-15 18:42:47 +00:00
<member name= "material" type= "Material" setter= "set_material" getter= "get_material" >
2019-06-29 13:24:23 +00:00
The material applied to textures on this [CanvasItem].
2017-09-12 20:42:36 +00:00
</member>
2019-09-24 17:45:03 +00:00
<member name= "modulate" type= "Color" setter= "set_modulate" getter= "get_modulate" default= "Color(1, 1, 1, 1)" >
2019-06-29 13:24:23 +00:00
The color applied to textures on this [CanvasItem].
2017-09-12 20:42:36 +00:00
</member>
2019-09-24 17:45:03 +00:00
<member name= "self_modulate" type= "Color" setter= "set_self_modulate" getter= "get_self_modulate" default= "Color(1, 1, 1, 1)" >
2019-06-29 13:24:23 +00:00
The color applied to textures on this [CanvasItem]. This is not inherited by children [CanvasItem]s.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "show_behind_parent" type= "bool" setter= "set_draw_behind_parent" getter= "is_draw_behind_parent_enabled" default= "false" >
2019-06-29 13:24:23 +00:00
If [code]true[/code], the object draws behind its parent.
2017-09-12 20:42:36 +00:00
</member>
2020-02-12 08:59:06 +00:00
<member name= "texture_filter" type= "int" setter= "set_texture_filter" getter= "get_texture_filter" enum= "CanvasItem.TextureFilter" default= "0" >
2020-05-15 12:49:43 +00:00
The texture filtering mode to use on this [CanvasItem].
2020-02-12 08:59:06 +00:00
</member>
<member name= "texture_repeat" type= "int" setter= "set_texture_repeat" getter= "get_texture_repeat" enum= "CanvasItem.TextureRepeat" default= "0" >
2020-05-15 12:49:43 +00:00
The texture repeating mode to use on this [CanvasItem].
2020-02-12 08:59:06 +00:00
</member>
2020-10-09 13:04:15 +00:00
<member name= "top_level" type= "bool" setter= "set_as_top_level" getter= "is_set_as_top_level" default= "false" >
2022-03-31 00:04:55 +00:00
If [code]true[/code], this [CanvasItem] will [i]not[/i] inherit its transform from parent [CanvasItem]s. Its draw order will also be changed to make it draw on top of other [CanvasItem]s that do not have [member top_level] set to [code]true[/code]. The [CanvasItem] will effectively act as if it was placed as a child of a bare [Node].
2020-10-09 13:04:15 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "use_parent_material" type= "bool" setter= "set_use_parent_material" getter= "get_use_parent_material" default= "false" >
2019-06-29 13:24:23 +00:00
If [code]true[/code], the parent [CanvasItem]'s [member material] property is used as this one's material.
2017-09-12 20:42:36 +00:00
</member>
2019-06-29 10:38:01 +00:00
<member name= "visible" type= "bool" setter= "set_visible" getter= "is_visible" default= "true" >
2020-07-27 10:09:51 +00:00
If [code]true[/code], this [CanvasItem] is drawn. The node is only visible if all of its antecedents are visible as well (in other words, [method is_visible_in_tree] must return [code]true[/code]).
[b]Note:[/b] For controls that inherit [Popup], the correct way to make them visible is to call one of the multiple [code]popup*()[/code] functions instead.
2017-09-12 20:42:36 +00:00
</member>
</members>
<signals >
<signal name= "draw" >
<description >
2020-01-23 10:14:14 +00:00
Emitted when the [CanvasItem] must redraw. This can only be connected realtime, as deferred will not allow drawing.
2017-09-12 20:42:36 +00:00
</description>
</signal>
2020-12-08 10:02:17 +00:00
<signal name= "hidden" >
2017-09-12 20:42:36 +00:00
<description >
Emitted when becoming hidden.
</description>
</signal>
<signal name= "item_rect_changed" >
<description >
2020-10-26 04:18:16 +00:00
Emitted when the item's [Rect2] boundaries (position or size) have changed, or when an action is taking place that may have impacted these boundaries (e.g. changing [member Sprite2D.texture]).
2017-09-12 20:42:36 +00:00
</description>
</signal>
<signal name= "visibility_changed" >
<description >
Emitted when the visibility (hidden/visible) changes.
</description>
</signal>
</signals>
<constants >
2019-04-15 12:49:41 +00:00
<constant name= "NOTIFICATION_TRANSFORM_CHANGED" value= "2000" >
2022-03-20 13:59:15 +00:00
The [CanvasItem]'s global transform has changed. This notification is only received if enabled by [method set_notify_transform].
</constant>
<constant name= "NOTIFICATION_LOCAL_TRANSFORM_CHANGED" value= "35" >
The [CanvasItem]'s local transform has changed. This notification is only received if enabled by [method set_notify_local_transform].
2017-10-22 10:56:11 +00:00
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "NOTIFICATION_DRAW" value= "30" >
2020-01-23 10:14:14 +00:00
The [CanvasItem] is requested to draw.
2017-09-12 20:42:36 +00:00
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "NOTIFICATION_VISIBILITY_CHANGED" value= "31" >
2020-01-23 10:14:14 +00:00
The [CanvasItem]'s visibility has changed.
2017-09-12 20:42:36 +00:00
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "NOTIFICATION_ENTER_CANVAS" value= "32" >
2020-01-23 10:14:14 +00:00
The [CanvasItem] has entered the canvas.
2017-09-12 20:42:36 +00:00
</constant>
2017-11-24 22:16:30 +00:00
<constant name= "NOTIFICATION_EXIT_CANVAS" value= "33" >
2020-01-23 10:14:14 +00:00
The [CanvasItem] has exited the canvas.
2017-09-12 20:42:36 +00:00
</constant>
2020-02-12 08:59:06 +00:00
<constant name= "TEXTURE_FILTER_PARENT_NODE" value= "0" enum= "TextureFilter" >
2020-03-03 18:21:21 +00:00
The [CanvasItem] will inherit the filter from its parent.
2020-02-12 08:59:06 +00:00
</constant>
<constant name= "TEXTURE_FILTER_NEAREST" value= "1" enum= "TextureFilter" >
2020-03-03 18:21:21 +00:00
The texture filter reads from the nearest pixel only. The simplest and fastest method of filtering. Useful for pixel art.
2020-02-12 08:59:06 +00:00
</constant>
<constant name= "TEXTURE_FILTER_LINEAR" value= "2" enum= "TextureFilter" >
2020-03-03 18:21:21 +00:00
The texture filter blends between the nearest four pixels. Use this for most cases where you want to avoid a pixelated style.
2020-02-12 08:59:06 +00:00
</constant>
2020-02-19 23:31:43 +00:00
<constant name= "TEXTURE_FILTER_NEAREST_WITH_MIPMAPS" value= "3" enum= "TextureFilter" >
2020-05-15 12:49:43 +00:00
The texture filter reads from the nearest pixel in the nearest mipmap. This is the fastest way to read from textures with mipmaps.
2020-02-12 08:59:06 +00:00
</constant>
<constant name= "TEXTURE_FILTER_LINEAR_WITH_MIPMAPS" value= "4" enum= "TextureFilter" >
2020-05-15 12:49:43 +00:00
The texture filter blends between the nearest 4 pixels and between the nearest 2 mipmaps. Use this for non-pixel art textures that may be viewed at a low scale (e.g. due to [Camera2D] zoom), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels.
2020-02-12 08:59:06 +00:00
</constant>
2020-02-19 23:31:43 +00:00
<constant name= "TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC" value= "5" enum= "TextureFilter" >
2020-05-15 12:49:43 +00:00
The texture filter reads from the nearest pixel, but selects a mipmap based on the angle between the surface and the camera view. This reduces artifacts on surfaces that are almost in line with the camera.
[b]Note:[/b] This texture filter is rarely useful in 2D projects. [constant TEXTURE_FILTER_NEAREST_WITH_MIPMAPS] is usually more appropriate.
2020-02-12 08:59:06 +00:00
</constant>
<constant name= "TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC" value= "6" enum= "TextureFilter" >
2020-05-15 12:49:43 +00:00
The texture filter blends between the nearest 4 pixels and selects a mipmap based on the angle between the surface and the camera view. This reduces artifacts on surfaces that are almost in line with the camera. This is the slowest of the filtering options, but results in the highest quality texturing.
[b]Note:[/b] This texture filter is rarely useful in 2D projects. [constant TEXTURE_FILTER_LINEAR_WITH_MIPMAPS] is usually more appropriate.
2020-02-12 08:59:06 +00:00
</constant>
<constant name= "TEXTURE_FILTER_MAX" value= "7" enum= "TextureFilter" >
2020-03-03 18:21:21 +00:00
Represents the size of the [enum TextureFilter] enum.
2020-02-12 08:59:06 +00:00
</constant>
<constant name= "TEXTURE_REPEAT_PARENT_NODE" value= "0" enum= "TextureRepeat" >
2020-03-03 18:21:21 +00:00
The [CanvasItem] will inherit the filter from its parent.
2020-02-12 08:59:06 +00:00
</constant>
<constant name= "TEXTURE_REPEAT_DISABLED" value= "1" enum= "TextureRepeat" >
2020-03-03 18:21:21 +00:00
Texture will not repeat.
2020-02-12 08:59:06 +00:00
</constant>
<constant name= "TEXTURE_REPEAT_ENABLED" value= "2" enum= "TextureRepeat" >
2020-03-03 18:21:21 +00:00
Texture will repeat normally.
2020-02-12 08:59:06 +00:00
</constant>
<constant name= "TEXTURE_REPEAT_MIRROR" value= "3" enum= "TextureRepeat" >
2020-03-03 18:21:21 +00:00
Texture will repeat in a 2x2 tiled mode, where elements at even positions are mirrored.
2020-02-12 08:59:06 +00:00
</constant>
<constant name= "TEXTURE_REPEAT_MAX" value= "4" enum= "TextureRepeat" >
2020-03-03 18:21:21 +00:00
Represents the size of the [enum TextureRepeat] enum.
2020-02-12 08:59:06 +00:00
</constant>
2017-09-12 20:42:36 +00:00
</constants>
</class>