class_canvasitem.rst 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the CanvasItem.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_CanvasItem:
  6. CanvasItem
  7. ==========
  8. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`Control<class_Control>`, :ref:`Node2D<class_Node2D>`
  10. Base class of anything 2D.
  11. Description
  12. -----------
  13. 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 :ref:`Control<class_Control>` for anything GUI-related, and by :ref:`Node2D<class_Node2D>` for anything related to the 2D engine.
  14. Any ``CanvasItem`` can draw. For this, :ref:`update<class_CanvasItem_method_update>` must be called, then :ref:`NOTIFICATION_DRAW<class_CanvasItem_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 ``draw_*`` functions). However, they can only be used inside the :ref:`Object._notification<class_Object_method__notification>`, signal or :ref:`_draw<class_CanvasItem_method__draw>` virtual functions.
  15. 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.
  16. 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.
  17. Ultimately, a transform notification can be requested, which will notify the node that its global position changed in case the parent tree changed.
  18. Tutorials
  19. ---------
  20. - :doc:`../tutorials/2d/2d_transforms`
  21. - :doc:`../tutorials/2d/custom_drawing_in_2d`
  22. Properties
  23. ----------
  24. +-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
  25. | :ref:`int<class_int>` | :ref:`light_mask<class_CanvasItem_property_light_mask>` | ``1`` |
  26. +-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
  27. | :ref:`Material<class_Material>` | :ref:`material<class_CanvasItem_property_material>` | |
  28. +-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
  29. | :ref:`Color<class_Color>` | :ref:`modulate<class_CanvasItem_property_modulate>` | ``Color( 1, 1, 1, 1 )`` |
  30. +-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
  31. | :ref:`Color<class_Color>` | :ref:`self_modulate<class_CanvasItem_property_self_modulate>` | ``Color( 1, 1, 1, 1 )`` |
  32. +-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
  33. | :ref:`bool<class_bool>` | :ref:`show_behind_parent<class_CanvasItem_property_show_behind_parent>` | ``false`` |
  34. +-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`show_on_top<class_CanvasItem_property_show_on_top>` | |
  36. +-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
  37. | :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` | :ref:`texture_filter<class_CanvasItem_property_texture_filter>` | ``0`` |
  38. +-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
  39. | :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` | :ref:`texture_repeat<class_CanvasItem_property_texture_repeat>` | ``0`` |
  40. +-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
  41. | :ref:`bool<class_bool>` | :ref:`use_parent_material<class_CanvasItem_property_use_parent_material>` | ``false`` |
  42. +-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`visible<class_CanvasItem_property_visible>` | ``true`` |
  44. +-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
  45. Methods
  46. -------
  47. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`_draw<class_CanvasItem_method__draw>` **(** **)** virtual |
  49. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`draw_arc<class_CanvasItem_method_draw_arc>` **(** :ref:`Vector2<class_Vector2>` center, :ref:`float<class_float>` radius, :ref:`float<class_float>` start_angle, :ref:`float<class_float>` end_angle, :ref:`int<class_int>` point_count, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0 **)** |
  51. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`float<class_float>` | :ref:`draw_char<class_CanvasItem_method_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 ) **)** |
  53. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`draw_circle<class_CanvasItem_method_draw_circle>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_Color>` color **)** |
  55. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`draw_colored_polygon<class_CanvasItem_method_draw_colored_polygon>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs=PackedVector2Array( ), :ref:`Texture2D<class_Texture2D>` texture=null, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
  57. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`draw_line<class_CanvasItem_method_draw_line>` **(** :ref:`Vector2<class_Vector2>` from, :ref:`Vector2<class_Vector2>` to, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0 **)** |
  59. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`draw_mesh<class_CanvasItem_method_draw_mesh>` **(** :ref:`Mesh<class_Mesh>` mesh, :ref:`Texture2D<class_Texture2D>` texture, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`Transform2D<class_Transform2D>` transform=Transform2D( 1, 0, 0, 1, 0, 0 ), :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
  61. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`draw_multiline<class_CanvasItem_method_draw_multiline>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0 **)** |
  63. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`draw_multiline_colors<class_CanvasItem_method_draw_multiline_colors>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`float<class_float>` width=1.0 **)** |
  65. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`draw_multimesh<class_CanvasItem_method_draw_multimesh>` **(** :ref:`MultiMesh<class_MultiMesh>` multimesh, :ref:`Texture2D<class_Texture2D>` texture, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
  67. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`draw_polygon<class_CanvasItem_method_draw_polygon>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs=PackedVector2Array( ), :ref:`Texture2D<class_Texture2D>` texture=null, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
  69. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`draw_polyline<class_CanvasItem_method_draw_polyline>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0 **)** |
  71. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`draw_polyline_colors<class_CanvasItem_method_draw_polyline_colors>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`float<class_float>` width=1.0 **)** |
  73. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | void | :ref:`draw_primitive<class_CanvasItem_method_draw_primitive>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs, :ref:`Texture2D<class_Texture2D>` texture=null, :ref:`float<class_float>` width=1.0, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
  75. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`draw_rect<class_CanvasItem_method_draw_rect>` **(** :ref:`Rect2<class_Rect2>` rect, :ref:`Color<class_Color>` color, :ref:`bool<class_bool>` filled=true, :ref:`float<class_float>` width=1.0 **)** |
  77. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`draw_set_transform<class_CanvasItem_method_draw_set_transform>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` rotation, :ref:`Vector2<class_Vector2>` scale **)** |
  79. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`draw_set_transform_matrix<class_CanvasItem_method_draw_set_transform_matrix>` **(** :ref:`Transform2D<class_Transform2D>` xform **)** |
  81. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | void | :ref:`draw_string<class_CanvasItem_method_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 **)** |
  83. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | void | :ref:`draw_style_box<class_CanvasItem_method_draw_style_box>` **(** :ref:`StyleBox<class_StyleBox>` style_box, :ref:`Rect2<class_Rect2>` rect **)** |
  85. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | void | :ref:`draw_texture<class_CanvasItem_method_draw_texture>` **(** :ref:`Texture2D<class_Texture2D>` texture, :ref:`Vector2<class_Vector2>` position, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
  87. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | void | :ref:`draw_texture_rect<class_CanvasItem_method_draw_texture_rect>` **(** :ref:`Texture2D<class_Texture2D>` 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:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
  89. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | void | :ref:`draw_texture_rect_region<class_CanvasItem_method_draw_texture_rect_region>` **(** :ref:`Texture2D<class_Texture2D>` 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:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` clip_uv=true, :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
  91. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | void | :ref:`force_update_transform<class_CanvasItem_method_force_update_transform>` **(** **)** |
  93. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`RID<class_RID>` | :ref:`get_canvas<class_CanvasItem_method_get_canvas>` **(** **)** const |
  95. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`RID<class_RID>` | :ref:`get_canvas_item<class_CanvasItem_method_get_canvas_item>` **(** **)** const |
  97. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_canvas_transform<class_CanvasItem_method_get_canvas_transform>` **(** **)** const |
  99. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`Vector2<class_Vector2>` | :ref:`get_global_mouse_position<class_CanvasItem_method_get_global_mouse_position>` **(** **)** const |
  101. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_global_transform<class_CanvasItem_method_get_global_transform>` **(** **)** const |
  103. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_global_transform_with_canvas<class_CanvasItem_method_get_global_transform_with_canvas>` **(** **)** const |
  105. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`Vector2<class_Vector2>` | :ref:`get_local_mouse_position<class_CanvasItem_method_get_local_mouse_position>` **(** **)** const |
  107. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_transform<class_CanvasItem_method_get_transform>` **(** **)** const |
  109. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`Rect2<class_Rect2>` | :ref:`get_viewport_rect<class_CanvasItem_method_get_viewport_rect>` **(** **)** const |
  111. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_viewport_transform<class_CanvasItem_method_get_viewport_transform>` **(** **)** const |
  113. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`World2D<class_World2D>` | :ref:`get_world_2d<class_CanvasItem_method_get_world_2d>` **(** **)** const |
  115. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | void | :ref:`hide<class_CanvasItem_method_hide>` **(** **)** |
  117. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`bool<class_bool>` | :ref:`is_local_transform_notification_enabled<class_CanvasItem_method_is_local_transform_notification_enabled>` **(** **)** const |
  119. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`bool<class_bool>` | :ref:`is_set_as_toplevel<class_CanvasItem_method_is_set_as_toplevel>` **(** **)** const |
  121. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`bool<class_bool>` | :ref:`is_transform_notification_enabled<class_CanvasItem_method_is_transform_notification_enabled>` **(** **)** const |
  123. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`bool<class_bool>` | :ref:`is_visible_in_tree<class_CanvasItem_method_is_visible_in_tree>` **(** **)** const |
  125. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`Vector2<class_Vector2>` | :ref:`make_canvas_position_local<class_CanvasItem_method_make_canvas_position_local>` **(** :ref:`Vector2<class_Vector2>` screen_point **)** const |
  127. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | :ref:`InputEvent<class_InputEvent>` | :ref:`make_input_local<class_CanvasItem_method_make_input_local>` **(** :ref:`InputEvent<class_InputEvent>` event **)** const |
  129. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | void | :ref:`set_as_toplevel<class_CanvasItem_method_set_as_toplevel>` **(** :ref:`bool<class_bool>` enable **)** |
  131. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | void | :ref:`set_notify_local_transform<class_CanvasItem_method_set_notify_local_transform>` **(** :ref:`bool<class_bool>` enable **)** |
  133. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | void | :ref:`set_notify_transform<class_CanvasItem_method_set_notify_transform>` **(** :ref:`bool<class_bool>` enable **)** |
  135. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | void | :ref:`show<class_CanvasItem_method_show>` **(** **)** |
  137. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | void | :ref:`update<class_CanvasItem_method_update>` **(** **)** |
  139. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. Signals
  141. -------
  142. .. _class_CanvasItem_signal_draw:
  143. - **draw** **(** **)**
  144. Emitted when the ``CanvasItem`` must redraw. This can only be connected realtime, as deferred will not allow drawing.
  145. ----
  146. .. _class_CanvasItem_signal_hide:
  147. - **hide** **(** **)**
  148. Emitted when becoming hidden.
  149. ----
  150. .. _class_CanvasItem_signal_item_rect_changed:
  151. - **item_rect_changed** **(** **)**
  152. Emitted when the item rect has changed.
  153. ----
  154. .. _class_CanvasItem_signal_visibility_changed:
  155. - **visibility_changed** **(** **)**
  156. Emitted when the visibility (hidden/visible) changes.
  157. Enumerations
  158. ------------
  159. .. _enum_CanvasItem_TextureFilter:
  160. .. _class_CanvasItem_constant_TEXTURE_FILTER_PARENT_NODE:
  161. .. _class_CanvasItem_constant_TEXTURE_FILTER_NEAREST:
  162. .. _class_CanvasItem_constant_TEXTURE_FILTER_LINEAR:
  163. .. _class_CanvasItem_constant_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS:
  164. .. _class_CanvasItem_constant_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS:
  165. .. _class_CanvasItem_constant_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC:
  166. .. _class_CanvasItem_constant_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC:
  167. .. _class_CanvasItem_constant_TEXTURE_FILTER_MAX:
  168. enum **TextureFilter**:
  169. - **TEXTURE_FILTER_PARENT_NODE** = **0** --- The ``CanvasItem`` will inherit the filter from its parent.
  170. - **TEXTURE_FILTER_NEAREST** = **1** --- The texture filter reads from the nearest pixel only. The simplest and fastest method of filtering. Useful for pixel art.
  171. - **TEXTURE_FILTER_LINEAR** = **2** --- The texture filter blends between the nearest four pixels. Use this for most cases where you want to avoid a pixelated style.
  172. - **TEXTURE_FILTER_NEAREST_WITH_MIPMAPS** = **3**
  173. - **TEXTURE_FILTER_LINEAR_WITH_MIPMAPS** = **4**
  174. - **TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC** = **5**
  175. - **TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC** = **6**
  176. - **TEXTURE_FILTER_MAX** = **7** --- Represents the size of the :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` enum.
  177. ----
  178. .. _enum_CanvasItem_TextureRepeat:
  179. .. _class_CanvasItem_constant_TEXTURE_REPEAT_PARENT_NODE:
  180. .. _class_CanvasItem_constant_TEXTURE_REPEAT_DISABLED:
  181. .. _class_CanvasItem_constant_TEXTURE_REPEAT_ENABLED:
  182. .. _class_CanvasItem_constant_TEXTURE_REPEAT_MIRROR:
  183. .. _class_CanvasItem_constant_TEXTURE_REPEAT_MAX:
  184. enum **TextureRepeat**:
  185. - **TEXTURE_REPEAT_PARENT_NODE** = **0** --- The ``CanvasItem`` will inherit the filter from its parent.
  186. - **TEXTURE_REPEAT_DISABLED** = **1** --- Texture will not repeat.
  187. - **TEXTURE_REPEAT_ENABLED** = **2** --- Texture will repeat normally.
  188. - **TEXTURE_REPEAT_MIRROR** = **3** --- Texture will repeat in a 2x2 tiled mode, where elements at even positions are mirrored.
  189. - **TEXTURE_REPEAT_MAX** = **4** --- Represents the size of the :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` enum.
  190. Constants
  191. ---------
  192. .. _class_CanvasItem_constant_NOTIFICATION_TRANSFORM_CHANGED:
  193. .. _class_CanvasItem_constant_NOTIFICATION_DRAW:
  194. .. _class_CanvasItem_constant_NOTIFICATION_VISIBILITY_CHANGED:
  195. .. _class_CanvasItem_constant_NOTIFICATION_ENTER_CANVAS:
  196. .. _class_CanvasItem_constant_NOTIFICATION_EXIT_CANVAS:
  197. - **NOTIFICATION_TRANSFORM_CHANGED** = **2000** --- The ``CanvasItem``'s transform has changed. This notification is only received if enabled by :ref:`set_notify_transform<class_CanvasItem_method_set_notify_transform>` or :ref:`set_notify_local_transform<class_CanvasItem_method_set_notify_local_transform>`.
  198. - **NOTIFICATION_DRAW** = **30** --- The ``CanvasItem`` is requested to draw.
  199. - **NOTIFICATION_VISIBILITY_CHANGED** = **31** --- The ``CanvasItem``'s visibility has changed.
  200. - **NOTIFICATION_ENTER_CANVAS** = **32** --- The ``CanvasItem`` has entered the canvas.
  201. - **NOTIFICATION_EXIT_CANVAS** = **33** --- The ``CanvasItem`` has exited the canvas.
  202. Property Descriptions
  203. ---------------------
  204. .. _class_CanvasItem_property_light_mask:
  205. - :ref:`int<class_int>` **light_mask**
  206. +-----------+-----------------------+
  207. | *Default* | ``1`` |
  208. +-----------+-----------------------+
  209. | *Setter* | set_light_mask(value) |
  210. +-----------+-----------------------+
  211. | *Getter* | get_light_mask() |
  212. +-----------+-----------------------+
  213. The rendering layers in which this ``CanvasItem`` responds to :ref:`Light2D<class_Light2D>` nodes.
  214. ----
  215. .. _class_CanvasItem_property_material:
  216. - :ref:`Material<class_Material>` **material**
  217. +----------+---------------------+
  218. | *Setter* | set_material(value) |
  219. +----------+---------------------+
  220. | *Getter* | get_material() |
  221. +----------+---------------------+
  222. The material applied to textures on this ``CanvasItem``.
  223. ----
  224. .. _class_CanvasItem_property_modulate:
  225. - :ref:`Color<class_Color>` **modulate**
  226. +-----------+-------------------------+
  227. | *Default* | ``Color( 1, 1, 1, 1 )`` |
  228. +-----------+-------------------------+
  229. | *Setter* | set_modulate(value) |
  230. +-----------+-------------------------+
  231. | *Getter* | get_modulate() |
  232. +-----------+-------------------------+
  233. The color applied to textures on this ``CanvasItem``.
  234. ----
  235. .. _class_CanvasItem_property_self_modulate:
  236. - :ref:`Color<class_Color>` **self_modulate**
  237. +-----------+--------------------------+
  238. | *Default* | ``Color( 1, 1, 1, 1 )`` |
  239. +-----------+--------------------------+
  240. | *Setter* | set_self_modulate(value) |
  241. +-----------+--------------------------+
  242. | *Getter* | get_self_modulate() |
  243. +-----------+--------------------------+
  244. The color applied to textures on this ``CanvasItem``. This is not inherited by children ``CanvasItem``\ s.
  245. ----
  246. .. _class_CanvasItem_property_show_behind_parent:
  247. - :ref:`bool<class_bool>` **show_behind_parent**
  248. +-----------+---------------------------------+
  249. | *Default* | ``false`` |
  250. +-----------+---------------------------------+
  251. | *Setter* | set_draw_behind_parent(value) |
  252. +-----------+---------------------------------+
  253. | *Getter* | is_draw_behind_parent_enabled() |
  254. +-----------+---------------------------------+
  255. If ``true``, the object draws behind its parent.
  256. ----
  257. .. _class_CanvasItem_property_show_on_top:
  258. - :ref:`bool<class_bool>` **show_on_top**
  259. If ``true``, the object draws on top of its parent.
  260. ----
  261. .. _class_CanvasItem_property_texture_filter:
  262. - :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **texture_filter**
  263. +-----------+---------------------------+
  264. | *Default* | ``0`` |
  265. +-----------+---------------------------+
  266. | *Setter* | set_texture_filter(value) |
  267. +-----------+---------------------------+
  268. | *Getter* | get_texture_filter() |
  269. +-----------+---------------------------+
  270. ----
  271. .. _class_CanvasItem_property_texture_repeat:
  272. - :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` **texture_repeat**
  273. +-----------+---------------------------+
  274. | *Default* | ``0`` |
  275. +-----------+---------------------------+
  276. | *Setter* | set_texture_repeat(value) |
  277. +-----------+---------------------------+
  278. | *Getter* | get_texture_repeat() |
  279. +-----------+---------------------------+
  280. ----
  281. .. _class_CanvasItem_property_use_parent_material:
  282. - :ref:`bool<class_bool>` **use_parent_material**
  283. +-----------+--------------------------------+
  284. | *Default* | ``false`` |
  285. +-----------+--------------------------------+
  286. | *Setter* | set_use_parent_material(value) |
  287. +-----------+--------------------------------+
  288. | *Getter* | get_use_parent_material() |
  289. +-----------+--------------------------------+
  290. If ``true``, the parent ``CanvasItem``'s :ref:`material<class_CanvasItem_property_material>` property is used as this one's material.
  291. ----
  292. .. _class_CanvasItem_property_visible:
  293. - :ref:`bool<class_bool>` **visible**
  294. +-----------+--------------------+
  295. | *Default* | ``true`` |
  296. +-----------+--------------------+
  297. | *Setter* | set_visible(value) |
  298. +-----------+--------------------+
  299. | *Getter* | is_visible() |
  300. +-----------+--------------------+
  301. If ``true``, this ``CanvasItem`` is drawn. For controls that inherit :ref:`Popup<class_Popup>`, the correct way to make them visible is to call one of the multiple ``popup*()`` functions instead.
  302. Method Descriptions
  303. -------------------
  304. .. _class_CanvasItem_method__draw:
  305. - void **_draw** **(** **)** virtual
  306. Overridable function called by the engine (if defined) to draw the canvas item.
  307. ----
  308. .. _class_CanvasItem_method_draw_arc:
  309. - void **draw_arc** **(** :ref:`Vector2<class_Vector2>` center, :ref:`float<class_float>` radius, :ref:`float<class_float>` start_angle, :ref:`float<class_float>` end_angle, :ref:`int<class_int>` point_count, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0 **)**
  310. Draws an arc between the given angles. The larger the value of ``point_count``, the smoother the curve.
  311. ----
  312. .. _class_CanvasItem_method_draw_char:
  313. - :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 ) **)**
  314. Draws a string character using a custom font. Returns the advance, depending on the character width and kerning with an optional next character.
  315. ----
  316. .. _class_CanvasItem_method_draw_circle:
  317. - void **draw_circle** **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_Color>` color **)**
  318. Draws a colored circle.
  319. ----
  320. .. _class_CanvasItem_method_draw_colored_polygon:
  321. - void **draw_colored_polygon** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs=PackedVector2Array( ), :ref:`Texture2D<class_Texture2D>` texture=null, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
  322. Draws a colored polygon of any amount of points, convex or concave.
  323. ----
  324. .. _class_CanvasItem_method_draw_line:
  325. - 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 **)**
  326. Draws a line from a 2D point to another, with a given color and width.
  327. ----
  328. .. _class_CanvasItem_method_draw_mesh:
  329. - void **draw_mesh** **(** :ref:`Mesh<class_Mesh>` mesh, :ref:`Texture2D<class_Texture2D>` texture, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`Transform2D<class_Transform2D>` transform=Transform2D( 1, 0, 0, 1, 0, 0 ), :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
  330. Draws a :ref:`Mesh<class_Mesh>` in 2D, using the provided texture. See :ref:`MeshInstance2D<class_MeshInstance2D>` for related documentation.
  331. ----
  332. .. _class_CanvasItem_method_draw_multiline:
  333. - void **draw_multiline** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0 **)**
  334. Draws multiple, parallel lines with a uniform ``color``.
  335. ----
  336. .. _class_CanvasItem_method_draw_multiline_colors:
  337. - void **draw_multiline_colors** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`float<class_float>` width=1.0 **)**
  338. Draws multiple, parallel lines with a uniform ``width`` and segment-by-segment coloring. Colors assigned to line segments match by index between ``points`` and ``colors``.
  339. ----
  340. .. _class_CanvasItem_method_draw_multimesh:
  341. - void **draw_multimesh** **(** :ref:`MultiMesh<class_MultiMesh>` multimesh, :ref:`Texture2D<class_Texture2D>` texture, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
  342. Draws a :ref:`MultiMesh<class_MultiMesh>` in 2D with the provided texture. See :ref:`MultiMeshInstance2D<class_MultiMeshInstance2D>` for related documentation.
  343. ----
  344. .. _class_CanvasItem_method_draw_polygon:
  345. - void **draw_polygon** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs=PackedVector2Array( ), :ref:`Texture2D<class_Texture2D>` texture=null, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
  346. Draws a polygon of any amount of points, convex or concave.
  347. ----
  348. .. _class_CanvasItem_method_draw_polyline:
  349. - void **draw_polyline** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0 **)**
  350. Draws interconnected line segments with a uniform ``color`` and ``width``.
  351. ----
  352. .. _class_CanvasItem_method_draw_polyline_colors:
  353. - void **draw_polyline_colors** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`float<class_float>` width=1.0 **)**
  354. Draws interconnected line segments with a uniform ``width`` and segment-by-segment coloring. Colors assigned to line segments match by index between ``points`` and ``colors``.
  355. ----
  356. .. _class_CanvasItem_method_draw_primitive:
  357. - void **draw_primitive** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs, :ref:`Texture2D<class_Texture2D>` texture=null, :ref:`float<class_float>` width=1.0, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
  358. 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.
  359. ----
  360. .. _class_CanvasItem_method_draw_rect:
  361. - void **draw_rect** **(** :ref:`Rect2<class_Rect2>` rect, :ref:`Color<class_Color>` color, :ref:`bool<class_bool>` filled=true, :ref:`float<class_float>` width=1.0 **)**
  362. Draws a rectangle. If ``filled`` is ``true``, the rectangle will be filled with the ``color`` specified. If ``filled`` is ``false``, the rectangle will be drawn as a stroke with the ``color`` and ``width`` specified.
  363. **Note:** ``width`` is only effective if ``filled`` is ``false``.
  364. ----
  365. .. _class_CanvasItem_method_draw_set_transform:
  366. - void **draw_set_transform** **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` rotation, :ref:`Vector2<class_Vector2>` scale **)**
  367. Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this.
  368. ----
  369. .. _class_CanvasItem_method_draw_set_transform_matrix:
  370. - void **draw_set_transform_matrix** **(** :ref:`Transform2D<class_Transform2D>` xform **)**
  371. Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this.
  372. ----
  373. .. _class_CanvasItem_method_draw_string:
  374. - 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 **)**
  375. Draws a string using a custom font.
  376. ----
  377. .. _class_CanvasItem_method_draw_style_box:
  378. - void **draw_style_box** **(** :ref:`StyleBox<class_StyleBox>` style_box, :ref:`Rect2<class_Rect2>` rect **)**
  379. Draws a styled rectangle.
  380. ----
  381. .. _class_CanvasItem_method_draw_texture:
  382. - void **draw_texture** **(** :ref:`Texture2D<class_Texture2D>` texture, :ref:`Vector2<class_Vector2>` position, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
  383. Draws a texture at a given position.
  384. ----
  385. .. _class_CanvasItem_method_draw_texture_rect:
  386. - void **draw_texture_rect** **(** :ref:`Texture2D<class_Texture2D>` 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:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
  387. Draws a textured rectangle at a given position, optionally modulated by a color. If ``transpose`` is ``true``, the texture will have its X and Y coordinates swapped.
  388. ----
  389. .. _class_CanvasItem_method_draw_texture_rect_region:
  390. - void **draw_texture_rect_region** **(** :ref:`Texture2D<class_Texture2D>` 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:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` clip_uv=true, :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
  391. Draws a textured rectangle region at a given position, optionally modulated by a color. If ``transpose`` is ``true``, the texture will have its X and Y coordinates swapped.
  392. ----
  393. .. _class_CanvasItem_method_force_update_transform:
  394. - void **force_update_transform** **(** **)**
  395. 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.
  396. ----
  397. .. _class_CanvasItem_method_get_canvas:
  398. - :ref:`RID<class_RID>` **get_canvas** **(** **)** const
  399. Returns the :ref:`RID<class_RID>` of the :ref:`World2D<class_World2D>` canvas where this item is in.
  400. ----
  401. .. _class_CanvasItem_method_get_canvas_item:
  402. - :ref:`RID<class_RID>` **get_canvas_item** **(** **)** const
  403. Returns the canvas item RID used by :ref:`VisualServer<class_VisualServer>` for this item.
  404. ----
  405. .. _class_CanvasItem_method_get_canvas_transform:
  406. - :ref:`Transform2D<class_Transform2D>` **get_canvas_transform** **(** **)** const
  407. Returns the transform matrix of this item's canvas.
  408. ----
  409. .. _class_CanvasItem_method_get_global_mouse_position:
  410. - :ref:`Vector2<class_Vector2>` **get_global_mouse_position** **(** **)** const
  411. Returns the global position of the mouse.
  412. ----
  413. .. _class_CanvasItem_method_get_global_transform:
  414. - :ref:`Transform2D<class_Transform2D>` **get_global_transform** **(** **)** const
  415. Returns the global transform matrix of this item.
  416. ----
  417. .. _class_CanvasItem_method_get_global_transform_with_canvas:
  418. - :ref:`Transform2D<class_Transform2D>` **get_global_transform_with_canvas** **(** **)** const
  419. Returns the global transform matrix of this item in relation to the canvas.
  420. ----
  421. .. _class_CanvasItem_method_get_local_mouse_position:
  422. - :ref:`Vector2<class_Vector2>` **get_local_mouse_position** **(** **)** const
  423. Returns the mouse position relative to this item's position.
  424. ----
  425. .. _class_CanvasItem_method_get_transform:
  426. - :ref:`Transform2D<class_Transform2D>` **get_transform** **(** **)** const
  427. Returns the transform matrix of this item.
  428. ----
  429. .. _class_CanvasItem_method_get_viewport_rect:
  430. - :ref:`Rect2<class_Rect2>` **get_viewport_rect** **(** **)** const
  431. Returns the viewport's boundaries as a :ref:`Rect2<class_Rect2>`.
  432. ----
  433. .. _class_CanvasItem_method_get_viewport_transform:
  434. - :ref:`Transform2D<class_Transform2D>` **get_viewport_transform** **(** **)** const
  435. Returns this item's transform in relation to the viewport.
  436. ----
  437. .. _class_CanvasItem_method_get_world_2d:
  438. - :ref:`World2D<class_World2D>` **get_world_2d** **(** **)** const
  439. Returns the :ref:`World2D<class_World2D>` where this item is in.
  440. ----
  441. .. _class_CanvasItem_method_hide:
  442. - void **hide** **(** **)**
  443. Hide the ``CanvasItem`` if it's currently visible.
  444. ----
  445. .. _class_CanvasItem_method_is_local_transform_notification_enabled:
  446. - :ref:`bool<class_bool>` **is_local_transform_notification_enabled** **(** **)** const
  447. Returns ``true`` if local transform notifications are communicated to children.
  448. ----
  449. .. _class_CanvasItem_method_is_set_as_toplevel:
  450. - :ref:`bool<class_bool>` **is_set_as_toplevel** **(** **)** const
  451. Returns ``true`` if the node is set as top-level. See :ref:`set_as_toplevel<class_CanvasItem_method_set_as_toplevel>`.
  452. ----
  453. .. _class_CanvasItem_method_is_transform_notification_enabled:
  454. - :ref:`bool<class_bool>` **is_transform_notification_enabled** **(** **)** const
  455. Returns ``true`` if global transform notifications are communicated to children.
  456. ----
  457. .. _class_CanvasItem_method_is_visible_in_tree:
  458. - :ref:`bool<class_bool>` **is_visible_in_tree** **(** **)** const
  459. Returns ``true`` if the node is present in the :ref:`SceneTree<class_SceneTree>`, its :ref:`visible<class_CanvasItem_property_visible>` property is ``true`` and its inherited visibility is also ``true``.
  460. ----
  461. .. _class_CanvasItem_method_make_canvas_position_local:
  462. - :ref:`Vector2<class_Vector2>` **make_canvas_position_local** **(** :ref:`Vector2<class_Vector2>` screen_point **)** const
  463. Assigns ``screen_point`` as this node's new local transform.
  464. ----
  465. .. _class_CanvasItem_method_make_input_local:
  466. - :ref:`InputEvent<class_InputEvent>` **make_input_local** **(** :ref:`InputEvent<class_InputEvent>` event **)** const
  467. Transformations issued by ``event``'s inputs are applied in local space instead of global space.
  468. ----
  469. .. _class_CanvasItem_method_set_as_toplevel:
  470. - void **set_as_toplevel** **(** :ref:`bool<class_bool>` enable **)**
  471. If ``enable`` is ``true``, the node won't inherit its transform from parent canvas items.
  472. ----
  473. .. _class_CanvasItem_method_set_notify_local_transform:
  474. - void **set_notify_local_transform** **(** :ref:`bool<class_bool>` enable **)**
  475. If ``enable`` is ``true``, children will be updated with local transform data.
  476. ----
  477. .. _class_CanvasItem_method_set_notify_transform:
  478. - void **set_notify_transform** **(** :ref:`bool<class_bool>` enable **)**
  479. If ``enable`` is ``true``, children will be updated with global transform data.
  480. ----
  481. .. _class_CanvasItem_method_show:
  482. - void **show** **(** **)**
  483. Show the ``CanvasItem`` if it's currently hidden. For controls that inherit :ref:`Popup<class_Popup>`, the correct way to make them visible is to call one of the multiple ``popup*()`` functions instead.
  484. ----
  485. .. _class_CanvasItem_method_update:
  486. - void **update** **(** **)**
  487. Queue the ``CanvasItem`` for update. :ref:`NOTIFICATION_DRAW<class_CanvasItem_constant_NOTIFICATION_DRAW>` will be called on idle time to request redraw.