class_canvasitem.rst 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the CanvasItem.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_CanvasItem:
  5. CanvasItem
  6. ==========
  7. **Inherits:** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Inherited By:** :ref:`Node2D<class_node2d>`, :ref:`Control<class_control>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Base class of anything 2D.
  13. Member Functions
  14. ----------------
  15. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`_draw<class_CanvasItem__draw>` **(** **)** virtual |
  17. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :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 ) **)** |
  19. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`draw_circle<class_CanvasItem_draw_circle>` **(** :ref:`Vector2<class_vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_color>` color **)** |
  21. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | 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 **)** |
  23. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | 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 **)** |
  25. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | 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 **)** |
  27. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | 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 **)** |
  29. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | 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 **)** |
  31. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | 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 **)** |
  33. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`draw_rect<class_CanvasItem_draw_rect>` **(** :ref:`Rect2<class_rect2>` rect, :ref:`Color<class_color>` color, :ref:`bool<class_bool>` filled=true **)** |
  35. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | 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 **)** |
  37. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`draw_set_transform_matrix<class_CanvasItem_draw_set_transform_matrix>` **(** :ref:`Transform2D<class_transform2d>` xform **)** |
  39. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | 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 **)** |
  41. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`draw_style_box<class_CanvasItem_draw_style_box>` **(** :ref:`StyleBox<class_stylebox>` style_box, :ref:`Rect2<class_rect2>` rect **)** |
  43. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | 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 **)** |
  45. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | 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 **)** |
  47. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | 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 **)** |
  49. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`Variant<class_variant>` | :ref:`edit_get_state<class_CanvasItem_edit_get_state>` **(** **)** const |
  51. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`edit_rotate<class_CanvasItem_edit_rotate>` **(** :ref:`float<class_float>` degrees **)** |
  53. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`edit_set_rect<class_CanvasItem_edit_set_rect>` **(** :ref:`Rect2<class_rect2>` rect **)** |
  55. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`edit_set_state<class_CanvasItem_edit_set_state>` **(** :ref:`Variant<class_variant>` state **)** |
  57. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`RID<class_rid>` | :ref:`get_canvas<class_CanvasItem_get_canvas>` **(** **)** const |
  59. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`RID<class_rid>` | :ref:`get_canvas_item<class_CanvasItem_get_canvas_item>` **(** **)** const |
  61. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`Transform2D<class_transform2d>` | :ref:`get_canvas_transform<class_CanvasItem_get_canvas_transform>` **(** **)** const |
  63. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`Vector2<class_vector2>` | :ref:`get_global_mouse_position<class_CanvasItem_get_global_mouse_position>` **(** **)** const |
  65. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Transform2D<class_transform2d>` | :ref:`get_global_transform<class_CanvasItem_get_global_transform>` **(** **)** const |
  67. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`Transform2D<class_transform2d>` | :ref:`get_global_transform_with_canvas<class_CanvasItem_get_global_transform_with_canvas>` **(** **)** const |
  69. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`Rect2<class_rect2>` | :ref:`get_item_and_children_rect<class_CanvasItem_get_item_and_children_rect>` **(** **)** const |
  71. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`Rect2<class_rect2>` | :ref:`get_item_rect<class_CanvasItem_get_item_rect>` **(** **)** const |
  73. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`int<class_int>` | :ref:`get_light_mask<class_CanvasItem_get_light_mask>` **(** **)** const |
  75. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`Vector2<class_vector2>` | :ref:`get_local_mouse_position<class_CanvasItem_get_local_mouse_position>` **(** **)** const |
  77. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`Material<class_material>` | :ref:`get_material<class_CanvasItem_get_material>` **(** **)** const |
  79. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`Color<class_color>` | :ref:`get_modulate<class_CanvasItem_get_modulate>` **(** **)** const |
  81. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`Color<class_color>` | :ref:`get_self_modulate<class_CanvasItem_get_self_modulate>` **(** **)** const |
  83. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`Transform2D<class_transform2d>` | :ref:`get_transform<class_CanvasItem_get_transform>` **(** **)** const |
  85. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`bool<class_bool>` | :ref:`get_use_parent_material<class_CanvasItem_get_use_parent_material>` **(** **)** const |
  87. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`Rect2<class_rect2>` | :ref:`get_viewport_rect<class_CanvasItem_get_viewport_rect>` **(** **)** const |
  89. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`Transform2D<class_transform2d>` | :ref:`get_viewport_transform<class_CanvasItem_get_viewport_transform>` **(** **)** const |
  91. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`World2D<class_world2d>` | :ref:`get_world_2d<class_CanvasItem_get_world_2d>` **(** **)** const |
  93. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | void | :ref:`hide<class_CanvasItem_hide>` **(** **)** |
  95. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`bool<class_bool>` | :ref:`is_draw_behind_parent_enabled<class_CanvasItem_is_draw_behind_parent_enabled>` **(** **)** const |
  97. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`bool<class_bool>` | :ref:`is_local_transform_notification_enabled<class_CanvasItem_is_local_transform_notification_enabled>` **(** **)** const |
  99. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`bool<class_bool>` | :ref:`is_set_as_toplevel<class_CanvasItem_is_set_as_toplevel>` **(** **)** const |
  101. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`bool<class_bool>` | :ref:`is_transform_notification_enabled<class_CanvasItem_is_transform_notification_enabled>` **(** **)** const |
  103. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`bool<class_bool>` | :ref:`is_visible<class_CanvasItem_is_visible>` **(** **)** const |
  105. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`bool<class_bool>` | :ref:`is_visible_in_tree<class_CanvasItem_is_visible_in_tree>` **(** **)** const |
  107. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`Vector2<class_vector2>` | :ref:`make_canvas_position_local<class_CanvasItem_make_canvas_position_local>` **(** :ref:`Vector2<class_vector2>` screen_point **)** const |
  109. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`InputEvent<class_inputevent>` | :ref:`make_input_local<class_CanvasItem_make_input_local>` **(** :ref:`InputEvent<class_inputevent>` event **)** const |
  111. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | void | :ref:`set_as_toplevel<class_CanvasItem_set_as_toplevel>` **(** :ref:`bool<class_bool>` enable **)** |
  113. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | void | :ref:`set_draw_behind_parent<class_CanvasItem_set_draw_behind_parent>` **(** :ref:`bool<class_bool>` enable **)** |
  115. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | void | :ref:`set_light_mask<class_CanvasItem_set_light_mask>` **(** :ref:`int<class_int>` light_mask **)** |
  117. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | void | :ref:`set_material<class_CanvasItem_set_material>` **(** :ref:`Material<class_material>` material **)** |
  119. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | void | :ref:`set_modulate<class_CanvasItem_set_modulate>` **(** :ref:`Color<class_color>` modulate **)** |
  121. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | void | :ref:`set_notify_local_transform<class_CanvasItem_set_notify_local_transform>` **(** :ref:`bool<class_bool>` enable **)** |
  123. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | void | :ref:`set_notify_transform<class_CanvasItem_set_notify_transform>` **(** :ref:`bool<class_bool>` enable **)** |
  125. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | void | :ref:`set_self_modulate<class_CanvasItem_set_self_modulate>` **(** :ref:`Color<class_color>` self_modulate **)** |
  127. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | void | :ref:`set_use_parent_material<class_CanvasItem_set_use_parent_material>` **(** :ref:`bool<class_bool>` enable **)** |
  129. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | void | :ref:`set_visible<class_CanvasItem_set_visible>` **(** :ref:`bool<class_bool>` visible **)** |
  131. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | void | :ref:`show<class_CanvasItem_show>` **(** **)** |
  133. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | void | :ref:`update<class_CanvasItem_update>` **(** **)** |
  135. +----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. Signals
  137. -------
  138. - **draw** **(** **)**
  139. Emitted when the CanvasItem must redraw. This can only be connected realtime, as deferred will not allow drawing.
  140. - **hide** **(** **)**
  141. Emitted when becoming hidden.
  142. - **item_rect_changed** **(** **)**
  143. Emitted when the item rect has changed.
  144. - **visibility_changed** **(** **)**
  145. Emitted when the visibility (hidden/visible) changes.
  146. Member Variables
  147. ----------------
  148. - :ref:`int<class_int>` **light_mask**
  149. - :ref:`Material<class_material>` **material**
  150. - :ref:`Color<class_color>` **modulate**
  151. - :ref:`Color<class_color>` **self_modulate**
  152. - :ref:`bool<class_bool>` **show_behind_parent**
  153. - :ref:`bool<class_bool>` **show_on_top**
  154. - :ref:`bool<class_bool>` **use_parent_material**
  155. - :ref:`bool<class_bool>` **visible**
  156. Numeric Constants
  157. -----------------
  158. - **BLEND_MODE_MIX** = **0** --- Mix blending mode. Colors are assumed to be independent of the alpha (opacity) value.
  159. - **BLEND_MODE_ADD** = **1** --- Additive blending mode.
  160. - **BLEND_MODE_SUB** = **2** --- Subtractive blending mode.
  161. - **BLEND_MODE_MUL** = **3** --- Multiplicative blending mode.
  162. - **BLEND_MODE_PREMULT_ALPHA** = **4** --- Mix blending mode. Colors are assumed to be premultiplied by the alpha (opacity) value.
  163. - **NOTIFICATION_DRAW** = **30** --- CanvasItem is requested to draw.
  164. - **NOTIFICATION_VISIBILITY_CHANGED** = **31** --- Canvas item visibility has changed.
  165. - **NOTIFICATION_ENTER_CANVAS** = **32** --- Canvas item has entered the canvas.
  166. - **NOTIFICATION_EXIT_CANVAS** = **33** --- Canvas item has exited the canvas.
  167. - **NOTIFICATION_TRANSFORM_CHANGED** = **29** --- Canvas item transform has changed. Only received if requested.
  168. Description
  169. -----------
  170. 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.
  171. 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.
  172. 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).
  173. 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.
  174. Ultimately, a transform notification can be requested, which will notify the node that its global position changed in case the parent tree changed.
  175. Member Function Description
  176. ---------------------------
  177. .. _class_CanvasItem__draw:
  178. - void **_draw** **(** **)** virtual
  179. Called (if exists) to draw the canvas item.
  180. .. _class_CanvasItem_draw_char:
  181. - :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 ) **)**
  182. Draw a string character using a custom font. Returns the advance, depending on the char width and kerning with an optional next char.
  183. .. _class_CanvasItem_draw_circle:
  184. - void **draw_circle** **(** :ref:`Vector2<class_vector2>` position, :ref:`float<class_float>` radius, :ref:`Color<class_color>` color **)**
  185. Draw a colored circle.
  186. .. _class_CanvasItem_draw_colored_polygon:
  187. - 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 **)**
  188. Draw a colored polygon of any amount of points, convex or concave.
  189. .. _class_CanvasItem_draw_line:
  190. - 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 **)**
  191. Draw a line from a 2D point to another, with a given color and width. It can be optionally antialiased.
  192. .. _class_CanvasItem_draw_polygon:
  193. - 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 **)**
  194. Draw a polygon of any amount of points, convex or concave.
  195. .. _class_CanvasItem_draw_polyline:
  196. - 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 **)**
  197. .. _class_CanvasItem_draw_polyline_colors:
  198. - 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 **)**
  199. .. _class_CanvasItem_draw_primitive:
  200. - 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 **)**
  201. 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.
  202. .. _class_CanvasItem_draw_rect:
  203. - void **draw_rect** **(** :ref:`Rect2<class_rect2>` rect, :ref:`Color<class_color>` color, :ref:`bool<class_bool>` filled=true **)**
  204. Draw a colored rectangle.
  205. .. _class_CanvasItem_draw_set_transform:
  206. - void **draw_set_transform** **(** :ref:`Vector2<class_vector2>` position, :ref:`float<class_float>` rotation, :ref:`Vector2<class_vector2>` scale **)**
  207. Set a custom transform for drawing. Anything drawn afterwards will be transformed by this.
  208. .. _class_CanvasItem_draw_set_transform_matrix:
  209. - void **draw_set_transform_matrix** **(** :ref:`Transform2D<class_transform2d>` xform **)**
  210. .. _class_CanvasItem_draw_string:
  211. - 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 **)**
  212. Draw a string using a custom font.
  213. .. _class_CanvasItem_draw_style_box:
  214. - void **draw_style_box** **(** :ref:`StyleBox<class_stylebox>` style_box, :ref:`Rect2<class_rect2>` rect **)**
  215. Draw a styled rectangle.
  216. .. _class_CanvasItem_draw_texture:
  217. - 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 **)**
  218. Draw a texture at a given position.
  219. .. _class_CanvasItem_draw_texture_rect:
  220. - 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 **)**
  221. Draw a textured rectangle at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture.
  222. .. _class_CanvasItem_draw_texture_rect_region:
  223. - 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 **)**
  224. 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.
  225. .. _class_CanvasItem_edit_get_state:
  226. - :ref:`Variant<class_variant>` **edit_get_state** **(** **)** const
  227. Used for editing, returns an opaque value representing the transform state.
  228. .. _class_CanvasItem_edit_rotate:
  229. - void **edit_rotate** **(** :ref:`float<class_float>` degrees **)**
  230. Used for editing, handle rotation.
  231. .. _class_CanvasItem_edit_set_rect:
  232. - void **edit_set_rect** **(** :ref:`Rect2<class_rect2>` rect **)**
  233. .. _class_CanvasItem_edit_set_state:
  234. - void **edit_set_state** **(** :ref:`Variant<class_variant>` state **)**
  235. Set the transform state of this CanvasItem. For :ref:`Node2D<class_node2d>`, this is an :ref:`Array<class_array>` with (in order) a :ref:`Vector2<class_vector2>` for position, a float for rotation (radians) and another :ref:`Vector2<class_vector2>` for scale. For :ref:`Control<class_control>` this is a :ref:`Rect2<class_rect2>` with the position and size.
  236. .. _class_CanvasItem_get_canvas:
  237. - :ref:`RID<class_rid>` **get_canvas** **(** **)** const
  238. Return the :ref:`RID<class_rid>` of the :ref:`World2D<class_world2d>` canvas where this item is in.
  239. .. _class_CanvasItem_get_canvas_item:
  240. - :ref:`RID<class_rid>` **get_canvas_item** **(** **)** const
  241. Return the canvas item RID used by :ref:`VisualServer<class_visualserver>` for this item.
  242. .. _class_CanvasItem_get_canvas_transform:
  243. - :ref:`Transform2D<class_transform2d>` **get_canvas_transform** **(** **)** const
  244. Get the transform matrix of this item's canvas.
  245. .. _class_CanvasItem_get_global_mouse_position:
  246. - :ref:`Vector2<class_vector2>` **get_global_mouse_position** **(** **)** const
  247. Get the global position of the mouse.
  248. .. _class_CanvasItem_get_global_transform:
  249. - :ref:`Transform2D<class_transform2d>` **get_global_transform** **(** **)** const
  250. Get the global transform matrix of this item.
  251. .. _class_CanvasItem_get_global_transform_with_canvas:
  252. - :ref:`Transform2D<class_transform2d>` **get_global_transform_with_canvas** **(** **)** const
  253. Get the global transform matrix of this item in relation to the canvas.
  254. .. _class_CanvasItem_get_item_and_children_rect:
  255. - :ref:`Rect2<class_rect2>` **get_item_and_children_rect** **(** **)** const
  256. Get a :ref:`Rect2<class_rect2>` with the boundaries of this item and its children.
  257. .. _class_CanvasItem_get_item_rect:
  258. - :ref:`Rect2<class_rect2>` **get_item_rect** **(** **)** const
  259. Return a rect containing the editable boundaries of the item.
  260. .. _class_CanvasItem_get_light_mask:
  261. - :ref:`int<class_int>` **get_light_mask** **(** **)** const
  262. Get this item's light mask number.
  263. .. _class_CanvasItem_get_local_mouse_position:
  264. - :ref:`Vector2<class_vector2>` **get_local_mouse_position** **(** **)** const
  265. Get the mouse position relative to this item's position.
  266. .. _class_CanvasItem_get_material:
  267. - :ref:`Material<class_material>` **get_material** **(** **)** const
  268. Get the material of this item.
  269. .. _class_CanvasItem_get_modulate:
  270. - :ref:`Color<class_color>` **get_modulate** **(** **)** const
  271. Get the modulate of the CanvasItem, which affects children items too.
  272. .. _class_CanvasItem_get_self_modulate:
  273. - :ref:`Color<class_color>` **get_self_modulate** **(** **)** const
  274. Get the self-modulate of the CanvasItem.
  275. .. _class_CanvasItem_get_transform:
  276. - :ref:`Transform2D<class_transform2d>` **get_transform** **(** **)** const
  277. Get the transform matrix of this item.
  278. .. _class_CanvasItem_get_use_parent_material:
  279. - :ref:`bool<class_bool>` **get_use_parent_material** **(** **)** const
  280. Get whether this item uses its parent's material.
  281. .. _class_CanvasItem_get_viewport_rect:
  282. - :ref:`Rect2<class_rect2>` **get_viewport_rect** **(** **)** const
  283. Get the viewport's boundaries as a :ref:`Rect2<class_rect2>`.
  284. .. _class_CanvasItem_get_viewport_transform:
  285. - :ref:`Transform2D<class_transform2d>` **get_viewport_transform** **(** **)** const
  286. Get this item's transform in relation to the viewport.
  287. .. _class_CanvasItem_get_world_2d:
  288. - :ref:`World2D<class_world2d>` **get_world_2d** **(** **)** const
  289. Get the :ref:`World2D<class_world2d>` where this item is in.
  290. .. _class_CanvasItem_hide:
  291. - void **hide** **(** **)**
  292. Hide the CanvasItem currently visible.
  293. .. _class_CanvasItem_is_draw_behind_parent_enabled:
  294. - :ref:`bool<class_bool>` **is_draw_behind_parent_enabled** **(** **)** const
  295. Return whether the item is drawn behind its parent.
  296. .. _class_CanvasItem_is_local_transform_notification_enabled:
  297. - :ref:`bool<class_bool>` **is_local_transform_notification_enabled** **(** **)** const
  298. .. _class_CanvasItem_is_set_as_toplevel:
  299. - :ref:`bool<class_bool>` **is_set_as_toplevel** **(** **)** const
  300. Return if set as toplevel. See :ref:`set_as_toplevel<class_CanvasItem_set_as_toplevel>`.
  301. .. _class_CanvasItem_is_transform_notification_enabled:
  302. - :ref:`bool<class_bool>` **is_transform_notification_enabled** **(** **)** const
  303. .. _class_CanvasItem_is_visible:
  304. - :ref:`bool<class_bool>` **is_visible** **(** **)** const
  305. Return true if this CanvasItem is visible. It may be invisible because itself or a parent canvas item is hidden.
  306. .. _class_CanvasItem_is_visible_in_tree:
  307. - :ref:`bool<class_bool>` **is_visible_in_tree** **(** **)** const
  308. .. _class_CanvasItem_make_canvas_position_local:
  309. - :ref:`Vector2<class_vector2>` **make_canvas_position_local** **(** :ref:`Vector2<class_vector2>` screen_point **)** const
  310. .. _class_CanvasItem_make_input_local:
  311. - :ref:`InputEvent<class_inputevent>` **make_input_local** **(** :ref:`InputEvent<class_inputevent>` event **)** const
  312. .. _class_CanvasItem_set_as_toplevel:
  313. - void **set_as_toplevel** **(** :ref:`bool<class_bool>` enable **)**
  314. Set as top level. This means that it will not inherit transform from parent canvas items.
  315. .. _class_CanvasItem_set_draw_behind_parent:
  316. - void **set_draw_behind_parent** **(** :ref:`bool<class_bool>` enable **)**
  317. Set whether the canvas item is drawn behind its parent.
  318. .. _class_CanvasItem_set_light_mask:
  319. - void **set_light_mask** **(** :ref:`int<class_int>` light_mask **)**
  320. Set the ligtht mask number of this item.
  321. .. _class_CanvasItem_set_material:
  322. - void **set_material** **(** :ref:`Material<class_material>` material **)**
  323. Set the material of this item.
  324. .. _class_CanvasItem_set_modulate:
  325. - void **set_modulate** **(** :ref:`Color<class_color>` modulate **)**
  326. Set the modulate of the CanvasItem. This *affects* the modulation of children items.
  327. .. _class_CanvasItem_set_notify_local_transform:
  328. - void **set_notify_local_transform** **(** :ref:`bool<class_bool>` enable **)**
  329. .. _class_CanvasItem_set_notify_transform:
  330. - void **set_notify_transform** **(** :ref:`bool<class_bool>` enable **)**
  331. .. _class_CanvasItem_set_self_modulate:
  332. - void **set_self_modulate** **(** :ref:`Color<class_color>` self_modulate **)**
  333. Set the self-modulate of the CanvasItem. This does not affect the modulation of children items.
  334. .. _class_CanvasItem_set_use_parent_material:
  335. - void **set_use_parent_material** **(** :ref:`bool<class_bool>` enable **)**
  336. Set whether or not this item should use its parent's material.
  337. .. _class_CanvasItem_set_visible:
  338. - void **set_visible** **(** :ref:`bool<class_bool>` visible **)**
  339. Set whether this item should be visible or not.
  340. Note that a hidden CanvasItem will make all children hidden too, so no matter what is set here this item won't be shown if its parent or grandparents nodes are hidden.
  341. .. _class_CanvasItem_show:
  342. - void **show** **(** **)**
  343. Show the CanvasItem currently hidden.
  344. .. _class_CanvasItem_update:
  345. - void **update** **(** **)**
  346. Queue the CanvasItem for update. ``NOTIFICATION_DRAW`` will be called on idle time to request redraw.