class_canvasitem.rst 151 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536
  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. Abstract base class for everything in 2D space.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Abstract base class for everything in 2D space. 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 GUI-related nodes, and by :ref:`Node2D<class_Node2D>` for 2D game objects.
  16. 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 a 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.
  17. 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.
  18. A **CanvasItem** can be hidden, which will also hide its children. By adjusting various other properties of a **CanvasItem**, you can also modulate its color (via :ref:`modulate<class_CanvasItem_property_modulate>` or :ref:`self_modulate<class_CanvasItem_property_self_modulate>`), change its Z-index, blend mode, and more.
  19. .. rst-class:: classref-introduction-group
  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. .. rst-class:: classref-reftable-group
  26. Properties
  27. ----------
  28. .. table::
  29. :widths: auto
  30. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  31. | :ref:`ClipChildrenMode<enum_CanvasItem_ClipChildrenMode>` | :ref:`clip_children<class_CanvasItem_property_clip_children>` | ``0`` |
  32. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  33. | :ref:`int<class_int>` | :ref:`light_mask<class_CanvasItem_property_light_mask>` | ``1`` |
  34. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  35. | :ref:`Material<class_Material>` | :ref:`material<class_CanvasItem_property_material>` | |
  36. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  37. | :ref:`Color<class_Color>` | :ref:`modulate<class_CanvasItem_property_modulate>` | ``Color(1, 1, 1, 1)`` |
  38. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  39. | :ref:`Color<class_Color>` | :ref:`self_modulate<class_CanvasItem_property_self_modulate>` | ``Color(1, 1, 1, 1)`` |
  40. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  41. | :ref:`bool<class_bool>` | :ref:`show_behind_parent<class_CanvasItem_property_show_behind_parent>` | ``false`` |
  42. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  43. | :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` | :ref:`texture_filter<class_CanvasItem_property_texture_filter>` | ``0`` |
  44. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  45. | :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` | :ref:`texture_repeat<class_CanvasItem_property_texture_repeat>` | ``0`` |
  46. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  47. | :ref:`bool<class_bool>` | :ref:`top_level<class_CanvasItem_property_top_level>` | ``false`` |
  48. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  49. | :ref:`bool<class_bool>` | :ref:`use_parent_material<class_CanvasItem_property_use_parent_material>` | ``false`` |
  50. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  51. | :ref:`int<class_int>` | :ref:`visibility_layer<class_CanvasItem_property_visibility_layer>` | ``1`` |
  52. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  53. | :ref:`bool<class_bool>` | :ref:`visible<class_CanvasItem_property_visible>` | ``true`` |
  54. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  55. | :ref:`bool<class_bool>` | :ref:`y_sort_enabled<class_CanvasItem_property_y_sort_enabled>` | ``false`` |
  56. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  57. | :ref:`bool<class_bool>` | :ref:`z_as_relative<class_CanvasItem_property_z_as_relative>` | ``true`` |
  58. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  59. | :ref:`int<class_int>` | :ref:`z_index<class_CanvasItem_property_z_index>` | ``0`` |
  60. +-----------------------------------------------------------+---------------------------------------------------------------------------+-----------------------+
  61. .. rst-class:: classref-reftable-group
  62. Methods
  63. -------
  64. .. table::
  65. :widths: auto
  66. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`_draw<class_CanvasItem_method__draw>` **(** **)** |virtual| |
  68. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | 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 **)** |
  70. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | 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 **)** |
  72. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | 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| |
  74. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | 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| |
  76. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`draw_circle<class_CanvasItem_method_draw_circle>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_Color>` color **)** |
  78. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | 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 **)** |
  80. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | 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, :ref:`bool<class_bool>` aligned=true **)** |
  82. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`draw_end_animation<class_CanvasItem_method_draw_end_animation>` **(** **)** |
  84. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | 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) **)** |
  86. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | 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 **)** |
  88. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | 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) **)** |
  90. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | 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, :ref:`float<class_float>` scale=1.0 **)** |
  92. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | 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 **)** |
  94. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | 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 **)** |
  96. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | 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>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  98. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | 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>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  100. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | void | :ref:`draw_multimesh<class_CanvasItem_method_draw_multimesh>` **(** :ref:`MultiMesh<class_MultiMesh>` multimesh, :ref:`Texture2D<class_Texture2D>` texture **)** |
  102. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | 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 **)** |
  104. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | 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 **)** |
  106. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | 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 **)** |
  108. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | 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 **)** |
  110. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | 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 **)** |
  112. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | 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) **)** |
  114. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | void | :ref:`draw_set_transform_matrix<class_CanvasItem_method_draw_set_transform_matrix>` **(** :ref:`Transform2D<class_Transform2D>` xform **)** |
  116. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | 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>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  118. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | 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>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const| |
  120. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | void | :ref:`draw_style_box<class_CanvasItem_method_draw_style_box>` **(** :ref:`StyleBox<class_StyleBox>` style_box, :ref:`Rect2<class_Rect2>` rect **)** |
  122. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | 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) **)** |
  124. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | 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 **)** |
  126. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | 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 **)** |
  128. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | void | :ref:`force_update_transform<class_CanvasItem_method_force_update_transform>` **(** **)** |
  130. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | :ref:`RID<class_RID>` | :ref:`get_canvas<class_CanvasItem_method_get_canvas>` **(** **)** |const| |
  132. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | :ref:`RID<class_RID>` | :ref:`get_canvas_item<class_CanvasItem_method_get_canvas_item>` **(** **)** |const| |
  134. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_canvas_transform<class_CanvasItem_method_get_canvas_transform>` **(** **)** |const| |
  136. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | :ref:`Vector2<class_Vector2>` | :ref:`get_global_mouse_position<class_CanvasItem_method_get_global_mouse_position>` **(** **)** |const| |
  138. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_global_transform<class_CanvasItem_method_get_global_transform>` **(** **)** |const| |
  140. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_global_transform_with_canvas<class_CanvasItem_method_get_global_transform_with_canvas>` **(** **)** |const| |
  142. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | :ref:`Vector2<class_Vector2>` | :ref:`get_local_mouse_position<class_CanvasItem_method_get_local_mouse_position>` **(** **)** |const| |
  144. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_screen_transform<class_CanvasItem_method_get_screen_transform>` **(** **)** |const| |
  146. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_transform<class_CanvasItem_method_get_transform>` **(** **)** |const| |
  148. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  149. | :ref:`Rect2<class_Rect2>` | :ref:`get_viewport_rect<class_CanvasItem_method_get_viewport_rect>` **(** **)** |const| |
  150. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  151. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_viewport_transform<class_CanvasItem_method_get_viewport_transform>` **(** **)** |const| |
  152. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  153. | :ref:`bool<class_bool>` | :ref:`get_visibility_layer_bit<class_CanvasItem_method_get_visibility_layer_bit>` **(** :ref:`int<class_int>` layer **)** |const| |
  154. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  155. | :ref:`World2D<class_World2D>` | :ref:`get_world_2d<class_CanvasItem_method_get_world_2d>` **(** **)** |const| |
  156. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  157. | void | :ref:`hide<class_CanvasItem_method_hide>` **(** **)** |
  158. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  159. | :ref:`bool<class_bool>` | :ref:`is_local_transform_notification_enabled<class_CanvasItem_method_is_local_transform_notification_enabled>` **(** **)** |const| |
  160. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  161. | :ref:`bool<class_bool>` | :ref:`is_transform_notification_enabled<class_CanvasItem_method_is_transform_notification_enabled>` **(** **)** |const| |
  162. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  163. | :ref:`bool<class_bool>` | :ref:`is_visible_in_tree<class_CanvasItem_method_is_visible_in_tree>` **(** **)** |const| |
  164. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  165. | :ref:`Vector2<class_Vector2>` | :ref:`make_canvas_position_local<class_CanvasItem_method_make_canvas_position_local>` **(** :ref:`Vector2<class_Vector2>` screen_point **)** |const| |
  166. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  167. | :ref:`InputEvent<class_InputEvent>` | :ref:`make_input_local<class_CanvasItem_method_make_input_local>` **(** :ref:`InputEvent<class_InputEvent>` event **)** |const| |
  168. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  169. | void | :ref:`move_to_front<class_CanvasItem_method_move_to_front>` **(** **)** |
  170. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  171. | void | :ref:`queue_redraw<class_CanvasItem_method_queue_redraw>` **(** **)** |
  172. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  173. | void | :ref:`set_notify_local_transform<class_CanvasItem_method_set_notify_local_transform>` **(** :ref:`bool<class_bool>` enable **)** |
  174. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  175. | void | :ref:`set_notify_transform<class_CanvasItem_method_set_notify_transform>` **(** :ref:`bool<class_bool>` enable **)** |
  176. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  177. | void | :ref:`set_visibility_layer_bit<class_CanvasItem_method_set_visibility_layer_bit>` **(** :ref:`int<class_int>` layer, :ref:`bool<class_bool>` enabled **)** |
  178. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  179. | void | :ref:`show<class_CanvasItem_method_show>` **(** **)** |
  180. +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  181. .. rst-class:: classref-section-separator
  182. ----
  183. .. rst-class:: classref-descriptions-group
  184. Signals
  185. -------
  186. .. _class_CanvasItem_signal_draw:
  187. .. rst-class:: classref-signal
  188. **draw** **(** **)**
  189. 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.
  190. \ **Note:** Deferred connections do not allow drawing through the ``draw_*`` methods.
  191. .. rst-class:: classref-item-separator
  192. ----
  193. .. _class_CanvasItem_signal_hidden:
  194. .. rst-class:: classref-signal
  195. **hidden** **(** **)**
  196. Emitted when becoming hidden.
  197. .. rst-class:: classref-item-separator
  198. ----
  199. .. _class_CanvasItem_signal_item_rect_changed:
  200. .. rst-class:: classref-signal
  201. **item_rect_changed** **(** **)**
  202. 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>`).
  203. .. rst-class:: classref-item-separator
  204. ----
  205. .. _class_CanvasItem_signal_visibility_changed:
  206. .. rst-class:: classref-signal
  207. **visibility_changed** **(** **)**
  208. Emitted when the visibility (hidden/visible) changes.
  209. .. rst-class:: classref-section-separator
  210. ----
  211. .. rst-class:: classref-descriptions-group
  212. Enumerations
  213. ------------
  214. .. _enum_CanvasItem_TextureFilter:
  215. .. rst-class:: classref-enumeration
  216. enum **TextureFilter**:
  217. .. _class_CanvasItem_constant_TEXTURE_FILTER_PARENT_NODE:
  218. .. rst-class:: classref-enumeration-constant
  219. :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **TEXTURE_FILTER_PARENT_NODE** = ``0``
  220. The **CanvasItem** will inherit the filter from its parent.
  221. .. _class_CanvasItem_constant_TEXTURE_FILTER_NEAREST:
  222. .. rst-class:: classref-enumeration-constant
  223. :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **TEXTURE_FILTER_NEAREST** = ``1``
  224. The texture filter reads from the nearest pixel only. The simplest and fastest method of filtering. Useful for pixel art.
  225. .. _class_CanvasItem_constant_TEXTURE_FILTER_LINEAR:
  226. .. rst-class:: classref-enumeration-constant
  227. :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **TEXTURE_FILTER_LINEAR** = ``2``
  228. The texture filter blends between the nearest four pixels. Use this for most cases where you want to avoid a pixelated style.
  229. .. _class_CanvasItem_constant_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS:
  230. .. rst-class:: classref-enumeration-constant
  231. :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **TEXTURE_FILTER_NEAREST_WITH_MIPMAPS** = ``3``
  232. The texture filter reads from the nearest pixel in the nearest mipmap. This is the fastest way to read from textures with mipmaps.
  233. .. _class_CanvasItem_constant_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS:
  234. .. rst-class:: classref-enumeration-constant
  235. :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **TEXTURE_FILTER_LINEAR_WITH_MIPMAPS** = ``4``
  236. 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.
  237. .. _class_CanvasItem_constant_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC:
  238. .. rst-class:: classref-enumeration-constant
  239. :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC** = ``5``
  240. 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>`.
  241. \ **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.
  242. .. _class_CanvasItem_constant_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC:
  243. .. rst-class:: classref-enumeration-constant
  244. :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC** = ``6``
  245. 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>`.
  246. \ **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.
  247. .. _class_CanvasItem_constant_TEXTURE_FILTER_MAX:
  248. .. rst-class:: classref-enumeration-constant
  249. :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **TEXTURE_FILTER_MAX** = ``7``
  250. Represents the size of the :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` enum.
  251. .. rst-class:: classref-item-separator
  252. ----
  253. .. _enum_CanvasItem_TextureRepeat:
  254. .. rst-class:: classref-enumeration
  255. enum **TextureRepeat**:
  256. .. _class_CanvasItem_constant_TEXTURE_REPEAT_PARENT_NODE:
  257. .. rst-class:: classref-enumeration-constant
  258. :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` **TEXTURE_REPEAT_PARENT_NODE** = ``0``
  259. The **CanvasItem** will inherit the filter from its parent.
  260. .. _class_CanvasItem_constant_TEXTURE_REPEAT_DISABLED:
  261. .. rst-class:: classref-enumeration-constant
  262. :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` **TEXTURE_REPEAT_DISABLED** = ``1``
  263. Texture will not repeat.
  264. .. _class_CanvasItem_constant_TEXTURE_REPEAT_ENABLED:
  265. .. rst-class:: classref-enumeration-constant
  266. :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` **TEXTURE_REPEAT_ENABLED** = ``2``
  267. Texture will repeat normally.
  268. .. _class_CanvasItem_constant_TEXTURE_REPEAT_MIRROR:
  269. .. rst-class:: classref-enumeration-constant
  270. :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` **TEXTURE_REPEAT_MIRROR** = ``3``
  271. Texture will repeat in a 2x2 tiled mode, where elements at even positions are mirrored.
  272. .. _class_CanvasItem_constant_TEXTURE_REPEAT_MAX:
  273. .. rst-class:: classref-enumeration-constant
  274. :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` **TEXTURE_REPEAT_MAX** = ``4``
  275. Represents the size of the :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` enum.
  276. .. rst-class:: classref-item-separator
  277. ----
  278. .. _enum_CanvasItem_ClipChildrenMode:
  279. .. rst-class:: classref-enumeration
  280. enum **ClipChildrenMode**:
  281. .. _class_CanvasItem_constant_CLIP_CHILDREN_DISABLED:
  282. .. rst-class:: classref-enumeration-constant
  283. :ref:`ClipChildrenMode<enum_CanvasItem_ClipChildrenMode>` **CLIP_CHILDREN_DISABLED** = ``0``
  284. Child draws over parent and is not clipped.
  285. .. _class_CanvasItem_constant_CLIP_CHILDREN_ONLY:
  286. .. rst-class:: classref-enumeration-constant
  287. :ref:`ClipChildrenMode<enum_CanvasItem_ClipChildrenMode>` **CLIP_CHILDREN_ONLY** = ``1``
  288. Parent is used for the purposes of clipping only. Child is clipped to the parent's visible area, parent is not drawn.
  289. .. _class_CanvasItem_constant_CLIP_CHILDREN_AND_DRAW:
  290. .. rst-class:: classref-enumeration-constant
  291. :ref:`ClipChildrenMode<enum_CanvasItem_ClipChildrenMode>` **CLIP_CHILDREN_AND_DRAW** = ``2``
  292. Parent is used for clipping child, but parent is also drawn underneath child as normal before clipping child to its visible area.
  293. .. _class_CanvasItem_constant_CLIP_CHILDREN_MAX:
  294. .. rst-class:: classref-enumeration-constant
  295. :ref:`ClipChildrenMode<enum_CanvasItem_ClipChildrenMode>` **CLIP_CHILDREN_MAX** = ``3``
  296. Represents the size of the :ref:`ClipChildrenMode<enum_CanvasItem_ClipChildrenMode>` enum.
  297. .. rst-class:: classref-section-separator
  298. ----
  299. .. rst-class:: classref-descriptions-group
  300. Constants
  301. ---------
  302. .. _class_CanvasItem_constant_NOTIFICATION_TRANSFORM_CHANGED:
  303. .. rst-class:: classref-constant
  304. **NOTIFICATION_TRANSFORM_CHANGED** = ``2000``
  305. 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>`.
  306. .. _class_CanvasItem_constant_NOTIFICATION_LOCAL_TRANSFORM_CHANGED:
  307. .. rst-class:: classref-constant
  308. **NOTIFICATION_LOCAL_TRANSFORM_CHANGED** = ``35``
  309. 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>`.
  310. .. _class_CanvasItem_constant_NOTIFICATION_DRAW:
  311. .. rst-class:: classref-constant
  312. **NOTIFICATION_DRAW** = ``30``
  313. The **CanvasItem** is requested to draw (see :ref:`_draw<class_CanvasItem_method__draw>`).
  314. .. _class_CanvasItem_constant_NOTIFICATION_VISIBILITY_CHANGED:
  315. .. rst-class:: classref-constant
  316. **NOTIFICATION_VISIBILITY_CHANGED** = ``31``
  317. The **CanvasItem**'s visibility has changed.
  318. .. _class_CanvasItem_constant_NOTIFICATION_ENTER_CANVAS:
  319. .. rst-class:: classref-constant
  320. **NOTIFICATION_ENTER_CANVAS** = ``32``
  321. The **CanvasItem** has entered the canvas.
  322. .. _class_CanvasItem_constant_NOTIFICATION_EXIT_CANVAS:
  323. .. rst-class:: classref-constant
  324. **NOTIFICATION_EXIT_CANVAS** = ``33``
  325. The **CanvasItem** has exited the canvas.
  326. .. _class_CanvasItem_constant_NOTIFICATION_WORLD_2D_CHANGED:
  327. .. rst-class:: classref-constant
  328. **NOTIFICATION_WORLD_2D_CHANGED** = ``36``
  329. The **CanvasItem**'s active :ref:`World2D<class_World2D>` changed.
  330. .. rst-class:: classref-section-separator
  331. ----
  332. .. rst-class:: classref-descriptions-group
  333. Property Descriptions
  334. ---------------------
  335. .. _class_CanvasItem_property_clip_children:
  336. .. rst-class:: classref-property
  337. :ref:`ClipChildrenMode<enum_CanvasItem_ClipChildrenMode>` **clip_children** = ``0``
  338. .. rst-class:: classref-property-setget
  339. - void **set_clip_children_mode** **(** :ref:`ClipChildrenMode<enum_CanvasItem_ClipChildrenMode>` value **)**
  340. - :ref:`ClipChildrenMode<enum_CanvasItem_ClipChildrenMode>` **get_clip_children_mode** **(** **)**
  341. Allows the current node to clip children nodes, essentially acting as a mask.
  342. .. rst-class:: classref-item-separator
  343. ----
  344. .. _class_CanvasItem_property_light_mask:
  345. .. rst-class:: classref-property
  346. :ref:`int<class_int>` **light_mask** = ``1``
  347. .. rst-class:: classref-property-setget
  348. - void **set_light_mask** **(** :ref:`int<class_int>` value **)**
  349. - :ref:`int<class_int>` **get_light_mask** **(** **)**
  350. The rendering layers in which this **CanvasItem** responds to :ref:`Light2D<class_Light2D>` nodes.
  351. .. rst-class:: classref-item-separator
  352. ----
  353. .. _class_CanvasItem_property_material:
  354. .. rst-class:: classref-property
  355. :ref:`Material<class_Material>` **material**
  356. .. rst-class:: classref-property-setget
  357. - void **set_material** **(** :ref:`Material<class_Material>` value **)**
  358. - :ref:`Material<class_Material>` **get_material** **(** **)**
  359. The material applied to this **CanvasItem**.
  360. .. rst-class:: classref-item-separator
  361. ----
  362. .. _class_CanvasItem_property_modulate:
  363. .. rst-class:: classref-property
  364. :ref:`Color<class_Color>` **modulate** = ``Color(1, 1, 1, 1)``
  365. .. rst-class:: classref-property-setget
  366. - void **set_modulate** **(** :ref:`Color<class_Color>` value **)**
  367. - :ref:`Color<class_Color>` **get_modulate** **(** **)**
  368. The color applied to this **CanvasItem**. This property does affect child **CanvasItem**\ s, unlike :ref:`self_modulate<class_CanvasItem_property_self_modulate>` which only affects the node itself.
  369. .. rst-class:: classref-item-separator
  370. ----
  371. .. _class_CanvasItem_property_self_modulate:
  372. .. rst-class:: classref-property
  373. :ref:`Color<class_Color>` **self_modulate** = ``Color(1, 1, 1, 1)``
  374. .. rst-class:: classref-property-setget
  375. - void **set_self_modulate** **(** :ref:`Color<class_Color>` value **)**
  376. - :ref:`Color<class_Color>` **get_self_modulate** **(** **)**
  377. The color applied to this **CanvasItem**. This property does **not** affect child **CanvasItem**\ s, unlike :ref:`modulate<class_CanvasItem_property_modulate>` which affects both the node itself and its children.
  378. \ **Note:** Internal children (e.g. sliders in :ref:`ColorPicker<class_ColorPicker>` or tab bar in :ref:`TabContainer<class_TabContainer>`) are also not affected by this property (see ``include_internal`` parameter of :ref:`Node.get_child<class_Node_method_get_child>` and other similar methods).
  379. .. rst-class:: classref-item-separator
  380. ----
  381. .. _class_CanvasItem_property_show_behind_parent:
  382. .. rst-class:: classref-property
  383. :ref:`bool<class_bool>` **show_behind_parent** = ``false``
  384. .. rst-class:: classref-property-setget
  385. - void **set_draw_behind_parent** **(** :ref:`bool<class_bool>` value **)**
  386. - :ref:`bool<class_bool>` **is_draw_behind_parent_enabled** **(** **)**
  387. If ``true``, the object draws behind its parent.
  388. .. rst-class:: classref-item-separator
  389. ----
  390. .. _class_CanvasItem_property_texture_filter:
  391. .. rst-class:: classref-property
  392. :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **texture_filter** = ``0``
  393. .. rst-class:: classref-property-setget
  394. - void **set_texture_filter** **(** :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` value **)**
  395. - :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **get_texture_filter** **(** **)**
  396. The texture filtering mode to use on this **CanvasItem**.
  397. .. rst-class:: classref-item-separator
  398. ----
  399. .. _class_CanvasItem_property_texture_repeat:
  400. .. rst-class:: classref-property
  401. :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` **texture_repeat** = ``0``
  402. .. rst-class:: classref-property-setget
  403. - void **set_texture_repeat** **(** :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` value **)**
  404. - :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` **get_texture_repeat** **(** **)**
  405. The texture repeating mode to use on this **CanvasItem**.
  406. .. rst-class:: classref-item-separator
  407. ----
  408. .. _class_CanvasItem_property_top_level:
  409. .. rst-class:: classref-property
  410. :ref:`bool<class_bool>` **top_level** = ``false``
  411. .. rst-class:: classref-property-setget
  412. - void **set_as_top_level** **(** :ref:`bool<class_bool>` value **)**
  413. - :ref:`bool<class_bool>` **is_set_as_top_level** **(** **)**
  414. 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>`.
  415. .. rst-class:: classref-item-separator
  416. ----
  417. .. _class_CanvasItem_property_use_parent_material:
  418. .. rst-class:: classref-property
  419. :ref:`bool<class_bool>` **use_parent_material** = ``false``
  420. .. rst-class:: classref-property-setget
  421. - void **set_use_parent_material** **(** :ref:`bool<class_bool>` value **)**
  422. - :ref:`bool<class_bool>` **get_use_parent_material** **(** **)**
  423. If ``true``, the parent **CanvasItem**'s :ref:`material<class_CanvasItem_property_material>` property is used as this one's material.
  424. .. rst-class:: classref-item-separator
  425. ----
  426. .. _class_CanvasItem_property_visibility_layer:
  427. .. rst-class:: classref-property
  428. :ref:`int<class_int>` **visibility_layer** = ``1``
  429. .. rst-class:: classref-property-setget
  430. - void **set_visibility_layer** **(** :ref:`int<class_int>` value **)**
  431. - :ref:`int<class_int>` **get_visibility_layer** **(** **)**
  432. The rendering layer in which this **CanvasItem** is rendered by :ref:`Viewport<class_Viewport>` nodes. A :ref:`Viewport<class_Viewport>` will render a **CanvasItem** if it and all its parents share a layer with the :ref:`Viewport<class_Viewport>`'s canvas cull mask.
  433. .. rst-class:: classref-item-separator
  434. ----
  435. .. _class_CanvasItem_property_visible:
  436. .. rst-class:: classref-property
  437. :ref:`bool<class_bool>` **visible** = ``true``
  438. .. rst-class:: classref-property-setget
  439. - void **set_visible** **(** :ref:`bool<class_bool>` value **)**
  440. - :ref:`bool<class_bool>` **is_visible** **(** **)**
  441. If ``true``, this **CanvasItem** is drawn. The node is only visible if all of its ancestors are visible as well (in other words, :ref:`is_visible_in_tree<class_CanvasItem_method_is_visible_in_tree>` must return ``true``).
  442. \ **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.
  443. .. rst-class:: classref-item-separator
  444. ----
  445. .. _class_CanvasItem_property_y_sort_enabled:
  446. .. rst-class:: classref-property
  447. :ref:`bool<class_bool>` **y_sort_enabled** = ``false``
  448. .. rst-class:: classref-property-setget
  449. - void **set_y_sort_enabled** **(** :ref:`bool<class_bool>` value **)**
  450. - :ref:`bool<class_bool>` **is_y_sort_enabled** **(** **)**
  451. If ``true``, child nodes with the lowest Y position are drawn before those with a higher Y position. If ``false``, Y-sorting is disabled. Y-sorting only affects children that inherit from **CanvasItem**.
  452. You can nest nodes with Y-sorting. Child Y-sorted nodes are sorted in the same space as the parent Y-sort. This feature allows you to organize a scene better or divide it into multiple ones without changing your scene tree.
  453. .. rst-class:: classref-item-separator
  454. ----
  455. .. _class_CanvasItem_property_z_as_relative:
  456. .. rst-class:: classref-property
  457. :ref:`bool<class_bool>` **z_as_relative** = ``true``
  458. .. rst-class:: classref-property-setget
  459. - void **set_z_as_relative** **(** :ref:`bool<class_bool>` value **)**
  460. - :ref:`bool<class_bool>` **is_z_relative** **(** **)**
  461. If ``true``, the node's Z index is relative to its parent's Z index. If this node's Z index is 2 and its parent's effective Z index is 3, then this node's effective Z index will be 2 + 3 = 5.
  462. .. rst-class:: classref-item-separator
  463. ----
  464. .. _class_CanvasItem_property_z_index:
  465. .. rst-class:: classref-property
  466. :ref:`int<class_int>` **z_index** = ``0``
  467. .. rst-class:: classref-property-setget
  468. - void **set_z_index** **(** :ref:`int<class_int>` value **)**
  469. - :ref:`int<class_int>` **get_z_index** **(** **)**
  470. Z index. Controls the order in which the nodes render. A node with a higher Z index will display in front of others. Must be between :ref:`RenderingServer.CANVAS_ITEM_Z_MIN<class_RenderingServer_constant_CANVAS_ITEM_Z_MIN>` and :ref:`RenderingServer.CANVAS_ITEM_Z_MAX<class_RenderingServer_constant_CANVAS_ITEM_Z_MAX>` (inclusive).
  471. \ **Note:** Changing the Z index of a :ref:`Control<class_Control>` only affects the drawing order, not the order in which input events are handled. This can be useful to implement certain UI animations, e.g. a menu where hovered items are scaled and should overlap others.
  472. .. rst-class:: classref-section-separator
  473. ----
  474. .. rst-class:: classref-descriptions-group
  475. Method Descriptions
  476. -------------------
  477. .. _class_CanvasItem_method__draw:
  478. .. rst-class:: classref-method
  479. void **_draw** **(** **)** |virtual|
  480. 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).
  481. Corresponds to the :ref:`NOTIFICATION_DRAW<class_CanvasItem_constant_NOTIFICATION_DRAW>` notification in :ref:`Object._notification<class_Object_method__notification>`.
  482. .. rst-class:: classref-item-separator
  483. ----
  484. .. _class_CanvasItem_method_draw_animation_slice:
  485. .. rst-class:: classref-method
  486. 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 **)**
  487. 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.
  488. .. rst-class:: classref-item-separator
  489. ----
  490. .. _class_CanvasItem_method_draw_arc:
  491. .. rst-class:: classref-method
  492. 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 **)**
  493. Draws an unfilled arc between the given angles with a uniform ``color`` and ``width`` and optional antialiasing (supported only for positive ``width``). The larger the value of ``point_count``, the smoother the curve. See also :ref:`draw_circle<class_CanvasItem_method_draw_circle>`.
  494. If ``width`` is negative, then the arc is drawn using :ref:`RenderingServer.PRIMITIVE_LINE_STRIP<class_RenderingServer_constant_PRIMITIVE_LINE_STRIP>`. This means that when the CanvasItem is scaled, the arc will remain thin. If this behavior is not desired, then pass a positive ``width`` like ``1.0``.
  495. The arc is drawn from ``start_angle`` towards the value of ``end_angle`` so in clockwise direction if ``start_angle < end_angle`` and counter-clockwise otherwise. Passing the same angles but in reversed order will produce the same arc. If absolute difference of ``start_angle`` and ``end_angle`` is greater than :ref:`@GDScript.TAU<class_@GDScript_constant_TAU>` radians, then a full circle arc is drawn (i.e. arc will not overlap itself).
  496. .. rst-class:: classref-item-separator
  497. ----
  498. .. _class_CanvasItem_method_draw_char:
  499. .. rst-class:: classref-method
  500. 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|
  501. Draws a string first character using a custom font.
  502. .. rst-class:: classref-item-separator
  503. ----
  504. .. _class_CanvasItem_method_draw_char_outline:
  505. .. rst-class:: classref-method
  506. 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|
  507. Draws a string first character outline using a custom font.
  508. .. rst-class:: classref-item-separator
  509. ----
  510. .. _class_CanvasItem_method_draw_circle:
  511. .. rst-class:: classref-method
  512. void **draw_circle** **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_Color>` color **)**
  513. 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>`.
  514. .. rst-class:: classref-item-separator
  515. ----
  516. .. _class_CanvasItem_method_draw_colored_polygon:
  517. .. rst-class:: classref-method
  518. 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 **)**
  519. 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.
  520. .. rst-class:: classref-item-separator
  521. ----
  522. .. _class_CanvasItem_method_draw_dashed_line:
  523. .. rst-class:: classref-method
  524. 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, :ref:`bool<class_bool>` aligned=true **)**
  525. 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>`.
  526. If ``width`` is negative, then a two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the line parts will remain thin. If this behavior is not desired, then pass a positive ``width`` like ``1.0``.
  527. .. rst-class:: classref-item-separator
  528. ----
  529. .. _class_CanvasItem_method_draw_end_animation:
  530. .. rst-class:: classref-method
  531. void **draw_end_animation** **(** **)**
  532. 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.
  533. .. rst-class:: classref-item-separator
  534. ----
  535. .. _class_CanvasItem_method_draw_lcd_texture_rect_region:
  536. .. rst-class:: classref-method
  537. 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) **)**
  538. Draws a textured rectangle region of the font texture with LCD subpixel anti-aliasing at a given position, optionally modulated by a color.
  539. Texture is drawn using the following blend operation, blend mode of the :ref:`CanvasItemMaterial<class_CanvasItemMaterial>` is ignored:
  540. ::
  541. dst.r = texture.r * modulate.r * modulate.a + dst.r * (1.0 - texture.r * modulate.a);
  542. dst.g = texture.g * modulate.g * modulate.a + dst.g * (1.0 - texture.g * modulate.a);
  543. dst.b = texture.b * modulate.b * modulate.a + dst.b * (1.0 - texture.b * modulate.a);
  544. dst.a = modulate.a + dst.a * (1.0 - modulate.a);
  545. .. rst-class:: classref-item-separator
  546. ----
  547. .. _class_CanvasItem_method_draw_line:
  548. .. rst-class:: classref-method
  549. 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 **)**
  550. 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>`.
  551. If ``width`` is negative, then a two-point primitive will be drawn instead of a four-point one. This means that when the CanvasItem is scaled, the line will remain thin. If this behavior is not desired, then pass a positive ``width`` like ``1.0``.
  552. .. rst-class:: classref-item-separator
  553. ----
  554. .. _class_CanvasItem_method_draw_mesh:
  555. .. rst-class:: classref-method
  556. 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) **)**
  557. Draws a :ref:`Mesh<class_Mesh>` in 2D, using the provided texture. See :ref:`MeshInstance2D<class_MeshInstance2D>` for related documentation.
  558. .. rst-class:: classref-item-separator
  559. ----
  560. .. _class_CanvasItem_method_draw_msdf_texture_rect_region:
  561. .. rst-class:: classref-method
  562. 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, :ref:`float<class_float>` scale=1.0 **)**
  563. 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.
  564. If ``outline`` is positive, each alpha channel value of pixel in region is set to maximum value of true distance in the ``outline`` radius.
  565. Value of the ``pixel_range`` should the same that was used during distance field texture generation.
  566. .. rst-class:: classref-item-separator
  567. ----
  568. .. _class_CanvasItem_method_draw_multiline:
  569. .. rst-class:: classref-method
  570. void **draw_multiline** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=-1.0 **)**
  571. Draws multiple disconnected lines with a uniform ``width`` and ``color``. Each line is defined by two consecutive points from ``points`` array, i.e. i-th segment consists of ``points[2 * i]``, ``points[2 * i + 1]`` endpoints. 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.
  572. If ``width`` is negative, then two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive ``width`` like ``1.0``.
  573. .. rst-class:: classref-item-separator
  574. ----
  575. .. _class_CanvasItem_method_draw_multiline_colors:
  576. .. rst-class:: classref-method
  577. void **draw_multiline_colors** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`float<class_float>` width=-1.0 **)**
  578. Draws multiple disconnected lines with a uniform ``width`` and segment-by-segment coloring. Each segment is defined by two consecutive points from ``points`` array and a corresponding color from ``colors`` array, i.e. i-th segment consists of ``points[2 * i]``, ``points[2 * i + 1]`` endpoints and has ``colors[i]`` 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_colors<class_CanvasItem_method_draw_polyline_colors>` instead.
  579. If ``width`` is negative, then two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive ``width`` like ``1.0``.
  580. .. rst-class:: classref-item-separator
  581. ----
  582. .. _class_CanvasItem_method_draw_multiline_string:
  583. .. rst-class:: classref-method
  584. 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>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  585. 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.
  586. .. rst-class:: classref-item-separator
  587. ----
  588. .. _class_CanvasItem_method_draw_multiline_string_outline:
  589. .. rst-class:: classref-method
  590. 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>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  591. 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.
  592. .. rst-class:: classref-item-separator
  593. ----
  594. .. _class_CanvasItem_method_draw_multimesh:
  595. .. rst-class:: classref-method
  596. void **draw_multimesh** **(** :ref:`MultiMesh<class_MultiMesh>` multimesh, :ref:`Texture2D<class_Texture2D>` texture **)**
  597. Draws a :ref:`MultiMesh<class_MultiMesh>` in 2D with the provided texture. See :ref:`MultiMeshInstance2D<class_MultiMeshInstance2D>` for related documentation.
  598. .. rst-class:: classref-item-separator
  599. ----
  600. .. _class_CanvasItem_method_draw_polygon:
  601. .. rst-class:: classref-method
  602. 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 **)**
  603. 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>`. If you need more flexibility (such as being able to use bones), use :ref:`RenderingServer.canvas_item_add_triangle_array<class_RenderingServer_method_canvas_item_add_triangle_array>` instead.
  604. .. rst-class:: classref-item-separator
  605. ----
  606. .. _class_CanvasItem_method_draw_polyline:
  607. .. rst-class:: classref-method
  608. 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 **)**
  609. Draws interconnected line segments with a uniform ``color`` and ``width`` and optional antialiasing (supported only for positive ``width``). 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>`.
  610. If ``width`` is negative, the polyline is drawn using :ref:`RenderingServer.PRIMITIVE_LINE_STRIP<class_RenderingServer_constant_PRIMITIVE_LINE_STRIP>`. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive ``width`` like ``1.0``.
  611. .. rst-class:: classref-item-separator
  612. ----
  613. .. _class_CanvasItem_method_draw_polyline_colors:
  614. .. rst-class:: classref-method
  615. 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 **)**
  616. Draws interconnected line segments with a uniform ``width``, point-by-point coloring, and optional antialiasing (supported only for positive ``width``). Colors assigned to line points match by index between ``points`` and ``colors``, i.e. each line segment is filled with a gradient between the colors of the endpoints. 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>`.
  617. If ``width`` is negative, then the polyline is drawn using :ref:`RenderingServer.PRIMITIVE_LINE_STRIP<class_RenderingServer_constant_PRIMITIVE_LINE_STRIP>`. This means that when the CanvasItem is scaled, the polyline will remain thin. If this behavior is not desired, then pass a positive ``width`` like ``1.0``.
  618. .. rst-class:: classref-item-separator
  619. ----
  620. .. _class_CanvasItem_method_draw_primitive:
  621. .. rst-class:: classref-method
  622. void **draw_primitive** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs, :ref:`Texture2D<class_Texture2D>` texture=null **)**
  623. 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>`.
  624. .. rst-class:: classref-item-separator
  625. ----
  626. .. _class_CanvasItem_method_draw_rect:
  627. .. rst-class:: classref-method
  628. 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 **)**
  629. 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. See also :ref:`draw_texture_rect<class_CanvasItem_method_draw_texture_rect>`.
  630. If ``width`` is negative, then two-point primitives will be drawn instead of a four-point ones. This means that when the CanvasItem is scaled, the lines will remain thin. If this behavior is not desired, then pass a positive ``width`` like ``1.0``.
  631. \ **Note:** ``width`` is only effective if ``filled`` is ``false``.
  632. \ **Note:** Unfilled rectangles drawn with a negative ``width`` may not display perfectly. For example, corners may be missing or brighter due to overlapping lines (for a translucent ``color``).
  633. .. rst-class:: classref-item-separator
  634. ----
  635. .. _class_CanvasItem_method_draw_set_transform:
  636. .. rst-class:: classref-method
  637. void **draw_set_transform** **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` rotation=0.0, :ref:`Vector2<class_Vector2>` scale=Vector2(1, 1) **)**
  638. Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this.
  639. \ **Note:** :ref:`FontFile.oversampling<class_FontFile_property_oversampling>` does *not* take ``scale`` into account. This means that scaling up/down will cause bitmap fonts and rasterized (non-MSDF) dynamic fonts to appear blurry or pixelated. To ensure text remains crisp regardless of scale, you can enable MSDF font rendering by enabling :ref:`ProjectSettings.gui/theme/default_font_multichannel_signed_distance_field<class_ProjectSettings_property_gui/theme/default_font_multichannel_signed_distance_field>` (applies to the default project font only), or enabling **Multichannel Signed Distance Field** in the import options of a DynamicFont for custom fonts. On system fonts, :ref:`SystemFont.multichannel_signed_distance_field<class_SystemFont_property_multichannel_signed_distance_field>` can be enabled in the inspector.
  640. .. rst-class:: classref-item-separator
  641. ----
  642. .. _class_CanvasItem_method_draw_set_transform_matrix:
  643. .. rst-class:: classref-method
  644. void **draw_set_transform_matrix** **(** :ref:`Transform2D<class_Transform2D>` xform **)**
  645. Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this.
  646. .. rst-class:: classref-item-separator
  647. ----
  648. .. _class_CanvasItem_method_draw_string:
  649. .. rst-class:: classref-method
  650. 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>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  651. 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.
  652. \ **Example using the default project font:**\
  653. .. tabs::
  654. .. code-tab:: gdscript
  655. # If using this method in a script that redraws constantly, move the
  656. # `default_font` declaration to a member variable assigned in `_ready()`
  657. # so the Control is only created once.
  658. var default_font = ThemeDB.fallback_font
  659. var default_font_size = ThemeDB.fallback_font_size
  660. draw_string(default_font, Vector2(64, 64), "Hello world", HORIZONTAL_ALIGNMENT_LEFT, -1, default_font_size)
  661. .. code-tab:: csharp
  662. // If using this method in a script that redraws constantly, move the
  663. // `default_font` declaration to a member variable assigned in `_Ready()`
  664. // so the Control is only created once.
  665. Font defaultFont = ThemeDB.FallbackFont;
  666. int defaultFontSize = ThemeDB.FallbackFontSize;
  667. DrawString(defaultFont, new Vector2(64, 64), "Hello world", HORIZONTAL_ALIGNMENT_LEFT, -1, defaultFontSize);
  668. See also :ref:`Font.draw_string<class_Font_method_draw_string>`.
  669. .. rst-class:: classref-item-separator
  670. ----
  671. .. _class_CanvasItem_method_draw_string_outline:
  672. .. rst-class:: classref-method
  673. 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>` justification_flags=3, :ref:`Direction<enum_TextServer_Direction>` direction=0, :ref:`Orientation<enum_TextServer_Orientation>` orientation=0 **)** |const|
  674. 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.
  675. .. rst-class:: classref-item-separator
  676. ----
  677. .. _class_CanvasItem_method_draw_style_box:
  678. .. rst-class:: classref-method
  679. void **draw_style_box** **(** :ref:`StyleBox<class_StyleBox>` style_box, :ref:`Rect2<class_Rect2>` rect **)**
  680. Draws a styled rectangle.
  681. .. rst-class:: classref-item-separator
  682. ----
  683. .. _class_CanvasItem_method_draw_texture:
  684. .. rst-class:: classref-method
  685. void **draw_texture** **(** :ref:`Texture2D<class_Texture2D>` texture, :ref:`Vector2<class_Vector2>` position, :ref:`Color<class_Color>` modulate=Color(1, 1, 1, 1) **)**
  686. Draws a texture at a given position.
  687. .. rst-class:: classref-item-separator
  688. ----
  689. .. _class_CanvasItem_method_draw_texture_rect:
  690. .. rst-class:: classref-method
  691. 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 **)**
  692. 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. See also :ref:`draw_rect<class_CanvasItem_method_draw_rect>` and :ref:`draw_texture_rect_region<class_CanvasItem_method_draw_texture_rect_region>`.
  693. .. rst-class:: classref-item-separator
  694. ----
  695. .. _class_CanvasItem_method_draw_texture_rect_region:
  696. .. rst-class:: classref-method
  697. 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 **)**
  698. Draws a textured rectangle from a texture's region (specified by ``src_rect``) at a given position, optionally modulated by a color. If ``transpose`` is ``true``, the texture will have its X and Y coordinates swapped. See also :ref:`draw_texture_rect<class_CanvasItem_method_draw_texture_rect>`.
  699. .. rst-class:: classref-item-separator
  700. ----
  701. .. _class_CanvasItem_method_force_update_transform:
  702. .. rst-class:: classref-method
  703. void **force_update_transform** **(** **)**
  704. 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.
  705. .. rst-class:: classref-item-separator
  706. ----
  707. .. _class_CanvasItem_method_get_canvas:
  708. .. rst-class:: classref-method
  709. :ref:`RID<class_RID>` **get_canvas** **(** **)** |const|
  710. Returns the :ref:`RID<class_RID>` of the :ref:`World2D<class_World2D>` canvas where this item is in.
  711. .. rst-class:: classref-item-separator
  712. ----
  713. .. _class_CanvasItem_method_get_canvas_item:
  714. .. rst-class:: classref-method
  715. :ref:`RID<class_RID>` **get_canvas_item** **(** **)** |const|
  716. Returns the canvas item RID used by :ref:`RenderingServer<class_RenderingServer>` for this item.
  717. .. rst-class:: classref-item-separator
  718. ----
  719. .. _class_CanvasItem_method_get_canvas_transform:
  720. .. rst-class:: classref-method
  721. :ref:`Transform2D<class_Transform2D>` **get_canvas_transform** **(** **)** |const|
  722. Returns the transform from the coordinate system of the canvas, this item is in, to the :ref:`Viewport<class_Viewport>`\ s coordinate system.
  723. .. rst-class:: classref-item-separator
  724. ----
  725. .. _class_CanvasItem_method_get_global_mouse_position:
  726. .. rst-class:: classref-method
  727. :ref:`Vector2<class_Vector2>` **get_global_mouse_position** **(** **)** |const|
  728. 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>`.
  729. \ **Note:** For screen-space coordinates (e.g. when using a non-embedded :ref:`Popup<class_Popup>`), you can use :ref:`DisplayServer.mouse_get_position<class_DisplayServer_method_mouse_get_position>`.
  730. .. rst-class:: classref-item-separator
  731. ----
  732. .. _class_CanvasItem_method_get_global_transform:
  733. .. rst-class:: classref-method
  734. :ref:`Transform2D<class_Transform2D>` **get_global_transform** **(** **)** |const|
  735. Returns the global transform matrix of this item, i.e. the combined transform up to the topmost **CanvasItem** node. The topmost item is a **CanvasItem** that either has no parent, has non-**CanvasItem** parent or it has :ref:`top_level<class_CanvasItem_property_top_level>` enabled.
  736. .. rst-class:: classref-item-separator
  737. ----
  738. .. _class_CanvasItem_method_get_global_transform_with_canvas:
  739. .. rst-class:: classref-method
  740. :ref:`Transform2D<class_Transform2D>` **get_global_transform_with_canvas** **(** **)** |const|
  741. Returns the transform from the local coordinate system of this **CanvasItem** to the :ref:`Viewport<class_Viewport>`\ s coordinate system.
  742. .. rst-class:: classref-item-separator
  743. ----
  744. .. _class_CanvasItem_method_get_local_mouse_position:
  745. .. rst-class:: classref-method
  746. :ref:`Vector2<class_Vector2>` **get_local_mouse_position** **(** **)** |const|
  747. Returns the mouse's position in this **CanvasItem** using the local coordinate system of this **CanvasItem**.
  748. .. rst-class:: classref-item-separator
  749. ----
  750. .. _class_CanvasItem_method_get_screen_transform:
  751. .. rst-class:: classref-method
  752. :ref:`Transform2D<class_Transform2D>` **get_screen_transform** **(** **)** |const|
  753. Returns the transform of this **CanvasItem** in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.
  754. 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>`).
  755. .. rst-class:: classref-item-separator
  756. ----
  757. .. _class_CanvasItem_method_get_transform:
  758. .. rst-class:: classref-method
  759. :ref:`Transform2D<class_Transform2D>` **get_transform** **(** **)** |const|
  760. Returns the transform matrix of this item.
  761. .. rst-class:: classref-item-separator
  762. ----
  763. .. _class_CanvasItem_method_get_viewport_rect:
  764. .. rst-class:: classref-method
  765. :ref:`Rect2<class_Rect2>` **get_viewport_rect** **(** **)** |const|
  766. Returns the viewport's boundaries as a :ref:`Rect2<class_Rect2>`.
  767. .. rst-class:: classref-item-separator
  768. ----
  769. .. _class_CanvasItem_method_get_viewport_transform:
  770. .. rst-class:: classref-method
  771. :ref:`Transform2D<class_Transform2D>` **get_viewport_transform** **(** **)** |const|
  772. Returns the transform from the coordinate system of the canvas, this item is in, to the :ref:`Viewport<class_Viewport>`\ s embedders coordinate system.
  773. .. rst-class:: classref-item-separator
  774. ----
  775. .. _class_CanvasItem_method_get_visibility_layer_bit:
  776. .. rst-class:: classref-method
  777. :ref:`bool<class_bool>` **get_visibility_layer_bit** **(** :ref:`int<class_int>` layer **)** |const|
  778. Returns an individual bit on the rendering visibility layer.
  779. .. rst-class:: classref-item-separator
  780. ----
  781. .. _class_CanvasItem_method_get_world_2d:
  782. .. rst-class:: classref-method
  783. :ref:`World2D<class_World2D>` **get_world_2d** **(** **)** |const|
  784. Returns the :ref:`World2D<class_World2D>` where this item is in.
  785. .. rst-class:: classref-item-separator
  786. ----
  787. .. _class_CanvasItem_method_hide:
  788. .. rst-class:: classref-method
  789. void **hide** **(** **)**
  790. Hide the **CanvasItem** if it's currently visible. This is equivalent to setting :ref:`visible<class_CanvasItem_property_visible>` to ``false``.
  791. .. rst-class:: classref-item-separator
  792. ----
  793. .. _class_CanvasItem_method_is_local_transform_notification_enabled:
  794. .. rst-class:: classref-method
  795. :ref:`bool<class_bool>` **is_local_transform_notification_enabled** **(** **)** |const|
  796. Returns ``true`` if local transform notifications are communicated to children.
  797. .. rst-class:: classref-item-separator
  798. ----
  799. .. _class_CanvasItem_method_is_transform_notification_enabled:
  800. .. rst-class:: classref-method
  801. :ref:`bool<class_bool>` **is_transform_notification_enabled** **(** **)** |const|
  802. Returns ``true`` if global transform notifications are communicated to children.
  803. .. rst-class:: classref-item-separator
  804. ----
  805. .. _class_CanvasItem_method_is_visible_in_tree:
  806. .. rst-class:: classref-method
  807. :ref:`bool<class_bool>` **is_visible_in_tree** **(** **)** |const|
  808. 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 ancestors are also visible. If any ancestor is hidden, this node will not be visible in the scene tree, and is consequently not drawn (see :ref:`_draw<class_CanvasItem_method__draw>`).
  809. .. rst-class:: classref-item-separator
  810. ----
  811. .. _class_CanvasItem_method_make_canvas_position_local:
  812. .. rst-class:: classref-method
  813. :ref:`Vector2<class_Vector2>` **make_canvas_position_local** **(** :ref:`Vector2<class_Vector2>` screen_point **)** |const|
  814. Assigns ``screen_point`` as this node's new local transform.
  815. .. rst-class:: classref-item-separator
  816. ----
  817. .. _class_CanvasItem_method_make_input_local:
  818. .. rst-class:: classref-method
  819. :ref:`InputEvent<class_InputEvent>` **make_input_local** **(** :ref:`InputEvent<class_InputEvent>` event **)** |const|
  820. Transformations issued by ``event``'s inputs are applied in local space instead of global space.
  821. .. rst-class:: classref-item-separator
  822. ----
  823. .. _class_CanvasItem_method_move_to_front:
  824. .. rst-class:: classref-method
  825. void **move_to_front** **(** **)**
  826. Moves this node to display on top of its siblings.
  827. Internally, the node is moved to the bottom of parent's children list. The method has no effect on nodes without a parent.
  828. .. rst-class:: classref-item-separator
  829. ----
  830. .. _class_CanvasItem_method_queue_redraw:
  831. .. rst-class:: classref-method
  832. void **queue_redraw** **(** **)**
  833. 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.
  834. .. rst-class:: classref-item-separator
  835. ----
  836. .. _class_CanvasItem_method_set_notify_local_transform:
  837. .. rst-class:: classref-method
  838. void **set_notify_local_transform** **(** :ref:`bool<class_bool>` enable **)**
  839. 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.
  840. .. rst-class:: classref-item-separator
  841. ----
  842. .. _class_CanvasItem_method_set_notify_transform:
  843. .. rst-class:: classref-method
  844. void **set_notify_transform** **(** :ref:`bool<class_bool>` enable **)**
  845. If ``enable`` is ``true``, this node will receive :ref:`NOTIFICATION_TRANSFORM_CHANGED<class_CanvasItem_constant_NOTIFICATION_TRANSFORM_CHANGED>` when its global transform changes.
  846. .. rst-class:: classref-item-separator
  847. ----
  848. .. _class_CanvasItem_method_set_visibility_layer_bit:
  849. .. rst-class:: classref-method
  850. void **set_visibility_layer_bit** **(** :ref:`int<class_int>` layer, :ref:`bool<class_bool>` enabled **)**
  851. Set/clear individual bits on the rendering visibility layer. This simplifies editing this **CanvasItem**'s visibility layer.
  852. .. rst-class:: classref-item-separator
  853. ----
  854. .. _class_CanvasItem_method_show:
  855. .. rst-class:: classref-method
  856. void **show** **(** **)**
  857. 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.
  858. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  859. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  860. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  861. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  862. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  863. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`