class_canvasitem.rst 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the CanvasItem.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_CanvasItem:
  5. CanvasItem
  6. ==========
  7. **Inherits:** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Inherited By:** :ref:`Node2D<class_node2d>`, :ref:`Control<class_control>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Base class of anything 2D.
  13. Member Functions
  14. ----------------
  15. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`_draw<class_CanvasItem__draw>` **(** **)** virtual |
  17. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`float<class_float>` | :ref:`draw_char<class_CanvasItem_draw_char>` **(** :ref:`Font<class_font>` font, :ref:`Vector2<class_vector2>` position, :ref:`String<class_string>` char, :ref:`String<class_string>` next, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ) **)** |
  19. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`draw_circle<class_CanvasItem_draw_circle>` **(** :ref:`Vector2<class_vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_color>` color **)** |
  21. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`draw_colored_polygon<class_CanvasItem_draw_colored_polygon>` **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`Color<class_color>` color, :ref:`PoolVector2Array<class_poolvector2array>` uvs=PoolVector2Array( ), :ref:`Texture<class_texture>` texture=null, :ref:`Texture<class_texture>` normal_map=null, :ref:`bool<class_bool>` antialiased=false **)** |
  23. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`draw_line<class_CanvasItem_draw_line>` **(** :ref:`Vector2<class_vector2>` from, :ref:`Vector2<class_vector2>` to, :ref:`Color<class_color>` color, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)** |
  25. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`draw_multiline<class_CanvasItem_draw_multiline>` **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`Color<class_color>` color, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)** |
  27. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`draw_multiline_colors<class_CanvasItem_draw_multiline_colors>` **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`PoolColorArray<class_poolcolorarray>` colors, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)** |
  29. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`draw_polygon<class_CanvasItem_draw_polygon>` **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`PoolColorArray<class_poolcolorarray>` colors, :ref:`PoolVector2Array<class_poolvector2array>` uvs=PoolVector2Array( ), :ref:`Texture<class_texture>` texture=null, :ref:`Texture<class_texture>` normal_map=null, :ref:`bool<class_bool>` antialiased=false **)** |
  31. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`draw_polyline<class_CanvasItem_draw_polyline>` **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`Color<class_color>` color, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)** |
  33. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`draw_polyline_colors<class_CanvasItem_draw_polyline_colors>` **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`PoolColorArray<class_poolcolorarray>` colors, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)** |
  35. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`draw_primitive<class_CanvasItem_draw_primitive>` **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`PoolColorArray<class_poolcolorarray>` colors, :ref:`PoolVector2Array<class_poolvector2array>` uvs, :ref:`Texture<class_texture>` texture=null, :ref:`float<class_float>` width=1.0, :ref:`Texture<class_texture>` normal_map=null **)** |
  37. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`draw_rect<class_CanvasItem_draw_rect>` **(** :ref:`Rect2<class_rect2>` rect, :ref:`Color<class_color>` color, :ref:`bool<class_bool>` filled=true **)** |
  39. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`draw_set_transform<class_CanvasItem_draw_set_transform>` **(** :ref:`Vector2<class_vector2>` position, :ref:`float<class_float>` rotation, :ref:`Vector2<class_vector2>` scale **)** |
  41. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`draw_set_transform_matrix<class_CanvasItem_draw_set_transform_matrix>` **(** :ref:`Transform2D<class_transform2d>` xform **)** |
  43. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`draw_string<class_CanvasItem_draw_string>` **(** :ref:`Font<class_font>` font, :ref:`Vector2<class_vector2>` position, :ref:`String<class_string>` text, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`int<class_int>` clip_w=-1 **)** |
  45. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`draw_style_box<class_CanvasItem_draw_style_box>` **(** :ref:`StyleBox<class_stylebox>` style_box, :ref:`Rect2<class_rect2>` rect **)** |
  47. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`draw_texture<class_CanvasItem_draw_texture>` **(** :ref:`Texture<class_texture>` texture, :ref:`Vector2<class_vector2>` position, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`Texture<class_texture>` normal_map=null **)** |
  49. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`draw_texture_rect<class_CanvasItem_draw_texture_rect>` **(** :ref:`Texture<class_texture>` texture, :ref:`Rect2<class_rect2>` rect, :ref:`bool<class_bool>` tile, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_texture>` normal_map=null **)** |
  51. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`draw_texture_rect_region<class_CanvasItem_draw_texture_rect_region>` **(** :ref:`Texture<class_texture>` texture, :ref:`Rect2<class_rect2>` rect, :ref:`Rect2<class_rect2>` src_rect, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_texture>` normal_map=null, :ref:`bool<class_bool>` clip_uv=true **)** |
  53. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`RID<class_rid>` | :ref:`get_canvas<class_CanvasItem_get_canvas>` **(** **)** const |
  55. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`RID<class_rid>` | :ref:`get_canvas_item<class_CanvasItem_get_canvas_item>` **(** **)** const |
  57. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Transform2D<class_transform2d>` | :ref:`get_canvas_transform<class_CanvasItem_get_canvas_transform>` **(** **)** const |
  59. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Vector2<class_vector2>` | :ref:`get_global_mouse_position<class_CanvasItem_get_global_mouse_position>` **(** **)** const |
  61. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Transform2D<class_transform2d>` | :ref:`get_global_transform<class_CanvasItem_get_global_transform>` **(** **)** const |
  63. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`Transform2D<class_transform2d>` | :ref:`get_global_transform_with_canvas<class_CanvasItem_get_global_transform_with_canvas>` **(** **)** const |
  65. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Vector2<class_vector2>` | :ref:`get_local_mouse_position<class_CanvasItem_get_local_mouse_position>` **(** **)** const |
  67. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`Transform2D<class_transform2d>` | :ref:`get_transform<class_CanvasItem_get_transform>` **(** **)** const |
  69. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`Rect2<class_rect2>` | :ref:`get_viewport_rect<class_CanvasItem_get_viewport_rect>` **(** **)** const |
  71. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`Transform2D<class_transform2d>` | :ref:`get_viewport_transform<class_CanvasItem_get_viewport_transform>` **(** **)** const |
  73. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`World2D<class_world2d>` | :ref:`get_world_2d<class_CanvasItem_get_world_2d>` **(** **)** const |
  75. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`hide<class_CanvasItem_hide>` **(** **)** |
  77. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`bool<class_bool>` | :ref:`is_local_transform_notification_enabled<class_CanvasItem_is_local_transform_notification_enabled>` **(** **)** const |
  79. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`bool<class_bool>` | :ref:`is_set_as_toplevel<class_CanvasItem_is_set_as_toplevel>` **(** **)** const |
  81. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`bool<class_bool>` | :ref:`is_transform_notification_enabled<class_CanvasItem_is_transform_notification_enabled>` **(** **)** const |
  83. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`bool<class_bool>` | :ref:`is_visible_in_tree<class_CanvasItem_is_visible_in_tree>` **(** **)** const |
  85. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`Vector2<class_vector2>` | :ref:`make_canvas_position_local<class_CanvasItem_make_canvas_position_local>` **(** :ref:`Vector2<class_vector2>` screen_point **)** const |
  87. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`InputEvent<class_inputevent>` | :ref:`make_input_local<class_CanvasItem_make_input_local>` **(** :ref:`InputEvent<class_inputevent>` event **)** const |
  89. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | void | :ref:`set_as_toplevel<class_CanvasItem_set_as_toplevel>` **(** :ref:`bool<class_bool>` enable **)** |
  91. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | void | :ref:`set_notify_local_transform<class_CanvasItem_set_notify_local_transform>` **(** :ref:`bool<class_bool>` enable **)** |
  93. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | void | :ref:`set_notify_transform<class_CanvasItem_set_notify_transform>` **(** :ref:`bool<class_bool>` enable **)** |
  95. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | void | :ref:`show<class_CanvasItem_show>` **(** **)** |
  97. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | void | :ref:`update<class_CanvasItem_update>` **(** **)** |
  99. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. Signals
  101. -------
  102. .. _class_CanvasItem_draw:
  103. - **draw** **(** **)**
  104. Emitted when the CanvasItem must redraw. This can only be connected realtime, as deferred will not allow drawing.
  105. .. _class_CanvasItem_hide:
  106. - **hide** **(** **)**
  107. Emitted when becoming hidden.
  108. .. _class_CanvasItem_item_rect_changed:
  109. - **item_rect_changed** **(** **)**
  110. Emitted when the item rect has changed.
  111. .. _class_CanvasItem_visibility_changed:
  112. - **visibility_changed** **(** **)**
  113. Emitted when the visibility (hidden/visible) changes.
  114. Member Variables
  115. ----------------
  116. .. _class_CanvasItem_light_mask:
  117. - :ref:`int<class_int>` **light_mask** - The rendering layers in which this ``CanvasItem`` responds to :ref:`Light2D<class_light2d>` nodes. Default value: ``1``.
  118. .. _class_CanvasItem_material:
  119. - :ref:`Material<class_material>` **material** - The material applied to textures on this ``CanvasItem``. Default value: ``null``.
  120. .. _class_CanvasItem_modulate:
  121. - :ref:`Color<class_color>` **modulate** - The color applied to textures on this ``CanvasItem``. Default value: ``Color(1, 1, 1, 1)`` (opaque "white").
  122. .. _class_CanvasItem_self_modulate:
  123. - :ref:`Color<class_color>` **self_modulate** - The color applied to textures on this ``CanvasItem``. This is not inherited by children ``CanvasItem``\ s. Default value: ``Color(1, 1, 1, 1)`` (opaque "white")..
  124. .. _class_CanvasItem_show_behind_parent:
  125. - :ref:`bool<class_bool>` **show_behind_parent** - If ``true`` the object draws behind its parent. Default value: ``false``.
  126. .. _class_CanvasItem_show_on_top:
  127. - :ref:`bool<class_bool>` **show_on_top** - If ``true`` the object draws on top of its parent. Default value: ``true``.
  128. .. _class_CanvasItem_use_parent_material:
  129. - :ref:`bool<class_bool>` **use_parent_material** - If ``true`` the parent ``CanvasItem``'s :ref:`material<class_CanvasItem_material>` property is used as this one's material. Default value: ``false``.
  130. .. _class_CanvasItem_visible:
  131. - :ref:`bool<class_bool>` **visible** - If ``true`` this ``CanvasItem`` is drawn. Default value: ``true``.
  132. Numeric Constants
  133. -----------------
  134. - **NOTIFICATION_TRANSFORM_CHANGED** = **29** --- Canvas item transform has changed. Only received if requested.
  135. - **NOTIFICATION_DRAW** = **30** --- CanvasItem is requested to draw.
  136. - **NOTIFICATION_VISIBILITY_CHANGED** = **31** --- Canvas item visibility has changed.
  137. - **NOTIFICATION_ENTER_CANVAS** = **32** --- Canvas item has entered the canvas.
  138. - **NOTIFICATION_EXIT_CANVAS** = **33** --- Canvas item has exited the canvas.
  139. Enums
  140. -----
  141. .. _enum_CanvasItem_BlendMode:
  142. enum **BlendMode**
  143. - **BLEND_MODE_MIX** = **0** --- Mix blending mode. Colors are assumed to be independent of the alpha (opacity) value.
  144. - **BLEND_MODE_ADD** = **1** --- Additive blending mode.
  145. - **BLEND_MODE_SUB** = **2** --- Subtractive blending mode.
  146. - **BLEND_MODE_MUL** = **3** --- Multiplicative blending mode.
  147. - **BLEND_MODE_PREMULT_ALPHA** = **4** --- Mix blending mode. Colors are assumed to be premultiplied by the alpha (opacity) value.
  148. Description
  149. -----------
  150. Base class of anything 2D. Canvas items are laid out in a tree and children inherit and extend the transform of their parent. CanvasItem is extended by :ref:`Control<class_control>`, for anything GUI related, and by :ref:`Node2D<class_node2d>` for anything 2D engine related.
  151. Any CanvasItem can draw. For this, the "update" function must be called, then NOTIFICATION_DRAW will be received on idle time to request redraw. Because of this, canvas items don't need to be redraw on every frame, improving the performance significantly. Several functions for drawing on the CanvasItem are provided (see draw\_\* functions). They can only be used inside the notification, signal or _draw() overrides function, though.
  152. Canvas items are draw in tree order. By default, children are on top of their parents so a root CanvasItem will be drawn behind everything (this can be changed per item though).
  153. Canvas items can also be hidden (hiding also their subtree). They provide many means for changing standard parameters such as opacity (for it and the subtree) and self opacity, blend mode.
  154. Ultimately, a transform notification can be requested, which will notify the node that its global position changed in case the parent tree changed.
  155. Member Function Description
  156. ---------------------------
  157. .. _class_CanvasItem__draw:
  158. - void **_draw** **(** **)** virtual
  159. Called (if exists) to draw the canvas item.
  160. .. _class_CanvasItem_draw_char:
  161. - :ref:`float<class_float>` **draw_char** **(** :ref:`Font<class_font>` font, :ref:`Vector2<class_vector2>` position, :ref:`String<class_string>` char, :ref:`String<class_string>` next, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ) **)**
  162. Draws a string character using a custom font. Returns the advance, depending on the char width and kerning with an optional next char.
  163. .. _class_CanvasItem_draw_circle:
  164. - void **draw_circle** **(** :ref:`Vector2<class_vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_color>` color **)**
  165. Draws a colored circle.
  166. .. _class_CanvasItem_draw_colored_polygon:
  167. - void **draw_colored_polygon** **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`Color<class_color>` color, :ref:`PoolVector2Array<class_poolvector2array>` uvs=PoolVector2Array( ), :ref:`Texture<class_texture>` texture=null, :ref:`Texture<class_texture>` normal_map=null, :ref:`bool<class_bool>` antialiased=false **)**
  168. Draws a colored polygon of any amount of points, convex or concave.
  169. .. _class_CanvasItem_draw_line:
  170. - void **draw_line** **(** :ref:`Vector2<class_vector2>` from, :ref:`Vector2<class_vector2>` to, :ref:`Color<class_color>` color, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)**
  171. Draws a line from a 2D point to another, with a given color and width. It can be optionally antialiased.
  172. .. _class_CanvasItem_draw_multiline:
  173. - void **draw_multiline** **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`Color<class_color>` color, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)**
  174. Draws multiple, parallel lines with a uniform ``color`` and ``width`` and optional antialiasing.
  175. .. _class_CanvasItem_draw_multiline_colors:
  176. - void **draw_multiline_colors** **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`PoolColorArray<class_poolcolorarray>` colors, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)**
  177. Draws multiple, parallel lines with a uniform ``width``, segment-by-segment coloring, and optional antialiasing. Colors assigned to line segments match by index between ``points`` and ``colors``.
  178. .. _class_CanvasItem_draw_polygon:
  179. - void **draw_polygon** **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`PoolColorArray<class_poolcolorarray>` colors, :ref:`PoolVector2Array<class_poolvector2array>` uvs=PoolVector2Array( ), :ref:`Texture<class_texture>` texture=null, :ref:`Texture<class_texture>` normal_map=null, :ref:`bool<class_bool>` antialiased=false **)**
  180. Draws a polygon of any amount of points, convex or concave.
  181. .. _class_CanvasItem_draw_polyline:
  182. - void **draw_polyline** **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`Color<class_color>` color, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)**
  183. Draws interconnected line segments with a uniform ``color`` and ``width`` and optional antialiasing.
  184. .. _class_CanvasItem_draw_polyline_colors:
  185. - void **draw_polyline_colors** **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`PoolColorArray<class_poolcolorarray>` colors, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)**
  186. Draws interconnected line segments with a uniform ``width``, segment-by-segment coloring, and optional antialiasing. Colors assigned to line segments match by index between ``points`` and ``colors``.
  187. .. _class_CanvasItem_draw_primitive:
  188. - void **draw_primitive** **(** :ref:`PoolVector2Array<class_poolvector2array>` points, :ref:`PoolColorArray<class_poolcolorarray>` colors, :ref:`PoolVector2Array<class_poolvector2array>` uvs, :ref:`Texture<class_texture>` texture=null, :ref:`float<class_float>` width=1.0, :ref:`Texture<class_texture>` normal_map=null **)**
  189. 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.
  190. .. _class_CanvasItem_draw_rect:
  191. - void **draw_rect** **(** :ref:`Rect2<class_rect2>` rect, :ref:`Color<class_color>` color, :ref:`bool<class_bool>` filled=true **)**
  192. Draws a colored rectangle.
  193. .. _class_CanvasItem_draw_set_transform:
  194. - void **draw_set_transform** **(** :ref:`Vector2<class_vector2>` position, :ref:`float<class_float>` rotation, :ref:`Vector2<class_vector2>` scale **)**
  195. Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this.
  196. .. _class_CanvasItem_draw_set_transform_matrix:
  197. - void **draw_set_transform_matrix** **(** :ref:`Transform2D<class_transform2d>` xform **)**
  198. Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this.
  199. .. _class_CanvasItem_draw_string:
  200. - void **draw_string** **(** :ref:`Font<class_font>` font, :ref:`Vector2<class_vector2>` position, :ref:`String<class_string>` text, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`int<class_int>` clip_w=-1 **)**
  201. Draws a string using a custom font.
  202. .. _class_CanvasItem_draw_style_box:
  203. - void **draw_style_box** **(** :ref:`StyleBox<class_stylebox>` style_box, :ref:`Rect2<class_rect2>` rect **)**
  204. Draws a styled rectangle.
  205. .. _class_CanvasItem_draw_texture:
  206. - void **draw_texture** **(** :ref:`Texture<class_texture>` texture, :ref:`Vector2<class_vector2>` position, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`Texture<class_texture>` normal_map=null **)**
  207. Draws a texture at a given position.
  208. .. _class_CanvasItem_draw_texture_rect:
  209. - void **draw_texture_rect** **(** :ref:`Texture<class_texture>` texture, :ref:`Rect2<class_rect2>` rect, :ref:`bool<class_bool>` tile, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_texture>` normal_map=null **)**
  210. Draws a textured rectangle at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture.
  211. .. _class_CanvasItem_draw_texture_rect_region:
  212. - void **draw_texture_rect_region** **(** :ref:`Texture<class_texture>` texture, :ref:`Rect2<class_rect2>` rect, :ref:`Rect2<class_rect2>` src_rect, :ref:`Color<class_color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_texture>` normal_map=null, :ref:`bool<class_bool>` clip_uv=true **)**
  213. Draws a textured rectangle region at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture.
  214. .. _class_CanvasItem_get_canvas:
  215. - :ref:`RID<class_rid>` **get_canvas** **(** **)** const
  216. Return the :ref:`RID<class_rid>` of the :ref:`World2D<class_world2d>` canvas where this item is in.
  217. .. _class_CanvasItem_get_canvas_item:
  218. - :ref:`RID<class_rid>` **get_canvas_item** **(** **)** const
  219. Return the canvas item RID used by :ref:`VisualServer<class_visualserver>` for this item.
  220. .. _class_CanvasItem_get_canvas_transform:
  221. - :ref:`Transform2D<class_transform2d>` **get_canvas_transform** **(** **)** const
  222. Get the transform matrix of this item's canvas.
  223. .. _class_CanvasItem_get_global_mouse_position:
  224. - :ref:`Vector2<class_vector2>` **get_global_mouse_position** **(** **)** const
  225. Get the global position of the mouse.
  226. .. _class_CanvasItem_get_global_transform:
  227. - :ref:`Transform2D<class_transform2d>` **get_global_transform** **(** **)** const
  228. Get the global transform matrix of this item.
  229. .. _class_CanvasItem_get_global_transform_with_canvas:
  230. - :ref:`Transform2D<class_transform2d>` **get_global_transform_with_canvas** **(** **)** const
  231. Get the global transform matrix of this item in relation to the canvas.
  232. .. _class_CanvasItem_get_local_mouse_position:
  233. - :ref:`Vector2<class_vector2>` **get_local_mouse_position** **(** **)** const
  234. Get the mouse position relative to this item's position.
  235. .. _class_CanvasItem_get_transform:
  236. - :ref:`Transform2D<class_transform2d>` **get_transform** **(** **)** const
  237. Get the transform matrix of this item.
  238. .. _class_CanvasItem_get_viewport_rect:
  239. - :ref:`Rect2<class_rect2>` **get_viewport_rect** **(** **)** const
  240. Get the viewport's boundaries as a :ref:`Rect2<class_rect2>`.
  241. .. _class_CanvasItem_get_viewport_transform:
  242. - :ref:`Transform2D<class_transform2d>` **get_viewport_transform** **(** **)** const
  243. Get this item's transform in relation to the viewport.
  244. .. _class_CanvasItem_get_world_2d:
  245. - :ref:`World2D<class_world2d>` **get_world_2d** **(** **)** const
  246. Get the :ref:`World2D<class_world2d>` where this item is in.
  247. .. _class_CanvasItem_hide:
  248. - void **hide** **(** **)**
  249. Hide the CanvasItem currently visible.
  250. .. _class_CanvasItem_is_local_transform_notification_enabled:
  251. - :ref:`bool<class_bool>` **is_local_transform_notification_enabled** **(** **)** const
  252. Returns ``true`` if local transform notifications are communicated to children.
  253. .. _class_CanvasItem_is_set_as_toplevel:
  254. - :ref:`bool<class_bool>` **is_set_as_toplevel** **(** **)** const
  255. Return if set as toplevel. See :ref:`set_as_toplevel<class_CanvasItem_set_as_toplevel>`.
  256. .. _class_CanvasItem_is_transform_notification_enabled:
  257. - :ref:`bool<class_bool>` **is_transform_notification_enabled** **(** **)** const
  258. Returns ``true`` if global transform notifications are communicated to children.
  259. .. _class_CanvasItem_is_visible_in_tree:
  260. - :ref:`bool<class_bool>` **is_visible_in_tree** **(** **)** const
  261. Returns ``true`` if the node is present in the :ref:`SceneTree<class_scenetree>`, its :ref:`visible<class_CanvasItem_visible>` property is ``true`` and its inherited visibility is also ``true``.
  262. .. _class_CanvasItem_make_canvas_position_local:
  263. - :ref:`Vector2<class_vector2>` **make_canvas_position_local** **(** :ref:`Vector2<class_vector2>` screen_point **)** const
  264. Assigns ``screen_point`` as this node's new local transform.
  265. .. _class_CanvasItem_make_input_local:
  266. - :ref:`InputEvent<class_inputevent>` **make_input_local** **(** :ref:`InputEvent<class_inputevent>` event **)** const
  267. Transformations issued by ``event``'s inputs are applied in local space instead of global space.
  268. .. _class_CanvasItem_set_as_toplevel:
  269. - void **set_as_toplevel** **(** :ref:`bool<class_bool>` enable **)**
  270. Sets as top level. This means that it will not inherit transform from parent canvas items.
  271. .. _class_CanvasItem_set_notify_local_transform:
  272. - void **set_notify_local_transform** **(** :ref:`bool<class_bool>` enable **)**
  273. If ``enable`` is ``true``, children will be updated with local transform data.
  274. .. _class_CanvasItem_set_notify_transform:
  275. - void **set_notify_transform** **(** :ref:`bool<class_bool>` enable **)**
  276. If ``enable`` is ``true``, children will be updated with global transform data.
  277. .. _class_CanvasItem_show:
  278. - void **show** **(** **)**
  279. Show the CanvasItem currently hidden.
  280. .. _class_CanvasItem_update:
  281. - void **update** **(** **)**
  282. Queue the CanvasItem for update. ``NOTIFICATION_DRAW`` will be called on idle time to request redraw.