mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
799 lines
92 KiB
ReStructuredText
799 lines
92 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the CanvasItem.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _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.
|
|
|
|
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>` must be called, then :ref:`NOTIFICATION_DRAW<class_CanvasItem_constant_NOTIFICATION_DRAW>` will be received on idle time to request redraw. Because of this, canvas items don't need to be redrawn on every frame, improving the performance significantly. Several functions for drawing on the ``CanvasItem`` are provided (see ``draw_*`` functions). However, they can only be used inside the :ref:`Object._notification<class_Object_method__notification>`, signal or :ref:`_draw<class_CanvasItem_method__draw>` virtual functions.
|
|
|
|
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.
|
|
|
|
Tutorials
|
|
---------
|
|
|
|
- :doc:`../tutorials/2d/2d_transforms`
|
|
|
|
- :doc:`../tutorials/2d/custom_drawing_in_2d`
|
|
|
|
Properties
|
|
----------
|
|
|
|
+-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
|
|
| :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:`TextureFilter<enum_CanvasItem_TextureFilter>` | :ref:`texture_filter<class_CanvasItem_property_texture_filter>` | ``0`` |
|
|
+-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
|
|
| :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` | :ref:`texture_repeat<class_CanvasItem_property_texture_repeat>` | ``0`` |
|
|
+-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
|
|
| :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`` |
|
|
+-----------------------------------------------------+---------------------------------------------------------------------------+-------------------------+
|
|
|
|
Methods
|
|
-------
|
|
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| 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:`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:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs=PackedVector2Array( ), :ref:`Texture2D<class_Texture2D>` texture=null, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| 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 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_mesh<class_CanvasItem_method_draw_mesh>` **(** :ref:`Mesh<class_Mesh>` mesh, :ref:`Texture2D<class_Texture2D>` texture, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`Transform2D<class_Transform2D>` transform=Transform2D( 1, 0, 0, 1, 0, 0 ), :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| 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 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| 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 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_multimesh<class_CanvasItem_method_draw_multimesh>` **(** :ref:`MultiMesh<class_MultiMesh>` multimesh, :ref:`Texture2D<class_Texture2D>` texture, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_polygon<class_CanvasItem_method_draw_polygon>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs=PackedVector2Array( ), :ref:`Texture2D<class_Texture2D>` texture=null, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| 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 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| 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 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_primitive<class_CanvasItem_method_draw_primitive>` **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs, :ref:`Texture2D<class_Texture2D>` texture=null, :ref:`float<class_float>` width=1.0, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| 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 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| 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:`Texture2D<class_Texture2D>` texture, :ref:`Vector2<class_Vector2>` position, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_texture_rect<class_CanvasItem_method_draw_texture_rect>` **(** :ref:`Texture2D<class_Texture2D>` texture, :ref:`Rect2<class_Rect2>` rect, :ref:`bool<class_bool>` tile, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_texture_rect_region<class_CanvasItem_method_draw_texture_rect_region>` **(** :ref:`Texture2D<class_Texture2D>` texture, :ref:`Rect2<class_Rect2>` rect, :ref:`Rect2<class_Rect2>` src_rect, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` clip_uv=true, :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| 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>` **(** **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Signals
|
|
-------
|
|
|
|
.. _class_CanvasItem_signal_draw:
|
|
|
|
- **draw** **(** **)**
|
|
|
|
Emitted when the ``CanvasItem`` must redraw. This can only be connected realtime, as deferred will not allow drawing.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_signal_hide:
|
|
|
|
- **hide** **(** **)**
|
|
|
|
Emitted when becoming hidden.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_signal_item_rect_changed:
|
|
|
|
- **item_rect_changed** **(** **)**
|
|
|
|
Emitted when the item rect has changed.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_signal_visibility_changed:
|
|
|
|
- **visibility_changed** **(** **)**
|
|
|
|
Emitted when the visibility (hidden/visible) changes.
|
|
|
|
Enumerations
|
|
------------
|
|
|
|
.. _enum_CanvasItem_TextureFilter:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_FILTER_PARENT_NODE:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_FILTER_NEAREST:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_FILTER_LINEAR:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_FILTER_MAX:
|
|
|
|
enum **TextureFilter**:
|
|
|
|
- **TEXTURE_FILTER_PARENT_NODE** = **0** --- The ``CanvasItem`` will inherit the filter from its parent.
|
|
|
|
- **TEXTURE_FILTER_NEAREST** = **1** --- The texture filter reads from the nearest pixel only. The simplest and fastest method of filtering. Useful for pixel art.
|
|
|
|
- **TEXTURE_FILTER_LINEAR** = **2** --- The texture filter blends between the nearest four pixels. Use this for most cases where you want to avoid a pixelated style.
|
|
|
|
- **TEXTURE_FILTER_NEAREST_WITH_MIPMAPS** = **3**
|
|
|
|
- **TEXTURE_FILTER_LINEAR_WITH_MIPMAPS** = **4**
|
|
|
|
- **TEXTURE_FILTER_NEAREST_WITH_MIPMAPS_ANISOTROPIC** = **5**
|
|
|
|
- **TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC** = **6**
|
|
|
|
- **TEXTURE_FILTER_MAX** = **7** --- Represents the size of the :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` enum.
|
|
|
|
----
|
|
|
|
.. _enum_CanvasItem_TextureRepeat:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_REPEAT_PARENT_NODE:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_REPEAT_DISABLED:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_REPEAT_ENABLED:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_REPEAT_MIRROR:
|
|
|
|
.. _class_CanvasItem_constant_TEXTURE_REPEAT_MAX:
|
|
|
|
enum **TextureRepeat**:
|
|
|
|
- **TEXTURE_REPEAT_PARENT_NODE** = **0** --- The ``CanvasItem`` will inherit the filter from its parent.
|
|
|
|
- **TEXTURE_REPEAT_DISABLED** = **1** --- Texture will not repeat.
|
|
|
|
- **TEXTURE_REPEAT_ENABLED** = **2** --- Texture will repeat normally.
|
|
|
|
- **TEXTURE_REPEAT_MIRROR** = **3** --- Texture will repeat in a 2x2 tiled mode, where elements at even positions are mirrored.
|
|
|
|
- **TEXTURE_REPEAT_MAX** = **4** --- Represents the size of the :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` enum.
|
|
|
|
Constants
|
|
---------
|
|
|
|
.. _class_CanvasItem_constant_NOTIFICATION_TRANSFORM_CHANGED:
|
|
|
|
.. _class_CanvasItem_constant_NOTIFICATION_DRAW:
|
|
|
|
.. _class_CanvasItem_constant_NOTIFICATION_VISIBILITY_CHANGED:
|
|
|
|
.. _class_CanvasItem_constant_NOTIFICATION_ENTER_CANVAS:
|
|
|
|
.. _class_CanvasItem_constant_NOTIFICATION_EXIT_CANVAS:
|
|
|
|
- **NOTIFICATION_TRANSFORM_CHANGED** = **2000** --- The ``CanvasItem``'s transform has changed. This notification is only received if enabled by :ref:`set_notify_transform<class_CanvasItem_method_set_notify_transform>` or :ref:`set_notify_local_transform<class_CanvasItem_method_set_notify_local_transform>`.
|
|
|
|
- **NOTIFICATION_DRAW** = **30** --- The ``CanvasItem`` is requested to draw.
|
|
|
|
- **NOTIFICATION_VISIBILITY_CHANGED** = **31** --- The ``CanvasItem``'s visibility has changed.
|
|
|
|
- **NOTIFICATION_ENTER_CANVAS** = **32** --- The ``CanvasItem`` has entered the canvas.
|
|
|
|
- **NOTIFICATION_EXIT_CANVAS** = **33** --- The ``CanvasItem`` has exited the canvas.
|
|
|
|
Property Descriptions
|
|
---------------------
|
|
|
|
.. _class_CanvasItem_property_light_mask:
|
|
|
|
- :ref:`int<class_int>` **light_mask**
|
|
|
|
+-----------+-----------------------+
|
|
| *Default* | ``1`` |
|
|
+-----------+-----------------------+
|
|
| *Setter* | set_light_mask(value) |
|
|
+-----------+-----------------------+
|
|
| *Getter* | get_light_mask() |
|
|
+-----------+-----------------------+
|
|
|
|
The rendering layers in which this ``CanvasItem`` responds to :ref:`Light2D<class_Light2D>` nodes.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_property_material:
|
|
|
|
- :ref:`Material<class_Material>` **material**
|
|
|
|
+----------+---------------------+
|
|
| *Setter* | set_material(value) |
|
|
+----------+---------------------+
|
|
| *Getter* | get_material() |
|
|
+----------+---------------------+
|
|
|
|
The material applied to textures on this ``CanvasItem``.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_property_modulate:
|
|
|
|
- :ref:`Color<class_Color>` **modulate**
|
|
|
|
+-----------+-------------------------+
|
|
| *Default* | ``Color( 1, 1, 1, 1 )`` |
|
|
+-----------+-------------------------+
|
|
| *Setter* | set_modulate(value) |
|
|
+-----------+-------------------------+
|
|
| *Getter* | get_modulate() |
|
|
+-----------+-------------------------+
|
|
|
|
The color applied to textures on this ``CanvasItem``.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_property_self_modulate:
|
|
|
|
- :ref:`Color<class_Color>` **self_modulate**
|
|
|
|
+-----------+--------------------------+
|
|
| *Default* | ``Color( 1, 1, 1, 1 )`` |
|
|
+-----------+--------------------------+
|
|
| *Setter* | set_self_modulate(value) |
|
|
+-----------+--------------------------+
|
|
| *Getter* | get_self_modulate() |
|
|
+-----------+--------------------------+
|
|
|
|
The color applied to textures on this ``CanvasItem``. This is not inherited by children ``CanvasItem``\ s.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_property_show_behind_parent:
|
|
|
|
- :ref:`bool<class_bool>` **show_behind_parent**
|
|
|
|
+-----------+---------------------------------+
|
|
| *Default* | ``false`` |
|
|
+-----------+---------------------------------+
|
|
| *Setter* | set_draw_behind_parent(value) |
|
|
+-----------+---------------------------------+
|
|
| *Getter* | is_draw_behind_parent_enabled() |
|
|
+-----------+---------------------------------+
|
|
|
|
If ``true``, the object draws behind its parent.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_property_show_on_top:
|
|
|
|
- :ref:`bool<class_bool>` **show_on_top**
|
|
|
|
If ``true``, the object draws on top of its parent.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_property_texture_filter:
|
|
|
|
- :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` **texture_filter**
|
|
|
|
+-----------+---------------------------+
|
|
| *Default* | ``0`` |
|
|
+-----------+---------------------------+
|
|
| *Setter* | set_texture_filter(value) |
|
|
+-----------+---------------------------+
|
|
| *Getter* | get_texture_filter() |
|
|
+-----------+---------------------------+
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_property_texture_repeat:
|
|
|
|
- :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` **texture_repeat**
|
|
|
|
+-----------+---------------------------+
|
|
| *Default* | ``0`` |
|
|
+-----------+---------------------------+
|
|
| *Setter* | set_texture_repeat(value) |
|
|
+-----------+---------------------------+
|
|
| *Getter* | get_texture_repeat() |
|
|
+-----------+---------------------------+
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_property_use_parent_material:
|
|
|
|
- :ref:`bool<class_bool>` **use_parent_material**
|
|
|
|
+-----------+--------------------------------+
|
|
| *Default* | ``false`` |
|
|
+-----------+--------------------------------+
|
|
| *Setter* | set_use_parent_material(value) |
|
|
+-----------+--------------------------------+
|
|
| *Getter* | get_use_parent_material() |
|
|
+-----------+--------------------------------+
|
|
|
|
If ``true``, the parent ``CanvasItem``'s :ref:`material<class_CanvasItem_property_material>` property is used as this one's material.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_property_visible:
|
|
|
|
- :ref:`bool<class_bool>` **visible**
|
|
|
|
+-----------+--------------------+
|
|
| *Default* | ``true`` |
|
|
+-----------+--------------------+
|
|
| *Setter* | set_visible(value) |
|
|
+-----------+--------------------+
|
|
| *Getter* | is_visible() |
|
|
+-----------+--------------------+
|
|
|
|
If ``true``, this ``CanvasItem`` is drawn. For controls that inherit :ref:`Popup<class_Popup>`, the correct way to make them visible is to call one of the multiple ``popup*()`` functions instead.
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_CanvasItem_method__draw:
|
|
|
|
- void **_draw** **(** **)** virtual
|
|
|
|
Overridable function called by the engine (if defined) to draw the canvas item.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_arc:
|
|
|
|
- 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 **)**
|
|
|
|
Draws an arc between the given angles. The larger the value of ``point_count``, the smoother the curve.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_char:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_circle:
|
|
|
|
- void **draw_circle** **(** :ref:`Vector2<class_Vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_Color>` color **)**
|
|
|
|
Draws a colored circle.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_colored_polygon:
|
|
|
|
- void **draw_colored_polygon** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs=PackedVector2Array( ), :ref:`Texture2D<class_Texture2D>` texture=null, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
|
|
|
|
Draws a colored polygon of any amount of points, convex or concave.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_line:
|
|
|
|
- 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 **)**
|
|
|
|
Draws a line from a 2D point to another, with a given color and width.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_mesh:
|
|
|
|
- void **draw_mesh** **(** :ref:`Mesh<class_Mesh>` mesh, :ref:`Texture2D<class_Texture2D>` texture, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`Transform2D<class_Transform2D>` transform=Transform2D( 1, 0, 0, 1, 0, 0 ), :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
|
|
|
|
Draws a :ref:`Mesh<class_Mesh>` in 2D, using the provided texture. See :ref:`MeshInstance2D<class_MeshInstance2D>` for related documentation.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_multiline:
|
|
|
|
- void **draw_multiline** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0 **)**
|
|
|
|
Draws multiple, parallel lines with a uniform ``color``.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_multiline_colors:
|
|
|
|
- void **draw_multiline_colors** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`float<class_float>` width=1.0 **)**
|
|
|
|
Draws multiple, parallel lines with a uniform ``width`` and segment-by-segment coloring. Colors assigned to line segments match by index between ``points`` and ``colors``.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_multimesh:
|
|
|
|
- void **draw_multimesh** **(** :ref:`MultiMesh<class_MultiMesh>` multimesh, :ref:`Texture2D<class_Texture2D>` texture, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
|
|
|
|
Draws a :ref:`MultiMesh<class_MultiMesh>` in 2D with the provided texture. See :ref:`MultiMeshInstance2D<class_MultiMeshInstance2D>` for related documentation.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_polygon:
|
|
|
|
- void **draw_polygon** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs=PackedVector2Array( ), :ref:`Texture2D<class_Texture2D>` texture=null, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
|
|
|
|
Draws a polygon of any amount of points, convex or concave.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_polyline:
|
|
|
|
- void **draw_polyline** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`Color<class_Color>` color, :ref:`float<class_float>` width=1.0 **)**
|
|
|
|
Draws interconnected line segments with a uniform ``color`` and ``width``.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_polyline_colors:
|
|
|
|
- void **draw_polyline_colors** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`float<class_float>` width=1.0 **)**
|
|
|
|
Draws interconnected line segments with a uniform ``width`` and segment-by-segment coloring. Colors assigned to line segments match by index between ``points`` and ``colors``.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_primitive:
|
|
|
|
- void **draw_primitive** **(** :ref:`PackedVector2Array<class_PackedVector2Array>` points, :ref:`PackedColorArray<class_PackedColorArray>` colors, :ref:`PackedVector2Array<class_PackedVector2Array>` uvs, :ref:`Texture2D<class_Texture2D>` texture=null, :ref:`float<class_float>` width=1.0, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
|
|
|
|
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.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_rect:
|
|
|
|
- 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 **)**
|
|
|
|
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.
|
|
|
|
**Note:** ``width`` is only effective if ``filled`` is ``false``.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_set_transform:
|
|
|
|
- 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.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_set_transform_matrix:
|
|
|
|
- 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.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_string:
|
|
|
|
- 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 a string using a custom font.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_style_box:
|
|
|
|
- void **draw_style_box** **(** :ref:`StyleBox<class_StyleBox>` style_box, :ref:`Rect2<class_Rect2>` rect **)**
|
|
|
|
Draws a styled rectangle.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_texture:
|
|
|
|
- void **draw_texture** **(** :ref:`Texture2D<class_Texture2D>` texture, :ref:`Vector2<class_Vector2>` position, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
|
|
|
|
Draws a texture at a given position.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_texture_rect:
|
|
|
|
- void **draw_texture_rect** **(** :ref:`Texture2D<class_Texture2D>` texture, :ref:`Rect2<class_Rect2>` rect, :ref:`bool<class_bool>` tile, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
|
|
|
|
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.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_draw_texture_rect_region:
|
|
|
|
- void **draw_texture_rect_region** **(** :ref:`Texture2D<class_Texture2D>` texture, :ref:`Rect2<class_Rect2>` rect, :ref:`Rect2<class_Rect2>` src_rect, :ref:`Color<class_Color>` modulate=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` transpose=false, :ref:`Texture2D<class_Texture2D>` normal_map=null, :ref:`Texture2D<class_Texture2D>` specular_map=null, :ref:`Color<class_Color>` specular_shininess=Color( 1, 1, 1, 1 ), :ref:`bool<class_bool>` clip_uv=true, :ref:`TextureFilter<enum_CanvasItem_TextureFilter>` texture_filter=0, :ref:`TextureRepeat<enum_CanvasItem_TextureRepeat>` texture_repeat=0 **)**
|
|
|
|
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.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_force_update_transform:
|
|
|
|
- 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.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_get_canvas:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_get_canvas_item:
|
|
|
|
- :ref:`RID<class_RID>` **get_canvas_item** **(** **)** const
|
|
|
|
Returns the canvas item RID used by :ref:`VisualServer<class_VisualServer>` for this item.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_get_canvas_transform:
|
|
|
|
- :ref:`Transform2D<class_Transform2D>` **get_canvas_transform** **(** **)** const
|
|
|
|
Returns the transform matrix of this item's canvas.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_get_global_mouse_position:
|
|
|
|
- :ref:`Vector2<class_Vector2>` **get_global_mouse_position** **(** **)** const
|
|
|
|
Returns the global position of the mouse.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_get_global_transform:
|
|
|
|
- :ref:`Transform2D<class_Transform2D>` **get_global_transform** **(** **)** const
|
|
|
|
Returns the global transform matrix of this item.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_get_global_transform_with_canvas:
|
|
|
|
- :ref:`Transform2D<class_Transform2D>` **get_global_transform_with_canvas** **(** **)** const
|
|
|
|
Returns the global transform matrix of this item in relation to the canvas.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_get_local_mouse_position:
|
|
|
|
- :ref:`Vector2<class_Vector2>` **get_local_mouse_position** **(** **)** const
|
|
|
|
Returns the mouse position relative to this item's position.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_get_transform:
|
|
|
|
- :ref:`Transform2D<class_Transform2D>` **get_transform** **(** **)** const
|
|
|
|
Returns the transform matrix of this item.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_get_viewport_rect:
|
|
|
|
- :ref:`Rect2<class_Rect2>` **get_viewport_rect** **(** **)** const
|
|
|
|
Returns the viewport's boundaries as a :ref:`Rect2<class_Rect2>`.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_get_viewport_transform:
|
|
|
|
- :ref:`Transform2D<class_Transform2D>` **get_viewport_transform** **(** **)** const
|
|
|
|
Returns this item's transform in relation to the viewport.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_get_world_2d:
|
|
|
|
- :ref:`World2D<class_World2D>` **get_world_2d** **(** **)** const
|
|
|
|
Returns the :ref:`World2D<class_World2D>` where this item is in.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_hide:
|
|
|
|
- void **hide** **(** **)**
|
|
|
|
Hide the ``CanvasItem`` if it's currently visible.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_is_local_transform_notification_enabled:
|
|
|
|
- :ref:`bool<class_bool>` **is_local_transform_notification_enabled** **(** **)** const
|
|
|
|
Returns ``true`` if local transform notifications are communicated to children.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_is_set_as_toplevel:
|
|
|
|
- :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>`.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_is_transform_notification_enabled:
|
|
|
|
- :ref:`bool<class_bool>` **is_transform_notification_enabled** **(** **)** const
|
|
|
|
Returns ``true`` if global transform notifications are communicated to children.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_is_visible_in_tree:
|
|
|
|
- :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 its inherited visibility is also ``true``.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_make_canvas_position_local:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_make_input_local:
|
|
|
|
- :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.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_set_as_toplevel:
|
|
|
|
- void **set_as_toplevel** **(** :ref:`bool<class_bool>` enable **)**
|
|
|
|
If ``enable`` is ``true``, the node won't inherit its transform from parent canvas items.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_set_notify_local_transform:
|
|
|
|
- void **set_notify_local_transform** **(** :ref:`bool<class_bool>` enable **)**
|
|
|
|
If ``enable`` is ``true``, children will be updated with local transform data.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_set_notify_transform:
|
|
|
|
- void **set_notify_transform** **(** :ref:`bool<class_bool>` enable **)**
|
|
|
|
If ``enable`` is ``true``, children will be updated with global transform data.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_show:
|
|
|
|
- void **show** **(** **)**
|
|
|
|
Show the ``CanvasItem`` if it's currently hidden. For controls that inherit :ref:`Popup<class_Popup>`, the correct way to make them visible is to call one of the multiple ``popup*()`` functions instead.
|
|
|
|
----
|
|
|
|
.. _class_CanvasItem_method_update:
|
|
|
|
- void **update** **(** **)**
|
|
|
|
Queue the ``CanvasItem`` for update. :ref:`NOTIFICATION_DRAW<class_CanvasItem_constant_NOTIFICATION_DRAW>` will be called on idle time to request redraw.
|
|
|