class_canvasitem.rst 128 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/CanvasItem.xml.
  6. .. _class_CanvasItem:
  7. CanvasItem
  8. ==========
  9. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`Control<class_Control>`, :ref:`Node2D<class_Node2D>`
  11. Base class of anything 2D.
  12. Description
  13. -----------
  14. 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.
  15. Any ``CanvasItem`` can draw. For this, :ref:`queue_redraw<class_CanvasItem_method_queue_redraw>` is called by the engine, 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 :ref:`_draw<class_CanvasItem_method__draw>`, its corresponding :ref:`Object._notification<class_Object_method__notification>` or methods connected to the :ref:`draw<class_CanvasItem_signal_draw>` signal.
  16. 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.
  17. 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.
  18. Ultimately, a transform notification can be requested, which will notify the node that its global position changed in case the parent tree changed.
  19. \ **Note:** Unless otherwise specified, all methods that have angle parameters must have angles specified as *radians*. To convert degrees to radians, use :ref:`@GlobalScope.deg_to_rad<class_@GlobalScope_method_deg_to_rad>`.
  20. Tutorials
  21. ---------
  22. - :doc:`Viewport and canvas transforms <../tutorials/2d/2d_transforms>`
  23. - :doc:`Custom drawing in 2D <../tutorials/2d/custom_drawing_in_2d>`
  24. - `Audio Spectrum Demo <https://godotengine.org/asset-library/asset/528>`__
  25. Properties
  26. ----------
  27. +-----------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  28. | :ref:`bool<class_bool>` | :ref:`clip_children<class_CanvasItem_property_clip_children>` | ``false`` |
  29. +-----------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  30. | :ref:`int<class_int>` | :ref:`light_mask<class_CanvasItem_property_light_mask>` | ``1`` |
  31. +-----------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  32. | :ref:`Material<class_Material>` | :ref:`material<class_CanvasItem_property_material>` | |
  33. +-----------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  34. | :ref:`Color<class_Color>` | :ref:`modulate<class_CanvasItem_property_modulate>` | ``Color(1, 1, 1, 1)`` |
  35. +-----------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  36. | :ref:`Color<class_Color>` | :ref:`self_modulate<class_CanvasItem_property_self_modulate>` | ``Color(1, 1, 1, 1)`` |
  37. +-----------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  38. | :ref:`bool<class_bool>` | :ref:`show_behind_parent<class_CanvasItem_property_show_behind_parent>` | ``false`` |
  39. +-----------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  40. | :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` | :ref:`texture_filter<class_CanvasItem_property_texture_filter>` | ``0`` |
  41. +-----------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  42. | :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` | :ref:`texture_repeat<class_CanvasItem_property_texture_repeat>` | ``0`` |
  43. +-----------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  44. | :ref:`bool<class_bool>` | :ref:`top_level<class_CanvasItem_property_top_level>` | ``false`` |
  45. +-----------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  46. | :ref:`bool<class_bool>` | :ref:`use_parent_material<class_CanvasItem_property_use_parent_material>` | ``false`` |
  47. +-----------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  48. | :ref:`bool<class_bool>` | :ref:`visible<class_CanvasItem_property_visible>` | ``true`` |
  49. +-----------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  50. Methods
  51. -------
  52. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`_draw<class_CanvasItem_method__draw>` **(** **)** |virtual| |
  54. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`draw_animation_slice<class_CanvasItem_method_draw_animation_slice>` **(** :ref:`float<class_float>` animation_length, :ref:`float<class_float>` slice_begin, :ref:`float<class_float>` slice_end, :ref:`float<class_float>` offset=0.0 **)** |
  56. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | 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, :ref:`bool<class_bool>` antialiased=false **)** |
  58. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`draw_char<class_CanvasItem_method_draw_char>` **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` char, :ref:`int<class_int>` font_size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1) **)** |const| |
  60. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`draw_char_outline<class_CanvasItem_method_draw_char_outline>` **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` char, :ref:`int<class_int>` font_size=16, :ref:`int<class_int>` size=-1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1) **)** |const| |
  62. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`draw_circle<class_CanvasItem_method_draw_circle>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_Color>` color **)** |
  64. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | 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 **)** |
  66. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`draw_dashed_line<class_CanvasItem_method_draw_dashed_line>` **(** :ref:`Vector2<class_Vector2>` from, :ref:`Vector2<class_Vector2>` to, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0, :ref:`float<class_float>` dash=2.0 **)** |
  68. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`draw_end_animation<class_CanvasItem_method_draw_end_animation>` **(** **)** |
  70. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`draw_lcd_texture_rect_region<class_CanvasItem_method_draw_lcd_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) **)** |
  72. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | 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, :ref:`bool<class_bool>` antialiased=false **)** |
  74. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | void | :ref:`draw_mesh<class_CanvasItem_method_draw_mesh>` **(** :ref:`Mesh<class_Mesh>` mesh, :ref:`Texture2D<class_Texture2D>` texture, :ref:`Transform2D<class_Transform2D>` transform=Transform2D(1, 0, 0, 1, 0, 0), :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1) **)** |
  76. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`draw_msdf_texture_rect_region<class_CanvasItem_method_draw_msdf_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:`float<class_float>` outline=0.0, :ref:`float<class_float>` pixel_range=4.0 **)** |
  78. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | 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 **)** |
  80. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | 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 **)** |
  82. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`draw_multiline_string<class_CanvasItem_method_draw_multiline_string>` **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` font_size=16, :ref:`int<class_int>` max_lines=-1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`LineBreakFlag<enum_TextServer_LineBreakFlag>` brk_flags=3, :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  84. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`draw_multiline_string_outline<class_CanvasItem_method_draw_multiline_string_outline>` **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` font_size=16, :ref:`int<class_int>` max_lines=-1, :ref:`int<class_int>` size=1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`LineBreakFlag<enum_TextServer_LineBreakFlag>` brk_flags=3, :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  86. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`draw_multimesh<class_CanvasItem_method_draw_multimesh>` **(** :ref:`MultiMesh<class_MultiMesh>` multimesh, :ref:`Texture2D<class_Texture2D>` texture **)** |
  88. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | 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 **)** |
  90. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | 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, :ref:`bool<class_bool>` antialiased=false **)** |
  92. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | 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, :ref:`bool<class_bool>` antialiased=false **)** |
  94. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | 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 **)** |
  96. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | 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 **)** |
  98. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`draw_set_transform<class_CanvasItem_method_draw_set_transform>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` rotation=0.0, :ref:`Vector2<class_Vector2>` scale=Vector2(1, 1) **)** |
  100. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | void | :ref:`draw_set_transform_matrix<class_CanvasItem_method_draw_set_transform_matrix>` **(** :ref:`Transform2D<class_Transform2D>` xform **)** |
  102. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | void | :ref:`draw_string<class_CanvasItem_method_draw_string>` **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` font_size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  104. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | void | :ref:`draw_string_outline<class_CanvasItem_method_draw_string_outline>` **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` font_size=16, :ref:`int<class_int>` size=1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  106. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | void | :ref:`draw_style_box<class_CanvasItem_method_draw_style_box>` **(** :ref:`StyleBox<class_StyleBox>` style_box, :ref:`Rect2<class_Rect2>` rect **)** |
  108. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | 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) **)** |
  110. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | 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 **)** |
  112. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | 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:`bool<class_bool>` clip_uv=true **)** |
  114. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | void | :ref:`force_update_transform<class_CanvasItem_method_force_update_transform>` **(** **)** |
  116. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | :ref:`RID<class_RID>` | :ref:`get_canvas<class_CanvasItem_method_get_canvas>` **(** **)** |const| |
  118. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | :ref:`RID<class_RID>` | :ref:`get_canvas_item<class_CanvasItem_method_get_canvas_item>` **(** **)** |const| |
  120. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_canvas_transform<class_CanvasItem_method_get_canvas_transform>` **(** **)** |const| |
  122. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | :ref:`Vector2<class_Vector2>` | :ref:`get_global_mouse_position<class_CanvasItem_method_get_global_mouse_position>` **(** **)** |const| |
  124. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_global_transform<class_CanvasItem_method_get_global_transform>` **(** **)** |const| |
  126. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_global_transform_with_canvas<class_CanvasItem_method_get_global_transform_with_canvas>` **(** **)** |const| |
  128. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | :ref:`Vector2<class_Vector2>` | :ref:`get_local_mouse_position<class_CanvasItem_method_get_local_mouse_position>` **(** **)** |const| |
  130. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_screen_transform<class_CanvasItem_method_get_screen_transform>` **(** **)** |const| |
  132. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_transform<class_CanvasItem_method_get_transform>` **(** **)** |const| |
  134. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | :ref:`Rect2<class_Rect2>` | :ref:`get_viewport_rect<class_CanvasItem_method_get_viewport_rect>` **(** **)** |const| |
  136. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_viewport_transform<class_CanvasItem_method_get_viewport_transform>` **(** **)** |const| |
  138. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | :ref:`World2D<class_World2D>` | :ref:`get_world_2d<class_CanvasItem_method_get_world_2d>` **(** **)** |const| |
  140. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | void | :ref:`hide<class_CanvasItem_method_hide>` **(** **)** |
  142. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | :ref:`bool<class_bool>` | :ref:`is_local_transform_notification_enabled<class_CanvasItem_method_is_local_transform_notification_enabled>` **(** **)** |const| |
  144. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | :ref:`bool<class_bool>` | :ref:`is_transform_notification_enabled<class_CanvasItem_method_is_transform_notification_enabled>` **(** **)** |const| |
  146. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. | :ref:`bool<class_bool>` | :ref:`is_visible_in_tree<class_CanvasItem_method_is_visible_in_tree>` **(** **)** |const| |
  148. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  149. | :ref:`Vector2<class_Vector2>` | :ref:`make_canvas_position_local<class_CanvasItem_method_make_canvas_position_local>` **(** :ref:`Vector2<class_Vector2>` screen_point **)** |const| |
  150. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  151. | :ref:`InputEvent<class_InputEvent>` | :ref:`make_input_local<class_CanvasItem_method_make_input_local>` **(** :ref:`InputEvent<class_InputEvent>` event **)** |const| |
  152. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  153. | void | :ref:`move_to_front<class_CanvasItem_method_move_to_front>` **(** **)** |
  154. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  155. | void | :ref:`queue_redraw<class_CanvasItem_method_queue_redraw>` **(** **)** |
  156. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  157. | void | :ref:`set_notify_local_transform<class_CanvasItem_method_set_notify_local_transform>` **(** :ref:`bool<class_bool>` enable **)** |
  158. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  159. | void | :ref:`set_notify_transform<class_CanvasItem_method_set_notify_transform>` **(** :ref:`bool<class_bool>` enable **)** |
  160. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  161. | void | :ref:`show<class_CanvasItem_method_show>` **(** **)** |
  162. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  163. Signals
  164. -------
  165. .. _class_CanvasItem_signal_draw:
  166. - **draw** **(** **)**
  167. Emitted when the ``CanvasItem`` must redraw, *after* the related :ref:`NOTIFICATION_DRAW<class_CanvasItem_constant_NOTIFICATION_DRAW>` notification, and *before* :ref:`_draw<class_CanvasItem_method__draw>` is called.
  168. \ **Note:** Deferred connections do not allow drawing through the ``draw_*`` methods.
  169. ----
  170. .. _class_CanvasItem_signal_hidden:
  171. - **hidden** **(** **)**
  172. Emitted when becoming hidden.
  173. ----
  174. .. _class_CanvasItem_signal_item_rect_changed:
  175. - **item_rect_changed** **(** **)**
  176. Emitted when the item's :ref:`Rect2<class_Rect2>` boundaries (position or size) have changed, or when an action is taking place that may have impacted these boundaries (e.g. changing :ref:`Sprite2D.texture<class_Sprite2D_property_texture>`).
  177. ----
  178. .. _class_CanvasItem_signal_visibility_changed:
  179. - **visibility_changed** **(** **)**
  180. Emitted when the visibility (hidden/visible) changes.
  181. Enumerations
  182. ------------
  183. .. _enum_CanvasItem_TextureFilter:
  184. .. _class_CanvasItem_constant_TEXTURE_FILTER_PARENT_NODE:
  185. .. _class_CanvasItem_constant_TEXTURE_FILTER_NEAREST:
  186. .. _class_CanvasItem_constant_TEXTURE_FILTER_LINEAR:
  187. .. _class_CanvasItem_constant_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS:
  188. .. _class_CanvasItem_constant_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS:
  189. .. _class_CanvasItem_constant_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC:
  190. .. _class_CanvasItem_constant_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC:
  191. .. _class_CanvasItem_constant_TEXTURE_FILTER_MAX:
  192. enum **TextureFilter**:
  193. - **TEXTURE_FILTER_PARENT_NODE** = **0** --- The ``CanvasItem`` will inherit the filter from its parent.
  194. - **TEXTURE_FILTER_NEAREST** = **1** --- The texture filter reads from the nearest pixel only. The simplest and fastest method of filtering. Useful for pixel art.
  195. - **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.
  196. - **TEXTURE_FILTER_NEAREST_WITH_MIPMAPS** = **3** --- The texture filter reads from the nearest pixel in the nearest mipmap. This is the fastest way to read from textures with mipmaps.
  197. - **TEXTURE_FILTER_LINEAR_WITH_MIPMAPS** = **4** --- The texture filter blends between the nearest 4 pixels and between the nearest 2 mipmaps. Use this for non-pixel art textures that may be viewed at a low scale (e.g. due to :ref:`Camera2D<class_Camera2D>` zoom), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels.
  198. - **TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC** = **5** --- The texture filter reads from the nearest pixel, but selects a mipmap based on the angle between the surface and the camera view. This reduces artifacts on surfaces that are almost in line with the camera. The anisotropic filtering level can be changed by adjusting :ref:`ProjectSettings.rendering/textures/default_filters/anisotropic_filtering_level<class_ProjectSettings_property_rendering/textures/default_filters/anisotropic_filtering_level>`.
  199. \ **Note:** This texture filter is rarely useful in 2D projects. :ref:`TEXTURE_FILTER_NEAREST_WITH_MIPMAPS<class_CanvasItem_constant_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS>` is usually more appropriate.
  200. - **TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC** = **6** --- The texture filter blends between the nearest 4 pixels and selects a mipmap based on the angle between the surface and the camera view. This reduces artifacts on surfaces that are almost in line with the camera. This is the slowest of the filtering options, but results in the highest quality texturing. The anisotropic filtering level can be changed by adjusting :ref:`ProjectSettings.rendering/textures/default_filters/anisotropic_filtering_level<class_ProjectSettings_property_rendering/textures/default_filters/anisotropic_filtering_level>`.
  201. \ **Note:** This texture filter is rarely useful in 2D projects. :ref:`TEXTURE_FILTER_LINEAR_WITH_MIPMAPS<class_CanvasItem_constant_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS>` is usually more appropriate.
  202. - **TEXTURE_FILTER_MAX** = **7** --- Represents the size of the :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` enum.
  203. ----
  204. .. _enum_CanvasItem_TextureRepeat:
  205. .. _class_CanvasItem_constant_TEXTURE_REPEAT_PARENT_NODE:
  206. .. _class_CanvasItem_constant_TEXTURE_REPEAT_DISABLED:
  207. .. _class_CanvasItem_constant_TEXTURE_REPEAT_ENABLED:
  208. .. _class_CanvasItem_constant_TEXTURE_REPEAT_MIRROR:
  209. .. _class_CanvasItem_constant_TEXTURE_REPEAT_MAX:
  210. enum **TextureRepeat**:
  211. - **TEXTURE_REPEAT_PARENT_NODE** = **0** --- The ``CanvasItem`` will inherit the filter from its parent.
  212. - **TEXTURE_REPEAT_DISABLED** = **1** --- Texture will not repeat.
  213. - **TEXTURE_REPEAT_ENABLED** = **2** --- Texture will repeat normally.
  214. - **TEXTURE_REPEAT_MIRROR** = **3** --- Texture will repeat in a 2x2 tiled mode, where elements at even positions are mirrored.
  215. - **TEXTURE_REPEAT_MAX** = **4** --- Represents the size of the :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` enum.
  216. Constants
  217. ---------
  218. .. _class_CanvasItem_constant_NOTIFICATION_TRANSFORM_CHANGED:
  219. .. _class_CanvasItem_constant_NOTIFICATION_LOCAL_TRANSFORM_CHANGED:
  220. .. _class_CanvasItem_constant_NOTIFICATION_DRAW:
  221. .. _class_CanvasItem_constant_NOTIFICATION_VISIBILITY_CHANGED:
  222. .. _class_CanvasItem_constant_NOTIFICATION_ENTER_CANVAS:
  223. .. _class_CanvasItem_constant_NOTIFICATION_EXIT_CANVAS:
  224. - **NOTIFICATION_TRANSFORM_CHANGED** = **2000** --- The ``CanvasItem``'s global transform has changed. This notification is only received if enabled by :ref:`set_notify_transform<class_CanvasItem_method_set_notify_transform>`.
  225. - **NOTIFICATION_LOCAL_TRANSFORM_CHANGED** = **35** --- The ``CanvasItem``'s local transform has changed. This notification is only received if enabled by :ref:`set_notify_local_transform<class_CanvasItem_method_set_notify_local_transform>`.
  226. - **NOTIFICATION_DRAW** = **30** --- The ``CanvasItem`` is requested to draw (see :ref:`_draw<class_CanvasItem_method__draw>`).
  227. - **NOTIFICATION_VISIBILITY_CHANGED** = **31** --- The ``CanvasItem``'s visibility has changed.
  228. - **NOTIFICATION_ENTER_CANVAS** = **32** --- The ``CanvasItem`` has entered the canvas.
  229. - **NOTIFICATION_EXIT_CANVAS** = **33** --- The ``CanvasItem`` has exited the canvas.
  230. Property Descriptions
  231. ---------------------
  232. .. _class_CanvasItem_property_clip_children:
  233. - :ref:`bool<class_bool>` **clip_children**
  234. +-----------+--------------------------+
  235. | *Default* | ``false`` |
  236. +-----------+--------------------------+
  237. | *Setter* | set_clip_children(value) |
  238. +-----------+--------------------------+
  239. | *Getter* | is_clipping_children() |
  240. +-----------+--------------------------+
  241. Allows the current node to clip children nodes, essentially acting as a mask.
  242. ----
  243. .. _class_CanvasItem_property_light_mask:
  244. - :ref:`int<class_int>` **light_mask**
  245. +-----------+-----------------------+
  246. | *Default* | ``1`` |
  247. +-----------+-----------------------+
  248. | *Setter* | set_light_mask(value) |
  249. +-----------+-----------------------+
  250. | *Getter* | get_light_mask() |
  251. +-----------+-----------------------+
  252. The rendering layers in which this ``CanvasItem`` responds to :ref:`Light2D<class_Light2D>` nodes.
  253. ----
  254. .. _class_CanvasItem_property_material:
  255. - :ref:`Material<class_Material>` **material**
  256. +----------+---------------------+
  257. | *Setter* | set_material(value) |
  258. +----------+---------------------+
  259. | *Getter* | get_material() |
  260. +----------+---------------------+
  261. The material applied to textures on this ``CanvasItem``.
  262. ----
  263. .. _class_CanvasItem_property_modulate:
  264. - :ref:`Color<class_Color>` **modulate**
  265. +-----------+-----------------------+
  266. | *Default* | ``Color(1, 1, 1, 1)`` |
  267. +-----------+-----------------------+
  268. | *Setter* | set_modulate(value) |
  269. +-----------+-----------------------+
  270. | *Getter* | get_modulate() |
  271. +-----------+-----------------------+
  272. The color applied to textures on this ``CanvasItem``.
  273. ----
  274. .. _class_CanvasItem_property_self_modulate:
  275. - :ref:`Color<class_Color>` **self_modulate**
  276. +-----------+--------------------------+
  277. | *Default* | ``Color(1, 1, 1, 1)`` |
  278. +-----------+--------------------------+
  279. | *Setter* | set_self_modulate(value) |
  280. +-----------+--------------------------+
  281. | *Getter* | get_self_modulate() |
  282. +-----------+--------------------------+
  283. The color applied to textures on this ``CanvasItem``. This is not inherited by children ``CanvasItem``\ s.
  284. ----
  285. .. _class_CanvasItem_property_show_behind_parent:
  286. - :ref:`bool<class_bool>` **show_behind_parent**
  287. +-----------+---------------------------------+
  288. | *Default* | ``false`` |
  289. +-----------+---------------------------------+
  290. | *Setter* | set_draw_behind_parent(value) |
  291. +-----------+---------------------------------+
  292. | *Getter* | is_draw_behind_parent_enabled() |
  293. +-----------+---------------------------------+
  294. If ``true``, the object draws behind its parent.
  295. ----
  296. .. _class_CanvasItem_property_texture_filter:
  297. - :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **texture_filter**
  298. +-----------+---------------------------+
  299. | *Default* | ``0`` |
  300. +-----------+---------------------------+
  301. | *Setter* | set_texture_filter(value) |
  302. +-----------+---------------------------+
  303. | *Getter* | get_texture_filter() |
  304. +-----------+---------------------------+
  305. The texture filtering mode to use on this ``CanvasItem``.
  306. ----
  307. .. _class_CanvasItem_property_texture_repeat:
  308. - :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` **texture_repeat**
  309. +-----------+---------------------------+
  310. | *Default* | ``0`` |
  311. +-----------+---------------------------+
  312. | *Setter* | set_texture_repeat(value) |
  313. +-----------+---------------------------+
  314. | *Getter* | get_texture_repeat() |
  315. +-----------+---------------------------+
  316. The texture repeating mode to use on this ``CanvasItem``.
  317. ----
  318. .. _class_CanvasItem_property_top_level:
  319. - :ref:`bool<class_bool>` **top_level**
  320. +-----------+-------------------------+
  321. | *Default* | ``false`` |
  322. +-----------+-------------------------+
  323. | *Setter* | set_as_top_level(value) |
  324. +-----------+-------------------------+
  325. | *Getter* | is_set_as_top_level() |
  326. +-----------+-------------------------+
  327. If ``true``, this ``CanvasItem`` will *not* inherit its transform from parent ``CanvasItem``\ s. Its draw order will also be changed to make it draw on top of other ``CanvasItem``\ s that do not have :ref:`top_level<class_CanvasItem_property_top_level>` set to ``true``. The ``CanvasItem`` will effectively act as if it was placed as a child of a bare :ref:`Node<class_Node>`.
  328. ----
  329. .. _class_CanvasItem_property_use_parent_material:
  330. - :ref:`bool<class_bool>` **use_parent_material**
  331. +-----------+--------------------------------+
  332. | *Default* | ``false`` |
  333. +-----------+--------------------------------+
  334. | *Setter* | set_use_parent_material(value) |
  335. +-----------+--------------------------------+
  336. | *Getter* | get_use_parent_material() |
  337. +-----------+--------------------------------+
  338. If ``true``, the parent ``CanvasItem``'s :ref:`material<class_CanvasItem_property_material>` property is used as this one's material.
  339. ----
  340. .. _class_CanvasItem_property_visible:
  341. - :ref:`bool<class_bool>` **visible**
  342. +-----------+--------------------+
  343. | *Default* | ``true`` |
  344. +-----------+--------------------+
  345. | *Setter* | set_visible(value) |
  346. +-----------+--------------------+
  347. | *Getter* | is_visible() |
  348. +-----------+--------------------+
  349. If ``true``, this ``CanvasItem`` is drawn. The node is only visible if all of its antecedents are visible as well (in other words, :ref:`is_visible_in_tree<class_CanvasItem_method_is_visible_in_tree>` must return ``true``).
  350. \ **Note:** 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.
  351. Method Descriptions
  352. -------------------
  353. .. _class_CanvasItem_method__draw:
  354. - void **_draw** **(** **)** |virtual|
  355. Called when ``CanvasItem`` has been requested to redraw (after :ref:`queue_redraw<class_CanvasItem_method_queue_redraw>` is called, either manually or by the engine).
  356. Corresponds to the :ref:`NOTIFICATION_DRAW<class_CanvasItem_constant_NOTIFICATION_DRAW>` notification in :ref:`Object._notification<class_Object_method__notification>`.
  357. ----
  358. .. _class_CanvasItem_method_draw_animation_slice:
  359. - void **draw_animation_slice** **(** :ref:`float<class_float>` animation_length, :ref:`float<class_float>` slice_begin, :ref:`float<class_float>` slice_end, :ref:`float<class_float>` offset=0.0 **)**
  360. Subsequent drawing commands will be ignored unless they fall within the specified animation slice. This is a faster way to implement animations that loop on background rather than redrawing constantly.
  361. ----
  362. .. _class_CanvasItem_method_draw_arc:
  363. - 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, :ref:`bool<class_bool>` antialiased=false **)**
  364. Draws a unfilled arc between the given angles. The larger the value of ``point_count``, the smoother the curve. See also :ref:`draw_circle<class_CanvasItem_method_draw_circle>`.
  365. ----
  366. .. _class_CanvasItem_method_draw_char:
  367. - void **draw_char** **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` char, :ref:`int<class_int>` font_size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1) **)** |const|
  368. Draws a string first character using a custom font.
  369. ----
  370. .. _class_CanvasItem_method_draw_char_outline:
  371. - void **draw_char_outline** **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` char, :ref:`int<class_int>` font_size=16, :ref:`int<class_int>` size=-1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1) **)** |const|
  372. Draws a string first character outline using a custom font.
  373. ----
  374. .. _class_CanvasItem_method_draw_circle:
  375. - void **draw_circle** **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_Color>` color **)**
  376. Draws a colored, filled circle. See also :ref:`draw_arc<class_CanvasItem_method_draw_arc>`, :ref:`draw_polyline<class_CanvasItem_method_draw_polyline>` and :ref:`draw_polygon<class_CanvasItem_method_draw_polygon>`.
  377. ----
  378. .. _class_CanvasItem_method_draw_colored_polygon:
  379. - 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 **)**
  380. Draws a colored polygon of any number of points, convex or concave. Unlike :ref:`draw_polygon<class_CanvasItem_method_draw_polygon>`, a single color must be specified for the whole polygon.
  381. ----
  382. .. _class_CanvasItem_method_draw_dashed_line:
  383. - void **draw_dashed_line** **(** :ref:`Vector2<class_Vector2>` from, :ref:`Vector2<class_Vector2>` to, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0, :ref:`float<class_float>` dash=2.0 **)**
  384. Draws a dashed line from a 2D point to another, with a given color and width. See also :ref:`draw_multiline<class_CanvasItem_method_draw_multiline>` and :ref:`draw_polyline<class_CanvasItem_method_draw_polyline>`.
  385. ----
  386. .. _class_CanvasItem_method_draw_end_animation:
  387. - void **draw_end_animation** **(** **)**
  388. After submitting all animations slices via :ref:`draw_animation_slice<class_CanvasItem_method_draw_animation_slice>`, this function can be used to revert drawing to its default state (all subsequent drawing commands will be visible). If you don't care about this particular use case, usage of this function after submitting the slices is not required.
  389. ----
  390. .. _class_CanvasItem_method_draw_lcd_texture_rect_region:
  391. - void **draw_lcd_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) **)**
  392. Draws a textured rectangle region of the font texture with LCD sub-pixel anti-aliasing at a given position, optionally modulated by a color.
  393. Texture is drawn using the following blend operation, blend mode of the :ref:`CanvasItemMaterial<class_CanvasItemMaterial>` is ignored:
  394. ::
  395. dst.r = texture.r * modulate.r * modulate.a + dst.r * (1.0 - texture.r * modulate.a);
  396. dst.g = texture.g * modulate.g * modulate.a + dst.g * (1.0 - texture.g * modulate.a);
  397. dst.b = texture.b * modulate.b * modulate.a + dst.b * (1.0 - texture.b * modulate.a);
  398. dst.a = modulate.a + dst.a * (1.0 - modulate.a);
  399. ----
  400. .. _class_CanvasItem_method_draw_line:
  401. - 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 **)**
  402. Draws a line from a 2D point to another, with a given color and width. It can be optionally antialiased. See also :ref:`draw_multiline<class_CanvasItem_method_draw_multiline>` and :ref:`draw_polyline<class_CanvasItem_method_draw_polyline>`.
  403. ----
  404. .. _class_CanvasItem_method_draw_mesh:
  405. - void **draw_mesh** **(** :ref:`Mesh<class_Mesh>` mesh, :ref:`Texture2D<class_Texture2D>` texture, :ref:`Transform2D<class_Transform2D>` transform=Transform2D(1, 0, 0, 1, 0, 0), :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1) **)**
  406. Draws a :ref:`Mesh<class_Mesh>` in 2D, using the provided texture. See :ref:`MeshInstance2D<class_MeshInstance2D>` for related documentation.
  407. ----
  408. .. _class_CanvasItem_method_draw_msdf_texture_rect_region:
  409. - void **draw_msdf_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:`float<class_float>` outline=0.0, :ref:`float<class_float>` pixel_range=4.0 **)**
  410. Draws a textured rectangle region of the multi-channel signed distance field texture at a given position, optionally modulated by a color. See :ref:`FontFile.multichannel_signed_distance_field<class_FontFile_property_multichannel_signed_distance_field>` for more information and caveats about MSDF font rendering.
  411. If ``outline`` is positive, each alpha channel value of pixel in region is set to maximum value of true distance in the ``outline`` radius.
  412. Value of the ``pixel_range`` should the same that was used during distance field texture generation.
  413. ----
  414. .. _class_CanvasItem_method_draw_multiline:
  415. - void **draw_multiline** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0 **)**
  416. Draws multiple disconnected lines with a uniform ``color``. When drawing large amounts of lines, this is faster than using individual :ref:`draw_line<class_CanvasItem_method_draw_line>` calls. To draw interconnected lines, use :ref:`draw_polyline<class_CanvasItem_method_draw_polyline>` instead.
  417. ----
  418. .. _class_CanvasItem_method_draw_multiline_colors:
  419. - void **draw_multiline_colors** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`float<class_float>` width=1.0 **)**
  420. Draws multiple disconnected lines with a uniform ``width`` and segment-by-segment coloring. Colors assigned to line segments match by index between ``points`` and ``colors``. When drawing large amounts of lines, this is faster than using individual :ref:`draw_line<class_CanvasItem_method_draw_line>` calls. To draw interconnected lines, use :ref:`draw_polyline_colors<class_CanvasItem_method_draw_polyline_colors>` instead.
  421. ----
  422. .. _class_CanvasItem_method_draw_multiline_string:
  423. - void **draw_multiline_string** **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` font_size=16, :ref:`int<class_int>` max_lines=-1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`LineBreakFlag<enum_TextServer_LineBreakFlag>` brk_flags=3, :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  424. Breaks ``text`` into lines and draws it using the specified ``font`` at the ``pos`` (top-left corner). The text will have its color multiplied by ``modulate``. If ``width`` is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
  425. ----
  426. .. _class_CanvasItem_method_draw_multiline_string_outline:
  427. - void **draw_multiline_string_outline** **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` font_size=16, :ref:`int<class_int>` max_lines=-1, :ref:`int<class_int>` size=1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`LineBreakFlag<enum_TextServer_LineBreakFlag>` brk_flags=3, :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  428. Breaks ``text`` to the lines and draws text outline using the specified ``font`` at the ``pos`` (top-left corner). The text will have its color multiplied by ``modulate``. If ``width`` is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
  429. ----
  430. .. _class_CanvasItem_method_draw_multimesh:
  431. - void **draw_multimesh** **(** :ref:`MultiMesh<class_MultiMesh>` multimesh, :ref:`Texture2D<class_Texture2D>` texture **)**
  432. Draws a :ref:`MultiMesh<class_MultiMesh>` in 2D with the provided texture. See :ref:`MultiMeshInstance2D<class_MultiMeshInstance2D>` for related documentation.
  433. ----
  434. .. _class_CanvasItem_method_draw_polygon:
  435. - 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 **)**
  436. Draws a solid polygon of any number of points, convex or concave. Unlike :ref:`draw_colored_polygon<class_CanvasItem_method_draw_colored_polygon>`, each point's color can be changed individually. See also :ref:`draw_polyline<class_CanvasItem_method_draw_polyline>` and :ref:`draw_polyline_colors<class_CanvasItem_method_draw_polyline_colors>`.
  437. ----
  438. .. _class_CanvasItem_method_draw_polyline:
  439. - void **draw_polyline** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)**
  440. Draws interconnected line segments with a uniform ``color`` and ``width`` and optional antialiasing. When drawing large amounts of lines, this is faster than using individual :ref:`draw_line<class_CanvasItem_method_draw_line>` calls. To draw disconnected lines, use :ref:`draw_multiline<class_CanvasItem_method_draw_multiline>` instead. See also :ref:`draw_polygon<class_CanvasItem_method_draw_polygon>`.
  441. ----
  442. .. _class_CanvasItem_method_draw_polyline_colors:
  443. - void **draw_polyline_colors** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)**
  444. Draws interconnected line segments with a uniform ``width`` and segment-by-segment coloring, and optional antialiasing. Colors assigned to line segments match by index between ``points`` and ``colors``. When drawing large amounts of lines, this is faster than using individual :ref:`draw_line<class_CanvasItem_method_draw_line>` calls. To draw disconnected lines, use :ref:`draw_multiline_colors<class_CanvasItem_method_draw_multiline_colors>` instead. See also :ref:`draw_polygon<class_CanvasItem_method_draw_polygon>`.
  445. ----
  446. .. _class_CanvasItem_method_draw_primitive:
  447. - 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 **)**
  448. Draws a custom primitive. 1 point for a point, 2 points for a line, 3 points for a triangle, and 4 points for a quad. If 0 points or more than 4 points are specified, nothing will be drawn and an error message will be printed. See also :ref:`draw_line<class_CanvasItem_method_draw_line>`, :ref:`draw_polyline<class_CanvasItem_method_draw_polyline>`, :ref:`draw_polygon<class_CanvasItem_method_draw_polygon>`, and :ref:`draw_rect<class_CanvasItem_method_draw_rect>`.
  449. ----
  450. .. _class_CanvasItem_method_draw_rect:
  451. - 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 **)**
  452. 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.
  453. \ **Note:** ``width`` is only effective if ``filled`` is ``false``.
  454. ----
  455. .. _class_CanvasItem_method_draw_set_transform:
  456. - void **draw_set_transform** **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` rotation=0.0, :ref:`Vector2<class_Vector2>` scale=Vector2(1, 1) **)**
  457. Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this.
  458. ----
  459. .. _class_CanvasItem_method_draw_set_transform_matrix:
  460. - void **draw_set_transform_matrix** **(** :ref:`Transform2D<class_Transform2D>` xform **)**
  461. Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this.
  462. ----
  463. .. _class_CanvasItem_method_draw_string:
  464. - void **draw_string** **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` font_size=16, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  465. Draws ``text`` using the specified ``font`` at the ``pos`` (bottom-left corner using the baseline of the font). The text will have its color multiplied by ``modulate``. If ``width`` is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
  466. \ **Example using the default project font:**\
  467. .. tabs::
  468. .. code-tab:: gdscript
  469. # If using this method in a script that redraws constantly, move the
  470. # `default_font` declaration to a member variable assigned in `_ready()`
  471. # so the Control is only created once.
  472. var default_font = ThemeDB.fallback_font
  473. var default_font_size = ThemeDB.fallback_font_size
  474. draw_string(default_font, Vector2(64, 64), "Hello world", HORIZONTAL_ALIGNMENT_LEFT, -1, default_font_size)
  475. .. code-tab:: csharp
  476. // If using this method in a script that redraws constantly, move the
  477. // `default_font` declaration to a member variable assigned in `_Ready()`
  478. // so the Control is only created once.
  479. Font defaultFont = ThemeDB.FallbackFont;
  480. int defaultFontSize = ThemeDB.FallbackFontSize;
  481. DrawString(defaultFont, new Vector2(64, 64), "Hello world", HORIZONTAL_ALIGNMENT_LEFT, -1, defaultFontSize);
  482. See also :ref:`Font.draw_string<class_Font_method_draw_string>`.
  483. ----
  484. .. _class_CanvasItem_method_draw_string_outline:
  485. - void **draw_string_outline** **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` pos, :ref:`String<class_String>` text, :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` alignment=0, :ref:`float<class_float>` width=-1, :ref:`int<class_int>` font_size=16, :ref:`int<class_int>` size=1, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1), :ref:`JustificationFlag<enum_TextServer_JustificationFlag>` jst_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  486. Draws ``text`` outline using the specified ``font`` at the ``pos`` (bottom-left corner using the baseline of the font). The text will have its color multiplied by ``modulate``. If ``width`` is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
  487. ----
  488. .. _class_CanvasItem_method_draw_style_box:
  489. - void **draw_style_box** **(** :ref:`StyleBox<class_StyleBox>` style_box, :ref:`Rect2<class_Rect2>` rect **)**
  490. Draws a styled rectangle.
  491. ----
  492. .. _class_CanvasItem_method_draw_texture:
  493. - void **draw_texture** **(** :ref:`Texture2D<class_Texture2D>` texture, :ref:`Vector2<class_Vector2>` position, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1) **)**
  494. Draws a texture at a given position.
  495. ----
  496. .. _class_CanvasItem_method_draw_texture_rect:
  497. - 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 **)**
  498. 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.
  499. ----
  500. .. _class_CanvasItem_method_draw_texture_rect_region:
  501. - 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:`bool<class_bool>` clip_uv=true **)**
  502. 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.
  503. ----
  504. .. _class_CanvasItem_method_force_update_transform:
  505. - void **force_update_transform** **(** **)**
  506. 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.
  507. ----
  508. .. _class_CanvasItem_method_get_canvas:
  509. - :ref:`RID<class_RID>` **get_canvas** **(** **)** |const|
  510. Returns the :ref:`RID<class_RID>` of the :ref:`World2D<class_World2D>` canvas where this item is in.
  511. ----
  512. .. _class_CanvasItem_method_get_canvas_item:
  513. - :ref:`RID<class_RID>` **get_canvas_item** **(** **)** |const|
  514. Returns the canvas item RID used by :ref:`RenderingServer<class_RenderingServer>` for this item.
  515. ----
  516. .. _class_CanvasItem_method_get_canvas_transform:
  517. - :ref:`Transform2D<class_Transform2D>` **get_canvas_transform** **(** **)** |const|
  518. Returns the transform matrix of this item's canvas.
  519. ----
  520. .. _class_CanvasItem_method_get_global_mouse_position:
  521. - :ref:`Vector2<class_Vector2>` **get_global_mouse_position** **(** **)** |const|
  522. Returns the mouse's position in the :ref:`CanvasLayer<class_CanvasLayer>` that this ``CanvasItem`` is in using the coordinate system of the :ref:`CanvasLayer<class_CanvasLayer>`.
  523. ----
  524. .. _class_CanvasItem_method_get_global_transform:
  525. - :ref:`Transform2D<class_Transform2D>` **get_global_transform** **(** **)** |const|
  526. Returns the global transform matrix of this item.
  527. ----
  528. .. _class_CanvasItem_method_get_global_transform_with_canvas:
  529. - :ref:`Transform2D<class_Transform2D>` **get_global_transform_with_canvas** **(** **)** |const|
  530. Returns the global transform matrix of this item in relation to the canvas.
  531. ----
  532. .. _class_CanvasItem_method_get_local_mouse_position:
  533. - :ref:`Vector2<class_Vector2>` **get_local_mouse_position** **(** **)** |const|
  534. Returns the mouse's position in this ``CanvasItem`` using the local coordinate system of this ``CanvasItem``.
  535. ----
  536. .. _class_CanvasItem_method_get_screen_transform:
  537. - :ref:`Transform2D<class_Transform2D>` **get_screen_transform** **(** **)** |const|
  538. Returns the transform of this ``CanvasItem`` in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.
  539. Equals to :ref:`get_global_transform<class_CanvasItem_method_get_global_transform>` if the window is embedded (see :ref:`Viewport.gui_embed_subwindows<class_Viewport_property_gui_embed_subwindows>`).
  540. ----
  541. .. _class_CanvasItem_method_get_transform:
  542. - :ref:`Transform2D<class_Transform2D>` **get_transform** **(** **)** |const|
  543. Returns the transform matrix of this item.
  544. ----
  545. .. _class_CanvasItem_method_get_viewport_rect:
  546. - :ref:`Rect2<class_Rect2>` **get_viewport_rect** **(** **)** |const|
  547. Returns the viewport's boundaries as a :ref:`Rect2<class_Rect2>`.
  548. ----
  549. .. _class_CanvasItem_method_get_viewport_transform:
  550. - :ref:`Transform2D<class_Transform2D>` **get_viewport_transform** **(** **)** |const|
  551. Returns this item's transform in relation to the viewport.
  552. ----
  553. .. _class_CanvasItem_method_get_world_2d:
  554. - :ref:`World2D<class_World2D>` **get_world_2d** **(** **)** |const|
  555. Returns the :ref:`World2D<class_World2D>` where this item is in.
  556. ----
  557. .. _class_CanvasItem_method_hide:
  558. - void **hide** **(** **)**
  559. Hide the ``CanvasItem`` if it's currently visible. This is equivalent to setting :ref:`visible<class_CanvasItem_property_visible>` to ``false``.
  560. ----
  561. .. _class_CanvasItem_method_is_local_transform_notification_enabled:
  562. - :ref:`bool<class_bool>` **is_local_transform_notification_enabled** **(** **)** |const|
  563. Returns ``true`` if local transform notifications are communicated to children.
  564. ----
  565. .. _class_CanvasItem_method_is_transform_notification_enabled:
  566. - :ref:`bool<class_bool>` **is_transform_notification_enabled** **(** **)** |const|
  567. Returns ``true`` if global transform notifications are communicated to children.
  568. ----
  569. .. _class_CanvasItem_method_is_visible_in_tree:
  570. - :ref:`bool<class_bool>` **is_visible_in_tree** **(** **)** |const|
  571. Returns ``true`` if the node is present in the :ref:`SceneTree<class_SceneTree>`, its :ref:`visible<class_CanvasItem_property_visible>` property is ``true`` and all its antecedents are also visible. If any antecedent is hidden, this node will not be visible in the scene tree, and is consequently not drawn (see :ref:`_draw<class_CanvasItem_method__draw>`).
  572. ----
  573. .. _class_CanvasItem_method_make_canvas_position_local:
  574. - :ref:`Vector2<class_Vector2>` **make_canvas_position_local** **(** :ref:`Vector2<class_Vector2>` screen_point **)** |const|
  575. Assigns ``screen_point`` as this node's new local transform.
  576. ----
  577. .. _class_CanvasItem_method_make_input_local:
  578. - :ref:`InputEvent<class_InputEvent>` **make_input_local** **(** :ref:`InputEvent<class_InputEvent>` event **)** |const|
  579. Transformations issued by ``event``'s inputs are applied in local space instead of global space.
  580. ----
  581. .. _class_CanvasItem_method_move_to_front:
  582. - void **move_to_front** **(** **)**
  583. Moves this node to display on top of its siblings. This has more use in :ref:`Control<class_Control>`, as :ref:`Node2D<class_Node2D>` can be ordered with :ref:`Node2D.z_index<class_Node2D_property_z_index>`.
  584. Internally, the node is moved to the bottom of parent's children list. The method has no effect on nodes without a parent.
  585. ----
  586. .. _class_CanvasItem_method_queue_redraw:
  587. - void **queue_redraw** **(** **)**
  588. Queues the ``CanvasItem`` to redraw. During idle time, if ``CanvasItem`` is visible, :ref:`NOTIFICATION_DRAW<class_CanvasItem_constant_NOTIFICATION_DRAW>` is sent and :ref:`_draw<class_CanvasItem_method__draw>` is called. This only occurs **once** per frame, even if this method has been called multiple times.
  589. ----
  590. .. _class_CanvasItem_method_set_notify_local_transform:
  591. - void **set_notify_local_transform** **(** :ref:`bool<class_bool>` enable **)**
  592. If ``enable`` is ``true``, this node will receive :ref:`NOTIFICATION_LOCAL_TRANSFORM_CHANGED<class_CanvasItem_constant_NOTIFICATION_LOCAL_TRANSFORM_CHANGED>` when its local transform changes.
  593. ----
  594. .. _class_CanvasItem_method_set_notify_transform:
  595. - void **set_notify_transform** **(** :ref:`bool<class_bool>` enable **)**
  596. If ``enable`` is ``true``, this node will receive :ref:`NOTIFICATION_TRANSFORM_CHANGED<class_CanvasItem_constant_NOTIFICATION_TRANSFORM_CHANGED>` when its global transform changes.
  597. ----
  598. .. _class_CanvasItem_method_show:
  599. - void **show** **(** **)**
  600. Show the ``CanvasItem`` if it's currently hidden. This is equivalent to setting :ref:`visible<class_CanvasItem_property_visible>` to ``true``. 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.
  601. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  602. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  603. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  604. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  605. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  606. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`