mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
421 lines
46 KiB
ReStructuredText
421 lines
46 KiB
ReStructuredText
.. 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:`Node2D<class_node2d>`, :ref:`Control<class_control>`
|
|
|
|
**Category:** Core
|
|
|
|
Brief Description
|
|
-----------------
|
|
|
|
Base class of anything 2D.
|
|
|
|
Member Functions
|
|
----------------
|
|
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`_draw<class_CanvasItem__draw>` **(** **)** virtual |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`draw_char<class_CanvasItem_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_draw_circle>` **(** :ref:`Vector2<class_vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_color>` color **)** |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_colored_polygon<class_CanvasItem_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_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_polygon<class_CanvasItem_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_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_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_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_draw_rect>` **(** :ref:`Rect2<class_rect2>` rect, :ref:`Color<class_color>` color, :ref:`bool<class_bool>` filled=true **)** |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_set_transform<class_CanvasItem_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_draw_set_transform_matrix>` **(** :ref:`Transform2D<class_transform2d>` xform **)** |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_string<class_CanvasItem_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_draw_style_box>` **(** :ref:`StyleBox<class_stylebox>` style_box, :ref:`Rect2<class_rect2>` rect **)** |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`draw_texture<class_CanvasItem_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_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_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 **)** |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`RID<class_rid>` | :ref:`get_canvas<class_CanvasItem_get_canvas>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`RID<class_rid>` | :ref:`get_canvas_item<class_CanvasItem_get_canvas_item>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Transform2D<class_transform2d>` | :ref:`get_canvas_transform<class_CanvasItem_get_canvas_transform>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2<class_vector2>` | :ref:`get_global_mouse_position<class_CanvasItem_get_global_mouse_position>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Transform2D<class_transform2d>` | :ref:`get_global_transform<class_CanvasItem_get_global_transform>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Transform2D<class_transform2d>` | :ref:`get_global_transform_with_canvas<class_CanvasItem_get_global_transform_with_canvas>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2<class_vector2>` | :ref:`get_local_mouse_position<class_CanvasItem_get_local_mouse_position>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Transform2D<class_transform2d>` | :ref:`get_transform<class_CanvasItem_get_transform>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_rect2>` | :ref:`get_viewport_rect<class_CanvasItem_get_viewport_rect>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Transform2D<class_transform2d>` | :ref:`get_viewport_transform<class_CanvasItem_get_viewport_transform>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`World2D<class_world2d>` | :ref:`get_world_2d<class_CanvasItem_get_world_2d>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`hide<class_CanvasItem_hide>` **(** **)** |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_local_transform_notification_enabled<class_CanvasItem_is_local_transform_notification_enabled>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_set_as_toplevel<class_CanvasItem_is_set_as_toplevel>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_transform_notification_enabled<class_CanvasItem_is_transform_notification_enabled>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_visible_in_tree<class_CanvasItem_is_visible_in_tree>` **(** **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2<class_vector2>` | :ref:`make_canvas_position_local<class_CanvasItem_make_canvas_position_local>` **(** :ref:`Vector2<class_vector2>` screen_point **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`InputEvent<class_inputevent>` | :ref:`make_input_local<class_CanvasItem_make_input_local>` **(** :ref:`InputEvent<class_inputevent>` event **)** const |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_as_toplevel<class_CanvasItem_set_as_toplevel>` **(** :ref:`bool<class_bool>` enable **)** |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_notify_local_transform<class_CanvasItem_set_notify_local_transform>` **(** :ref:`bool<class_bool>` enable **)** |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_notify_transform<class_CanvasItem_set_notify_transform>` **(** :ref:`bool<class_bool>` enable **)** |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`show<class_CanvasItem_show>` **(** **)** |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`update<class_CanvasItem_update>` **(** **)** |
|
|
+----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Signals
|
|
-------
|
|
|
|
.. _class_CanvasItem_draw:
|
|
|
|
- **draw** **(** **)**
|
|
|
|
Emitted when the CanvasItem must redraw. This can only be connected realtime, as deferred will not allow drawing.
|
|
|
|
.. _class_CanvasItem_hide:
|
|
|
|
- **hide** **(** **)**
|
|
|
|
Emitted when becoming hidden.
|
|
|
|
.. _class_CanvasItem_item_rect_changed:
|
|
|
|
- **item_rect_changed** **(** **)**
|
|
|
|
Emitted when the item rect has changed.
|
|
|
|
.. _class_CanvasItem_visibility_changed:
|
|
|
|
- **visibility_changed** **(** **)**
|
|
|
|
Emitted when the visibility (hidden/visible) changes.
|
|
|
|
|
|
Member Variables
|
|
----------------
|
|
|
|
.. _class_CanvasItem_light_mask:
|
|
|
|
- :ref:`int<class_int>` **light_mask**
|
|
|
|
.. _class_CanvasItem_material:
|
|
|
|
- :ref:`Material<class_material>` **material**
|
|
|
|
.. _class_CanvasItem_modulate:
|
|
|
|
- :ref:`Color<class_color>` **modulate**
|
|
|
|
.. _class_CanvasItem_self_modulate:
|
|
|
|
- :ref:`Color<class_color>` **self_modulate**
|
|
|
|
.. _class_CanvasItem_show_behind_parent:
|
|
|
|
- :ref:`bool<class_bool>` **show_behind_parent**
|
|
|
|
.. _class_CanvasItem_show_on_top:
|
|
|
|
- :ref:`bool<class_bool>` **show_on_top**
|
|
|
|
.. _class_CanvasItem_use_parent_material:
|
|
|
|
- :ref:`bool<class_bool>` **use_parent_material**
|
|
|
|
.. _class_CanvasItem_visible:
|
|
|
|
- :ref:`bool<class_bool>` **visible**
|
|
|
|
|
|
Numeric Constants
|
|
-----------------
|
|
|
|
- **BLEND_MODE_MIX** = **0** --- Mix blending mode. Colors are assumed to be independent of the alpha (opacity) value.
|
|
- **BLEND_MODE_ADD** = **1** --- Additive blending mode.
|
|
- **BLEND_MODE_SUB** = **2** --- Subtractive blending mode.
|
|
- **BLEND_MODE_MUL** = **3** --- Multiplicative blending mode.
|
|
- **BLEND_MODE_PREMULT_ALPHA** = **4** --- Mix blending mode. Colors are assumed to be premultiplied by the alpha (opacity) value.
|
|
- **NOTIFICATION_TRANSFORM_CHANGED** = **29** --- Canvas item transform has changed. Only received if requested.
|
|
- **NOTIFICATION_DRAW** = **30** --- CanvasItem is requested to draw.
|
|
- **NOTIFICATION_VISIBILITY_CHANGED** = **31** --- Canvas item visibility has changed.
|
|
- **NOTIFICATION_ENTER_CANVAS** = **32** --- Canvas item has entered the canvas.
|
|
- **NOTIFICATION_EXIT_CANVAS** = **33** --- Canvas item has exited the canvas.
|
|
|
|
Description
|
|
-----------
|
|
|
|
Base class of anything 2D. Canvas items are laid out in a tree and children inherit and extend the transform of their parent. CanvasItem is extended by :ref:`Control<class_control>`, for anything GUI related, and by :ref:`Node2D<class_node2d>` for anything 2D engine related.
|
|
|
|
Any CanvasItem can draw. For this, the "update" function must be called, then NOTIFICATION_DRAW will be received on idle time to request redraw. Because of this, canvas items don't need to be redraw on every frame, improving the performance significantly. Several functions for drawing on the CanvasItem are provided (see draw\_\* functions). They can only be used inside the notification, signal or _draw() overrides function, though.
|
|
|
|
Canvas items are draw in tree order. By default, children are on top of their parents so a root CanvasItem will be drawn behind everything (this can be changed per item though).
|
|
|
|
Canvas items can also be hidden (hiding also their subtree). They provide many means for changing standard parameters such as opacity (for it and the subtree) and self opacity, 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.
|
|
|
|
Member Function Description
|
|
---------------------------
|
|
|
|
.. _class_CanvasItem__draw:
|
|
|
|
- void **_draw** **(** **)** virtual
|
|
|
|
Called (if exists) to draw the canvas item.
|
|
|
|
.. _class_CanvasItem_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 ) **)**
|
|
|
|
Draw a string character using a custom font. Returns the advance, depending on the char width and kerning with an optional next char.
|
|
|
|
.. _class_CanvasItem_draw_circle:
|
|
|
|
- void **draw_circle** **(** :ref:`Vector2<class_vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_color>` color **)**
|
|
|
|
Draw a colored circle.
|
|
|
|
.. _class_CanvasItem_draw_colored_polygon:
|
|
|
|
- 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 **)**
|
|
|
|
Draw a colored polygon of any amount of points, convex or concave.
|
|
|
|
.. _class_CanvasItem_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, :ref:`bool<class_bool>` antialiased=false **)**
|
|
|
|
Draw a line from a 2D point to another, with a given color and width. It can be optionally antialiased.
|
|
|
|
.. _class_CanvasItem_draw_polygon:
|
|
|
|
- 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 **)**
|
|
|
|
Draw a polygon of any amount of points, convex or concave.
|
|
|
|
.. _class_CanvasItem_draw_polyline:
|
|
|
|
- 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 **)**
|
|
|
|
.. _class_CanvasItem_draw_polyline_colors:
|
|
|
|
- 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 **)**
|
|
|
|
.. _class_CanvasItem_draw_primitive:
|
|
|
|
- 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 **)**
|
|
|
|
Draw 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_draw_rect:
|
|
|
|
- void **draw_rect** **(** :ref:`Rect2<class_rect2>` rect, :ref:`Color<class_color>` color, :ref:`bool<class_bool>` filled=true **)**
|
|
|
|
Draw a colored rectangle.
|
|
|
|
.. _class_CanvasItem_draw_set_transform:
|
|
|
|
- void **draw_set_transform** **(** :ref:`Vector2<class_vector2>` position, :ref:`float<class_float>` rotation, :ref:`Vector2<class_vector2>` scale **)**
|
|
|
|
Set a custom transform for drawing. Anything drawn afterwards will be transformed by this.
|
|
|
|
.. _class_CanvasItem_draw_set_transform_matrix:
|
|
|
|
- void **draw_set_transform_matrix** **(** :ref:`Transform2D<class_transform2d>` xform **)**
|
|
|
|
.. _class_CanvasItem_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 **)**
|
|
|
|
Draw a string using a custom font.
|
|
|
|
.. _class_CanvasItem_draw_style_box:
|
|
|
|
- void **draw_style_box** **(** :ref:`StyleBox<class_stylebox>` style_box, :ref:`Rect2<class_rect2>` rect **)**
|
|
|
|
Draw a styled rectangle.
|
|
|
|
.. _class_CanvasItem_draw_texture:
|
|
|
|
- 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 **)**
|
|
|
|
Draw a texture at a given position.
|
|
|
|
.. _class_CanvasItem_draw_texture_rect:
|
|
|
|
- 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 **)**
|
|
|
|
Draw a textured rectangle at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture.
|
|
|
|
.. _class_CanvasItem_draw_texture_rect_region:
|
|
|
|
- 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 **)**
|
|
|
|
Draw a textured rectangle region at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture.
|
|
|
|
.. _class_CanvasItem_get_canvas:
|
|
|
|
- :ref:`RID<class_rid>` **get_canvas** **(** **)** const
|
|
|
|
Return the :ref:`RID<class_rid>` of the :ref:`World2D<class_world2d>` canvas where this item is in.
|
|
|
|
.. _class_CanvasItem_get_canvas_item:
|
|
|
|
- :ref:`RID<class_rid>` **get_canvas_item** **(** **)** const
|
|
|
|
Return the canvas item RID used by :ref:`VisualServer<class_visualserver>` for this item.
|
|
|
|
.. _class_CanvasItem_get_canvas_transform:
|
|
|
|
- :ref:`Transform2D<class_transform2d>` **get_canvas_transform** **(** **)** const
|
|
|
|
Get the transform matrix of this item's canvas.
|
|
|
|
.. _class_CanvasItem_get_global_mouse_position:
|
|
|
|
- :ref:`Vector2<class_vector2>` **get_global_mouse_position** **(** **)** const
|
|
|
|
Get the global position of the mouse.
|
|
|
|
.. _class_CanvasItem_get_global_transform:
|
|
|
|
- :ref:`Transform2D<class_transform2d>` **get_global_transform** **(** **)** const
|
|
|
|
Get the global transform matrix of this item.
|
|
|
|
.. _class_CanvasItem_get_global_transform_with_canvas:
|
|
|
|
- :ref:`Transform2D<class_transform2d>` **get_global_transform_with_canvas** **(** **)** const
|
|
|
|
Get the global transform matrix of this item in relation to the canvas.
|
|
|
|
.. _class_CanvasItem_get_local_mouse_position:
|
|
|
|
- :ref:`Vector2<class_vector2>` **get_local_mouse_position** **(** **)** const
|
|
|
|
Get the mouse position relative to this item's position.
|
|
|
|
.. _class_CanvasItem_get_transform:
|
|
|
|
- :ref:`Transform2D<class_transform2d>` **get_transform** **(** **)** const
|
|
|
|
Get the transform matrix of this item.
|
|
|
|
.. _class_CanvasItem_get_viewport_rect:
|
|
|
|
- :ref:`Rect2<class_rect2>` **get_viewport_rect** **(** **)** const
|
|
|
|
Get the viewport's boundaries as a :ref:`Rect2<class_rect2>`.
|
|
|
|
.. _class_CanvasItem_get_viewport_transform:
|
|
|
|
- :ref:`Transform2D<class_transform2d>` **get_viewport_transform** **(** **)** const
|
|
|
|
Get this item's transform in relation to the viewport.
|
|
|
|
.. _class_CanvasItem_get_world_2d:
|
|
|
|
- :ref:`World2D<class_world2d>` **get_world_2d** **(** **)** const
|
|
|
|
Get the :ref:`World2D<class_world2d>` where this item is in.
|
|
|
|
.. _class_CanvasItem_hide:
|
|
|
|
- void **hide** **(** **)**
|
|
|
|
Hide the CanvasItem currently visible.
|
|
|
|
.. _class_CanvasItem_is_local_transform_notification_enabled:
|
|
|
|
- :ref:`bool<class_bool>` **is_local_transform_notification_enabled** **(** **)** const
|
|
|
|
.. _class_CanvasItem_is_set_as_toplevel:
|
|
|
|
- :ref:`bool<class_bool>` **is_set_as_toplevel** **(** **)** const
|
|
|
|
Return if set as toplevel. See :ref:`set_as_toplevel<class_CanvasItem_set_as_toplevel>`.
|
|
|
|
.. _class_CanvasItem_is_transform_notification_enabled:
|
|
|
|
- :ref:`bool<class_bool>` **is_transform_notification_enabled** **(** **)** const
|
|
|
|
.. _class_CanvasItem_is_visible_in_tree:
|
|
|
|
- :ref:`bool<class_bool>` **is_visible_in_tree** **(** **)** const
|
|
|
|
.. _class_CanvasItem_make_canvas_position_local:
|
|
|
|
- :ref:`Vector2<class_vector2>` **make_canvas_position_local** **(** :ref:`Vector2<class_vector2>` screen_point **)** const
|
|
|
|
.. _class_CanvasItem_make_input_local:
|
|
|
|
- :ref:`InputEvent<class_inputevent>` **make_input_local** **(** :ref:`InputEvent<class_inputevent>` event **)** const
|
|
|
|
.. _class_CanvasItem_set_as_toplevel:
|
|
|
|
- void **set_as_toplevel** **(** :ref:`bool<class_bool>` enable **)**
|
|
|
|
Set as top level. This means that it will not inherit transform from parent canvas items.
|
|
|
|
.. _class_CanvasItem_set_notify_local_transform:
|
|
|
|
- void **set_notify_local_transform** **(** :ref:`bool<class_bool>` enable **)**
|
|
|
|
.. _class_CanvasItem_set_notify_transform:
|
|
|
|
- void **set_notify_transform** **(** :ref:`bool<class_bool>` enable **)**
|
|
|
|
.. _class_CanvasItem_show:
|
|
|
|
- void **show** **(** **)**
|
|
|
|
Show the CanvasItem currently hidden.
|
|
|
|
.. _class_CanvasItem_update:
|
|
|
|
- void **update** **(** **)**
|
|
|
|
Queue the CanvasItem for update. ``NOTIFICATION_DRAW`` will be called on idle time to request redraw.
|
|
|
|
|