1089 lines
79 KiB
Text
1089 lines
79 KiB
Text
|
:github_url: hide
|
||
|
|
||
|
.. DO NOT EDIT THIS FILE!!!
|
||
|
.. Generated automatically from Godot engine sources.
|
||
|
.. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
|
||
|
.. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/CanvasItem.xml.
|
||
|
|
||
|
.. _class_CanvasItem:
|
||
|
|
||
|
CanvasItem
|
||
|
==========
|
||
|
|
||
|
**Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
||
|
|
||
|
**Inherited By:** :ref:`Control<class_Control>`, :ref:`Node2D<class_Node2D>`
|
||
|
|
||
|
Base class of anything 2D.
|
||
|
|
||
|
.. rst-class:: classref-introduction-group
|
||
|
|
||
|
Description
|
||
|
-----------
|
||
|
|
||
|
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.
|
||
|
|
||
|
Any **CanvasItem** can draw. For this, :ref:`update<class_CanvasItem_method_update>` 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.
|
||
|
|
||
|
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.
|
||
|
|
||
|
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.
|
||
|
|
||
|
Ultimately, a transform notification can be requested, which will notify the node that its global position changed in case the parent tree changed.
|
||
|
|
||
|
\ **Note:** Unless otherwise specified, all methods that have angle parameters must have angles specified as *radians*. To convert degrees to radians, use :ref:`@GDScript.deg2rad<class_@GDScript_method_deg2rad>`.
|
||
|
|
||
|
.. rst-class:: classref-introduction-group
|
||
|
|
||
|
Tutorials
|
||
|
---------
|
||
|
|
||
|
- :doc:`Viewport and canvas transforms <../tutorials/2d/2d_transforms>`
|
||
|
|
||
|
- :doc:`Custom drawing in 2D <../tutorials/2d/custom_drawing_in_2d>`
|
||
|
|
||
|
- `Audio Spectrum Demo <https://godotengine.org/asset-library/asset/528>`__
|
||
|
|
||
|
.. rst-class:: classref-reftable-group
|
||
|
|
||
|
Properties
|
||
|
----------
|
||
|
|
||
|
.. table::
|
||
|
:widths: auto
|
||
|
|
||
|
+---------------------------------+---------------------------------------------------------------------------+-------------------------+
|
||
|
| :ref:`int<class_int>` | :ref:`light_mask<class_CanvasItem_property_light_mask>` | ``1`` |
|
||
|
+---------------------------------+---------------------------------------------------------------------------+-------------------------+
|
||
|
| :ref:`Material<class_Material>` | :ref:`material<class_CanvasItem_property_material>` | |
|
||
|
+---------------------------------+---------------------------------------------------------------------------+-------------------------+
|
||
|
| :ref:`Color<class_Color>` | :ref:`modulate<class_CanvasItem_property_modulate>` | ``Color( 1, 1, 1, 1 )`` |
|
||
|
+---------------------------------+---------------------------------------------------------------------------+-------------------------+
|
||
|
| :ref:`Color<class_Color>` | :ref:`self_modulate<class_CanvasItem_property_self_modulate>` | ``Color( 1, 1, 1, 1 )`` |
|
||
|
+---------------------------------+---------------------------------------------------------------------------+-------------------------+
|
||
|
| :ref:`bool<class_bool>` | :ref:`show_behind_parent<class_CanvasItem_property_show_behind_parent>` | ``false`` |
|
||
|
+---------------------------------+---------------------------------------------------------------------------+-------------------------+
|
||
|
| :ref:`bool<class_bool>` | :ref:`show_on_top<class_CanvasItem_property_show_on_top>` | |
|
||
|
+---------------------------------+---------------------------------------------------------------------------+-------------------------+
|
||
|
| :ref:`bool<class_bool>` | :ref:`use_parent_material<class_CanvasItem_property_use_parent_material>` | ``false`` |
|
||
|
+---------------------------------+---------------------------------------------------------------------------+-------------------------+
|
||
|
| :ref:`bool<class_bool>` | :ref:`visible<class_CanvasItem_property_visible>` | ``true`` |
|
||
|
+---------------------------------+---------------------------------------------------------------------------+-------------------------+
|
||
|
|
||
|
.. rst-class:: classref-reftable-group
|
||
|
|
||
|
Methods
|
||
|
-------
|
||
|
|
||
|
.. table::
|
||
|
:widths: auto
|
||
|
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`_draw<class_CanvasItem_method__draw>` **(** **)** |virtual| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| 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 **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`float<class_float>` | :ref:`draw_char<class_CanvasItem_method_draw_char>` **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` position, :ref:`String<class_String>` char, :ref:`String<class_String>` next, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ) **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_circle<class_CanvasItem_method_draw_circle>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_Color>` color **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_colored_polygon<class_CanvasItem_method_draw_colored_polygon>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`PoolVector2Array<class_PoolVector2Array>` uvs=PoolVector2Array( ), :ref:`Texture<class_Texture>` texture=null, :ref:`Texture<class_Texture>` normal_map=null, :ref:`bool<class_bool>` antialiased=false **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| 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 **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_mesh<class_CanvasItem_method_draw_mesh>` **(** :ref:`Mesh<class_Mesh>` mesh, :ref:`Texture<class_Texture>` texture, :ref:`Texture<class_Texture>` normal_map=null, :ref:`Transform2D<class_Transform2D>` transform=Transform2D( 1, 0, 0, 1, 0, 0 ), :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ) **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_multiline<class_CanvasItem_method_draw_multiline>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_multiline_colors<class_CanvasItem_method_draw_multiline_colors>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`PoolColorArray<class_PoolColorArray>` colors, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_multimesh<class_CanvasItem_method_draw_multimesh>` **(** :ref:`MultiMesh<class_MultiMesh>` multimesh, :ref:`Texture<class_Texture>` texture, :ref:`Texture<class_Texture>` normal_map=null **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_polygon<class_CanvasItem_method_draw_polygon>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`PoolColorArray<class_PoolColorArray>` colors, :ref:`PoolVector2Array<class_PoolVector2Array>` uvs=PoolVector2Array( ), :ref:`Texture<class_Texture>` texture=null, :ref:`Texture<class_Texture>` normal_map=null, :ref:`bool<class_bool>` antialiased=false **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_polyline<class_CanvasItem_method_draw_polyline>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_polyline_colors<class_CanvasItem_method_draw_polyline_colors>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`PoolColorArray<class_PoolColorArray>` colors, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_primitive<class_CanvasItem_method_draw_primitive>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`PoolColorArray<class_PoolColorArray>` colors, :ref:`PoolVector2Array<class_PoolVector2Array>` uvs, :ref:`Texture<class_Texture>` texture=null, :ref:`float<class_float>` width=1.0, :ref:`Texture<class_Texture>` normal_map=null **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| 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, :ref:`bool<class_bool>` antialiased=false **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_set_transform<class_CanvasItem_method_draw_set_transform>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` rotation, :ref:`Vector2<class_Vector2>` scale **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_set_transform_matrix<class_CanvasItem_method_draw_set_transform_matrix>` **(** :ref:`Transform2D<class_Transform2D>` xform **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_string<class_CanvasItem_method_draw_string>` **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` position, :ref:`String<class_String>` text, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`int<class_int>` clip_w=-1 **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_style_box<class_CanvasItem_method_draw_style_box>` **(** :ref:`StyleBox<class_StyleBox>` style_box, :ref:`Rect2<class_Rect2>` rect **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_texture<class_CanvasItem_method_draw_texture>` **(** :ref:`Texture<class_Texture>` texture, :ref:`Vector2<class_Vector2>` position, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`Texture<class_Texture>` normal_map=null **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_texture_rect<class_CanvasItem_method_draw_texture_rect>` **(** :ref:`Texture<class_Texture>` texture, :ref:`Rect2<class_Rect2>` rect, :ref:`bool<class_bool>` tile, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_Texture>` normal_map=null **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`draw_texture_rect_region<class_CanvasItem_method_draw_texture_rect_region>` **(** :ref:`Texture<class_Texture>` texture, :ref:`Rect2<class_Rect2>` rect, :ref:`Rect2<class_Rect2>` src_rect, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_Texture>` normal_map=null, :ref:`bool<class_bool>` clip_uv=true **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`force_update_transform<class_CanvasItem_method_force_update_transform>` **(** **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`RID<class_RID>` | :ref:`get_canvas<class_CanvasItem_method_get_canvas>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`RID<class_RID>` | :ref:`get_canvas_item<class_CanvasItem_method_get_canvas_item>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`Transform2D<class_Transform2D>` | :ref:`get_canvas_transform<class_CanvasItem_method_get_canvas_transform>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`Vector2<class_Vector2>` | :ref:`get_global_mouse_position<class_CanvasItem_method_get_global_mouse_position>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`Transform2D<class_Transform2D>` | :ref:`get_global_transform<class_CanvasItem_method_get_global_transform>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`Transform2D<class_Transform2D>` | :ref:`get_global_transform_with_canvas<class_CanvasItem_method_get_global_transform_with_canvas>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`Vector2<class_Vector2>` | :ref:`get_local_mouse_position<class_CanvasItem_method_get_local_mouse_position>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`Transform2D<class_Transform2D>` | :ref:`get_transform<class_CanvasItem_method_get_transform>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`Rect2<class_Rect2>` | :ref:`get_viewport_rect<class_CanvasItem_method_get_viewport_rect>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`Transform2D<class_Transform2D>` | :ref:`get_viewport_transform<class_CanvasItem_method_get_viewport_transform>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`World2D<class_World2D>` | :ref:`get_world_2d<class_CanvasItem_method_get_world_2d>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`hide<class_CanvasItem_method_hide>` **(** **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`bool<class_bool>` | :ref:`is_local_transform_notification_enabled<class_CanvasItem_method_is_local_transform_notification_enabled>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`bool<class_bool>` | :ref:`is_set_as_toplevel<class_CanvasItem_method_is_set_as_toplevel>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`bool<class_bool>` | :ref:`is_transform_notification_enabled<class_CanvasItem_method_is_transform_notification_enabled>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`bool<class_bool>` | :ref:`is_visible_in_tree<class_CanvasItem_method_is_visible_in_tree>` **(** **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`Vector2<class_Vector2>` | :ref:`make_canvas_position_local<class_CanvasItem_method_make_canvas_position_local>` **(** :ref:`Vector2<class_Vector2>` screen_point **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| :ref:`InputEvent<class_InputEvent>` | :ref:`make_input_local<class_CanvasItem_method_make_input_local>` **(** :ref:`InputEvent<class_InputEvent>` event **)** |const| |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`set_as_toplevel<class_CanvasItem_method_set_as_toplevel>` **(** :ref:`bool<class_bool>` enable **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`set_notify_local_transform<class_CanvasItem_method_set_notify_local_transform>` **(** :ref:`bool<class_bool>` enable **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`set_notify_transform<class_CanvasItem_method_set_notify_transform>` **(** :ref:`bool<class_bool>` enable **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`show<class_CanvasItem_method_show>` **(** **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
| void | :ref:`update<class_CanvasItem_method_update>` **(** **)** |
|
||
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
|
||
|
.. rst-class:: classref-section-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. rst-class:: classref-descriptions-group
|
||
|
|
||
|
Signals
|
||
|
-------
|
||
|
|
||
|
.. _class_CanvasItem_signal_draw:
|
||
|
|
||
|
.. rst-class:: classref-signal
|
||
|
|
||
|
**draw** **(** **)**
|
||
|
|
||
|
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.
|
||
|
|
||
|
\ **Note:** Deferred connections do not allow drawing through the ``draw_*`` methods.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_signal_hide:
|
||
|
|
||
|
.. rst-class:: classref-signal
|
||
|
|
||
|
**hide** **(** **)**
|
||
|
|
||
|
Emitted when becoming hidden.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_signal_item_rect_changed:
|
||
|
|
||
|
.. rst-class:: classref-signal
|
||
|
|
||
|
**item_rect_changed** **(** **)**
|
||
|
|
||
|
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:`Sprite.texture<class_Sprite_property_texture>`).
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_signal_visibility_changed:
|
||
|
|
||
|
.. rst-class:: classref-signal
|
||
|
|
||
|
**visibility_changed** **(** **)**
|
||
|
|
||
|
Emitted when the visibility (hidden/visible) changes.
|
||
|
|
||
|
.. rst-class:: classref-section-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. rst-class:: classref-descriptions-group
|
||
|
|
||
|
Enumerations
|
||
|
------------
|
||
|
|
||
|
.. _enum_CanvasItem_BlendMode:
|
||
|
|
||
|
.. rst-class:: classref-enumeration
|
||
|
|
||
|
enum **BlendMode**:
|
||
|
|
||
|
.. _class_CanvasItem_constant_BLEND_MODE_MIX:
|
||
|
|
||
|
.. rst-class:: classref-enumeration-constant
|
||
|
|
||
|
:ref:`BlendMode<enum_CanvasItem_BlendMode>` **BLEND_MODE_MIX** = ``0``
|
||
|
|
||
|
Mix blending mode. Colors are assumed to be independent of the alpha (opacity) value.
|
||
|
|
||
|
.. _class_CanvasItem_constant_BLEND_MODE_ADD:
|
||
|
|
||
|
.. rst-class:: classref-enumeration-constant
|
||
|
|
||
|
:ref:`BlendMode<enum_CanvasItem_BlendMode>` **BLEND_MODE_ADD** = ``1``
|
||
|
|
||
|
Additive blending mode.
|
||
|
|
||
|
.. _class_CanvasItem_constant_BLEND_MODE_SUB:
|
||
|
|
||
|
.. rst-class:: classref-enumeration-constant
|
||
|
|
||
|
:ref:`BlendMode<enum_CanvasItem_BlendMode>` **BLEND_MODE_SUB** = ``2``
|
||
|
|
||
|
Subtractive blending mode.
|
||
|
|
||
|
.. _class_CanvasItem_constant_BLEND_MODE_MUL:
|
||
|
|
||
|
.. rst-class:: classref-enumeration-constant
|
||
|
|
||
|
:ref:`BlendMode<enum_CanvasItem_BlendMode>` **BLEND_MODE_MUL** = ``3``
|
||
|
|
||
|
Multiplicative blending mode.
|
||
|
|
||
|
.. _class_CanvasItem_constant_BLEND_MODE_PREMULT_ALPHA:
|
||
|
|
||
|
.. rst-class:: classref-enumeration-constant
|
||
|
|
||
|
:ref:`BlendMode<enum_CanvasItem_BlendMode>` **BLEND_MODE_PREMULT_ALPHA** = ``4``
|
||
|
|
||
|
Mix blending mode. Colors are assumed to be premultiplied by the alpha (opacity) value.
|
||
|
|
||
|
.. _class_CanvasItem_constant_BLEND_MODE_DISABLED:
|
||
|
|
||
|
.. rst-class:: classref-enumeration-constant
|
||
|
|
||
|
:ref:`BlendMode<enum_CanvasItem_BlendMode>` **BLEND_MODE_DISABLED** = ``5``
|
||
|
|
||
|
Disables blending mode. Colors including alpha are written as-is. Only applicable for render targets with a transparent background. No lighting will be applied.
|
||
|
|
||
|
.. rst-class:: classref-section-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. rst-class:: classref-descriptions-group
|
||
|
|
||
|
Constants
|
||
|
---------
|
||
|
|
||
|
.. _class_CanvasItem_constant_NOTIFICATION_TRANSFORM_CHANGED:
|
||
|
|
||
|
.. rst-class:: classref-constant
|
||
|
|
||
|
**NOTIFICATION_TRANSFORM_CHANGED** = ``2000``
|
||
|
|
||
|
The **CanvasItem**'s global transform has changed. This notification is only received if enabled by :ref:`set_notify_transform<class_CanvasItem_method_set_notify_transform>`.
|
||
|
|
||
|
.. _class_CanvasItem_constant_NOTIFICATION_LOCAL_TRANSFORM_CHANGED:
|
||
|
|
||
|
.. rst-class:: classref-constant
|
||
|
|
||
|
**NOTIFICATION_LOCAL_TRANSFORM_CHANGED** = ``35``
|
||
|
|
||
|
The **CanvasItem**'s local transform has changed. This notification is only received if enabled by :ref:`set_notify_local_transform<class_CanvasItem_method_set_notify_local_transform>`.
|
||
|
|
||
|
.. _class_CanvasItem_constant_NOTIFICATION_DRAW:
|
||
|
|
||
|
.. rst-class:: classref-constant
|
||
|
|
||
|
**NOTIFICATION_DRAW** = ``30``
|
||
|
|
||
|
The **CanvasItem** is requested to draw (see :ref:`_draw<class_CanvasItem_method__draw>`).
|
||
|
|
||
|
.. _class_CanvasItem_constant_NOTIFICATION_VISIBILITY_CHANGED:
|
||
|
|
||
|
.. rst-class:: classref-constant
|
||
|
|
||
|
**NOTIFICATION_VISIBILITY_CHANGED** = ``31``
|
||
|
|
||
|
The **CanvasItem**'s visibility has changed.
|
||
|
|
||
|
.. _class_CanvasItem_constant_NOTIFICATION_ENTER_CANVAS:
|
||
|
|
||
|
.. rst-class:: classref-constant
|
||
|
|
||
|
**NOTIFICATION_ENTER_CANVAS** = ``32``
|
||
|
|
||
|
The **CanvasItem** has entered the canvas.
|
||
|
|
||
|
.. _class_CanvasItem_constant_NOTIFICATION_EXIT_CANVAS:
|
||
|
|
||
|
.. rst-class:: classref-constant
|
||
|
|
||
|
**NOTIFICATION_EXIT_CANVAS** = ``33``
|
||
|
|
||
|
The **CanvasItem** has exited the canvas.
|
||
|
|
||
|
.. rst-class:: classref-section-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. rst-class:: classref-descriptions-group
|
||
|
|
||
|
Property Descriptions
|
||
|
---------------------
|
||
|
|
||
|
.. _class_CanvasItem_property_light_mask:
|
||
|
|
||
|
.. rst-class:: classref-property
|
||
|
|
||
|
:ref:`int<class_int>` **light_mask** = ``1``
|
||
|
|
||
|
.. rst-class:: classref-property-setget
|
||
|
|
||
|
- void **set_light_mask** **(** :ref:`int<class_int>` value **)**
|
||
|
- :ref:`int<class_int>` **get_light_mask** **(** **)**
|
||
|
|
||
|
The rendering layers in which this **CanvasItem** responds to :ref:`Light2D<class_Light2D>` nodes.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_property_material:
|
||
|
|
||
|
.. rst-class:: classref-property
|
||
|
|
||
|
:ref:`Material<class_Material>` **material**
|
||
|
|
||
|
.. rst-class:: classref-property-setget
|
||
|
|
||
|
- void **set_material** **(** :ref:`Material<class_Material>` value **)**
|
||
|
- :ref:`Material<class_Material>` **get_material** **(** **)**
|
||
|
|
||
|
The material applied to textures on this **CanvasItem**.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_property_modulate:
|
||
|
|
||
|
.. rst-class:: classref-property
|
||
|
|
||
|
:ref:`Color<class_Color>` **modulate** = ``Color( 1, 1, 1, 1 )``
|
||
|
|
||
|
.. rst-class:: classref-property-setget
|
||
|
|
||
|
- void **set_modulate** **(** :ref:`Color<class_Color>` value **)**
|
||
|
- :ref:`Color<class_Color>` **get_modulate** **(** **)**
|
||
|
|
||
|
The color applied to textures on this **CanvasItem**.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_property_self_modulate:
|
||
|
|
||
|
.. rst-class:: classref-property
|
||
|
|
||
|
:ref:`Color<class_Color>` **self_modulate** = ``Color( 1, 1, 1, 1 )``
|
||
|
|
||
|
.. rst-class:: classref-property-setget
|
||
|
|
||
|
- void **set_self_modulate** **(** :ref:`Color<class_Color>` value **)**
|
||
|
- :ref:`Color<class_Color>` **get_self_modulate** **(** **)**
|
||
|
|
||
|
The color applied to textures on this **CanvasItem**. This is not inherited by children **CanvasItem**\ s.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_property_show_behind_parent:
|
||
|
|
||
|
.. rst-class:: classref-property
|
||
|
|
||
|
:ref:`bool<class_bool>` **show_behind_parent** = ``false``
|
||
|
|
||
|
.. rst-class:: classref-property-setget
|
||
|
|
||
|
- void **set_draw_behind_parent** **(** :ref:`bool<class_bool>` value **)**
|
||
|
- :ref:`bool<class_bool>` **is_draw_behind_parent_enabled** **(** **)**
|
||
|
|
||
|
If ``true``, the object draws behind its parent.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_property_show_on_top:
|
||
|
|
||
|
.. rst-class:: classref-property
|
||
|
|
||
|
:ref:`bool<class_bool>` **show_on_top**
|
||
|
|
||
|
If ``true``, the object draws on top of its parent.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_property_use_parent_material:
|
||
|
|
||
|
.. rst-class:: classref-property
|
||
|
|
||
|
:ref:`bool<class_bool>` **use_parent_material** = ``false``
|
||
|
|
||
|
.. rst-class:: classref-property-setget
|
||
|
|
||
|
- void **set_use_parent_material** **(** :ref:`bool<class_bool>` value **)**
|
||
|
- :ref:`bool<class_bool>` **get_use_parent_material** **(** **)**
|
||
|
|
||
|
If ``true``, the parent **CanvasItem**'s :ref:`material<class_CanvasItem_property_material>` property is used as this one's material.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_property_visible:
|
||
|
|
||
|
.. rst-class:: classref-property
|
||
|
|
||
|
:ref:`bool<class_bool>` **visible** = ``true``
|
||
|
|
||
|
.. rst-class:: classref-property-setget
|
||
|
|
||
|
- void **set_visible** **(** :ref:`bool<class_bool>` value **)**
|
||
|
- :ref:`bool<class_bool>` **is_visible** **(** **)**
|
||
|
|
||
|
If ``true``, this **CanvasItem** is drawn. The node is only visible if all of its ancestors are visible as well (in other words, :ref:`is_visible_in_tree<class_CanvasItem_method_is_visible_in_tree>` must return ``true``).
|
||
|
|
||
|
\ **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.
|
||
|
|
||
|
.. rst-class:: classref-section-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. rst-class:: classref-descriptions-group
|
||
|
|
||
|
Method Descriptions
|
||
|
-------------------
|
||
|
|
||
|
.. _class_CanvasItem_method__draw:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **_draw** **(** **)** |virtual|
|
||
|
|
||
|
Called when **CanvasItem** has been requested to redraw (when :ref:`update<class_CanvasItem_method_update>` is called, either manually or by the engine).
|
||
|
|
||
|
Corresponds to the :ref:`NOTIFICATION_DRAW<class_CanvasItem_constant_NOTIFICATION_DRAW>` notification in :ref:`Object._notification<class_Object_method__notification>`.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_arc:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
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 **)**
|
||
|
|
||
|
Draws a unfilled arc between the given angles. The larger the value of ``point_count``, the smoother the curve. See also :ref:`draw_circle<class_CanvasItem_method_draw_circle>`.
|
||
|
|
||
|
\ **Note:** Line drawing is not accelerated by batching if ``antialiased`` is ``true``.
|
||
|
|
||
|
\ **Note:** Due to how it works, built-in antialiasing will not look correct for translucent lines and may not work on certain platforms. As a workaround, install the `Antialiased Line2D <https://github.com/godot-extended-libraries/godot-antialiased-line2d>`__ add-on then create an AntialiasedRegularPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_char:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`float<class_float>` **draw_char** **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` position, :ref:`String<class_String>` char, :ref:`String<class_String>` next, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ) **)**
|
||
|
|
||
|
Draws a string character using a custom font. Returns the advance, depending on the character width and kerning with an optional next character.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_circle:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_circle** **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_Color>` color **)**
|
||
|
|
||
|
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>`.
|
||
|
|
||
|
\ **Note:** Built-in antialiasing is not provided for :ref:`draw_circle<class_CanvasItem_method_draw_circle>`. As a workaround, install the `Antialiased Line2D <https://github.com/godot-extended-libraries/godot-antialiased-line2d>`__ add-on then create an AntialiasedRegularPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_colored_polygon:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_colored_polygon** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`PoolVector2Array<class_PoolVector2Array>` uvs=PoolVector2Array( ), :ref:`Texture<class_Texture>` texture=null, :ref:`Texture<class_Texture>` normal_map=null, :ref:`bool<class_bool>` antialiased=false **)**
|
||
|
|
||
|
Draws a colored polygon of any amount of points, convex or concave. Unlike :ref:`draw_polygon<class_CanvasItem_method_draw_polygon>`, a single color must be specified for the whole polygon.
|
||
|
|
||
|
\ **Note:** Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the `Antialiased Line2D <https://github.com/godot-extended-libraries/godot-antialiased-line2d>`__ add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_line:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
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 **)**
|
||
|
|
||
|
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>`.
|
||
|
|
||
|
\ **Note:** Line drawing is not accelerated by batching if ``antialiased`` is ``true``.
|
||
|
|
||
|
\ **Note:** Due to how it works, built-in antialiasing will not look correct for translucent lines and may not work on certain platforms. As a workaround, install the `Antialiased Line2D <https://github.com/godot-extended-libraries/godot-antialiased-line2d>`__ add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_mesh:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_mesh** **(** :ref:`Mesh<class_Mesh>` mesh, :ref:`Texture<class_Texture>` texture, :ref:`Texture<class_Texture>` normal_map=null, :ref:`Transform2D<class_Transform2D>` transform=Transform2D( 1, 0, 0, 1, 0, 0 ), :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ) **)**
|
||
|
|
||
|
Draws a :ref:`Mesh<class_Mesh>` in 2D, using the provided texture. See :ref:`MeshInstance2D<class_MeshInstance2D>` for related documentation.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_multiline:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_multiline** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)**
|
||
|
|
||
|
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.
|
||
|
|
||
|
\ **Note:** ``width`` and ``antialiased`` are currently not implemented and have no effect. As a workaround, install the `Antialiased Line2D <https://github.com/godot-extended-libraries/godot-antialiased-line2d>`__ add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_multiline_colors:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_multiline_colors** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`PoolColorArray<class_PoolColorArray>` colors, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)**
|
||
|
|
||
|
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.
|
||
|
|
||
|
\ **Note:** ``width`` and ``antialiased`` are currently not implemented and have no effect. As a workaround, install the `Antialiased Line2D <https://github.com/godot-extended-libraries/godot-antialiased-line2d>`__ add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_multimesh:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_multimesh** **(** :ref:`MultiMesh<class_MultiMesh>` multimesh, :ref:`Texture<class_Texture>` texture, :ref:`Texture<class_Texture>` normal_map=null **)**
|
||
|
|
||
|
Draws a :ref:`MultiMesh<class_MultiMesh>` in 2D with the provided texture. See :ref:`MultiMeshInstance2D<class_MultiMeshInstance2D>` for related documentation.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_polygon:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_polygon** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`PoolColorArray<class_PoolColorArray>` colors, :ref:`PoolVector2Array<class_PoolVector2Array>` uvs=PoolVector2Array( ), :ref:`Texture<class_Texture>` texture=null, :ref:`Texture<class_Texture>` normal_map=null, :ref:`bool<class_bool>` antialiased=false **)**
|
||
|
|
||
|
Draws a solid polygon of any amount 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>`.
|
||
|
|
||
|
\ **Note:** Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the `Antialiased Line2D <https://github.com/godot-extended-libraries/godot-antialiased-line2d>`__ add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_polyline:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_polyline** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)**
|
||
|
|
||
|
Draws interconnected line segments with a uniform ``color`` and ``width`` and optional antialiasing. When drawing large amounts of lines, this is faster than using individual :ref:`draw_line<class_CanvasItem_method_draw_line>` calls. To draw disconnected lines, use :ref:`draw_multiline<class_CanvasItem_method_draw_multiline>` instead. See also :ref:`draw_polygon<class_CanvasItem_method_draw_polygon>`.
|
||
|
|
||
|
\ **Note:** Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the `Antialiased Line2D <https://github.com/godot-extended-libraries/godot-antialiased-line2d>`__ add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_polyline_colors:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_polyline_colors** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`PoolColorArray<class_PoolColorArray>` colors, :ref:`float<class_float>` width=1.0, :ref:`bool<class_bool>` antialiased=false **)**
|
||
|
|
||
|
Draws interconnected line segments with a uniform ``width`` and segment-by-segment coloring, and optional antialiasing. Colors assigned to line segments match by index between ``points`` and ``colors``. When drawing large amounts of lines, this is faster than using individual :ref:`draw_line<class_CanvasItem_method_draw_line>` calls. To draw disconnected lines, use :ref:`draw_multiline_colors<class_CanvasItem_method_draw_multiline_colors>` instead. See also :ref:`draw_polygon<class_CanvasItem_method_draw_polygon>`.
|
||
|
|
||
|
\ **Note:** Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the `Antialiased Line2D <https://github.com/godot-extended-libraries/godot-antialiased-line2d>`__ add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_primitive:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_primitive** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` points, :ref:`PoolColorArray<class_PoolColorArray>` colors, :ref:`PoolVector2Array<class_PoolVector2Array>` uvs, :ref:`Texture<class_Texture>` texture=null, :ref:`float<class_float>` width=1.0, :ref:`Texture<class_Texture>` normal_map=null **)**
|
||
|
|
||
|
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>`.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_rect:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
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, :ref:`bool<class_bool>` antialiased=false **)**
|
||
|
|
||
|
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. If ``antialiased`` is ``true``, the lines will attempt to perform antialiasing using OpenGL line smoothing.
|
||
|
|
||
|
\ **Note:** ``width`` and ``antialiased`` are only effective if ``filled`` is ``false``.
|
||
|
|
||
|
\ **Note:** Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the `Antialiased Line2D <https://github.com/godot-extended-libraries/godot-antialiased-line2d>`__ add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_set_transform:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_set_transform** **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` rotation, :ref:`Vector2<class_Vector2>` scale **)**
|
||
|
|
||
|
Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_set_transform_matrix:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_set_transform_matrix** **(** :ref:`Transform2D<class_Transform2D>` xform **)**
|
||
|
|
||
|
Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_string:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_string** **(** :ref:`Font<class_Font>` font, :ref:`Vector2<class_Vector2>` position, :ref:`String<class_String>` text, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`int<class_int>` clip_w=-1 **)**
|
||
|
|
||
|
Draws ``text`` using the specified ``font`` at the ``position`` (bottom-left corner using the baseline of the font). The text will have its color multiplied by ``modulate``. If ``clip_w`` is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
|
||
|
|
||
|
\ **Example using the default project font:**\
|
||
|
|
||
|
::
|
||
|
|
||
|
# If using this method in a script that redraws constantly, move the
|
||
|
# `default_font` declaration to a member variable assigned in `_ready()`
|
||
|
# so the Control is only created once.
|
||
|
var default_font = Control.new().get_font("font")
|
||
|
draw_string(default_font, Vector2(64, 64), "Hello world")
|
||
|
|
||
|
See also :ref:`Font.draw<class_Font_method_draw>`.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_style_box:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_style_box** **(** :ref:`StyleBox<class_StyleBox>` style_box, :ref:`Rect2<class_Rect2>` rect **)**
|
||
|
|
||
|
Draws a styled rectangle.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_texture:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_texture** **(** :ref:`Texture<class_Texture>` texture, :ref:`Vector2<class_Vector2>` position, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`Texture<class_Texture>` normal_map=null **)**
|
||
|
|
||
|
Draws a texture at a given position.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_texture_rect:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_texture_rect** **(** :ref:`Texture<class_Texture>` texture, :ref:`Rect2<class_Rect2>` rect, :ref:`bool<class_bool>` tile, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_Texture>` normal_map=null **)**
|
||
|
|
||
|
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.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_draw_texture_rect_region:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **draw_texture_rect_region** **(** :ref:`Texture<class_Texture>` texture, :ref:`Rect2<class_Rect2>` rect, :ref:`Rect2<class_Rect2>` src_rect, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture<class_Texture>` normal_map=null, :ref:`bool<class_bool>` clip_uv=true **)**
|
||
|
|
||
|
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.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_force_update_transform:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **force_update_transform** **(** **)**
|
||
|
|
||
|
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.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_get_canvas:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`RID<class_RID>` **get_canvas** **(** **)** |const|
|
||
|
|
||
|
Returns the :ref:`RID<class_RID>` of the :ref:`World2D<class_World2D>` canvas where this item is in.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_get_canvas_item:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`RID<class_RID>` **get_canvas_item** **(** **)** |const|
|
||
|
|
||
|
Returns the canvas item RID used by :ref:`VisualServer<class_VisualServer>` for this item.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_get_canvas_transform:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`Transform2D<class_Transform2D>` **get_canvas_transform** **(** **)** |const|
|
||
|
|
||
|
Returns the transform from the coordinate system of the canvas, this item is in, to the :ref:`Viewport<class_Viewport>`\ s coordinate system.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_get_global_mouse_position:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`Vector2<class_Vector2>` **get_global_mouse_position** **(** **)** |const|
|
||
|
|
||
|
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>`.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_get_global_transform:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`Transform2D<class_Transform2D>` **get_global_transform** **(** **)** |const|
|
||
|
|
||
|
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 is top-level. See also :ref:`set_as_toplevel<class_CanvasItem_method_set_as_toplevel>`.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_get_global_transform_with_canvas:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`Transform2D<class_Transform2D>` **get_global_transform_with_canvas** **(** **)** |const|
|
||
|
|
||
|
Returns the transform from the local coordinate system of this **CanvasItem** to the :ref:`Viewport<class_Viewport>`\ s coordinate system.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_get_local_mouse_position:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`Vector2<class_Vector2>` **get_local_mouse_position** **(** **)** |const|
|
||
|
|
||
|
Returns the mouse's position in this **CanvasItem** using the local coordinate system of this **CanvasItem**.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_get_transform:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`Transform2D<class_Transform2D>` **get_transform** **(** **)** |const|
|
||
|
|
||
|
Returns the transform matrix of this item.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_get_viewport_rect:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`Rect2<class_Rect2>` **get_viewport_rect** **(** **)** |const|
|
||
|
|
||
|
Returns the viewport's boundaries as a :ref:`Rect2<class_Rect2>`.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_get_viewport_transform:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`Transform2D<class_Transform2D>` **get_viewport_transform** **(** **)** |const|
|
||
|
|
||
|
Returns the transform from the coordinate system of the canvas, this item is in, to the :ref:`Viewport<class_Viewport>`\ s embedders coordinate system.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_get_world_2d:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`World2D<class_World2D>` **get_world_2d** **(** **)** |const|
|
||
|
|
||
|
Returns the :ref:`World2D<class_World2D>` where this item is in.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_hide:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **hide** **(** **)**
|
||
|
|
||
|
Hide the **CanvasItem** if it's currently visible. This is equivalent to setting :ref:`visible<class_CanvasItem_property_visible>` to ``false``.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_is_local_transform_notification_enabled:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`bool<class_bool>` **is_local_transform_notification_enabled** **(** **)** |const|
|
||
|
|
||
|
Returns ``true`` if local transform notifications are communicated to children.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_is_set_as_toplevel:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`bool<class_bool>` **is_set_as_toplevel** **(** **)** |const|
|
||
|
|
||
|
Returns ``true`` if the node is set as top-level. See :ref:`set_as_toplevel<class_CanvasItem_method_set_as_toplevel>`.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_is_transform_notification_enabled:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`bool<class_bool>` **is_transform_notification_enabled** **(** **)** |const|
|
||
|
|
||
|
Returns ``true`` if global transform notifications are communicated to children.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_is_visible_in_tree:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`bool<class_bool>` **is_visible_in_tree** **(** **)** |const|
|
||
|
|
||
|
Returns ``true`` if the node is present in the :ref:`SceneTree<class_SceneTree>`, its :ref:`visible<class_CanvasItem_property_visible>` property is ``true`` and all its ancestors are also visible. If any ancestor is hidden, this node will not be visible in the scene tree, and is consequently not drawn (see :ref:`_draw<class_CanvasItem_method__draw>`).
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_make_canvas_position_local:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`Vector2<class_Vector2>` **make_canvas_position_local** **(** :ref:`Vector2<class_Vector2>` screen_point **)** |const|
|
||
|
|
||
|
Assigns ``screen_point`` as this node's new local transform.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_make_input_local:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
:ref:`InputEvent<class_InputEvent>` **make_input_local** **(** :ref:`InputEvent<class_InputEvent>` event **)** |const|
|
||
|
|
||
|
Transformations issued by ``event``'s inputs are applied in local space instead of global space.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_set_as_toplevel:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **set_as_toplevel** **(** :ref:`bool<class_bool>` enable **)**
|
||
|
|
||
|
If ``enable`` is ``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 are not set as top-level. The **CanvasItem** will effectively act as if it was placed as a child of a bare :ref:`Node<class_Node>`. See also :ref:`is_set_as_toplevel<class_CanvasItem_method_is_set_as_toplevel>`.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_set_notify_local_transform:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **set_notify_local_transform** **(** :ref:`bool<class_bool>` enable **)**
|
||
|
|
||
|
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.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_set_notify_transform:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **set_notify_transform** **(** :ref:`bool<class_bool>` enable **)**
|
||
|
|
||
|
If ``enable`` is ``true``, this node will receive :ref:`NOTIFICATION_TRANSFORM_CHANGED<class_CanvasItem_constant_NOTIFICATION_TRANSFORM_CHANGED>` when its global transform changes.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_show:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **show** **(** **)**
|
||
|
|
||
|
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.
|
||
|
|
||
|
.. rst-class:: classref-item-separator
|
||
|
|
||
|
----
|
||
|
|
||
|
.. _class_CanvasItem_method_update:
|
||
|
|
||
|
.. rst-class:: classref-method
|
||
|
|
||
|
void **update** **(** **)**
|
||
|
|
||
|
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.
|
||
|
|
||
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
||
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
||
|
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|
||
|
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
|