class_canvasitem.rst 148 KB

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