class_canvasitem.rst 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_CanvasItem:
  4. CanvasItem
  5. ==========
  6. **Inherits:** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Inherited By:** :ref:`Node2D<class_node2d>`, :ref:`Control<class_control>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Base class of anything 2D.
  12. Member Functions
  13. ----------------
  14. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`_draw<class_CanvasItem__draw>` **(** **)** virtual |
  16. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`edit_set_state<class_CanvasItem_edit_set_state>` **(** var state **)** |
  18. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`edit_get<class_CanvasItem_edit_get>` **(** **)** const |
  20. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`edit_set_rect<class_CanvasItem_edit_set_rect>` **(** :ref:`Rect2<class_rect2>` rect **)** |
  22. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`edit_rotate<class_CanvasItem_edit_rotate>` **(** :ref:`float<class_float>` degrees **)** |
  24. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Rect2<class_rect2>` | :ref:`get_item_rect<class_CanvasItem_get_item_rect>` **(** **)** const |
  26. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`RID<class_rid>` | :ref:`get_canvas_item<class_CanvasItem_get_canvas_item>` **(** **)** const |
  28. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`is_visible<class_CanvasItem_is_visible>` **(** **)** const |
  30. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`is_hidden<class_CanvasItem_is_hidden>` **(** **)** const |
  32. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`show<class_CanvasItem_show>` **(** **)** |
  34. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`hide<class_CanvasItem_hide>` **(** **)** |
  36. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`set_hidden<class_CanvasItem_set_hidden>` **(** :ref:`bool<class_bool>` hidden **)** |
  38. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`update<class_CanvasItem_update>` **(** **)** |
  40. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_as_toplevel<class_CanvasItem_set_as_toplevel>` **(** :ref:`bool<class_bool>` enable **)** |
  42. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`is_set_as_toplevel<class_CanvasItem_is_set_as_toplevel>` **(** **)** const |
  44. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`set_blend_mode<class_CanvasItem_set_blend_mode>` **(** :ref:`int<class_int>` blend_mode **)** |
  46. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`get_blend_mode<class_CanvasItem_get_blend_mode>` **(** **)** const |
  48. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_light_mask<class_CanvasItem_set_light_mask>` **(** :ref:`int<class_int>` light_mask **)** |
  50. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`int<class_int>` | :ref:`get_light_mask<class_CanvasItem_get_light_mask>` **(** **)** const |
  52. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`set_opacity<class_CanvasItem_set_opacity>` **(** :ref:`float<class_float>` opacity **)** |
  54. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`float<class_float>` | :ref:`get_opacity<class_CanvasItem_get_opacity>` **(** **)** const |
  56. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`set_self_opacity<class_CanvasItem_set_self_opacity>` **(** :ref:`float<class_float>` self_opacity **)** |
  58. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`float<class_float>` | :ref:`get_self_opacity<class_CanvasItem_get_self_opacity>` **(** **)** const |
  60. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`set_draw_behind_parent<class_CanvasItem_set_draw_behind_parent>` **(** :ref:`bool<class_bool>` enable **)** |
  62. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`bool<class_bool>` | :ref:`is_draw_behind_parent_enabled<class_CanvasItem_is_draw_behind_parent_enabled>` **(** **)** const |
  64. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | 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 **)** |
  66. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`draw_rect<class_CanvasItem_draw_rect>` **(** :ref:`Rect2<class_rect2>` rect, :ref:`Color<class_color>` color **)** |
  68. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | void | :ref:`draw_circle<class_CanvasItem_draw_circle>` **(** :ref:`Vector2<class_vector2>` pos, :ref:`float<class_float>` radius, :ref:`Color<class_color>` color **)** |
  70. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | void | :ref:`draw_texture<class_CanvasItem_draw_texture>` **(** :ref:`Texture<class_texture>` texture, :ref:`Vector2<class_vector2>` pos, :ref:`Color<class_color>` modulate=Color(1,1,1,1) **)** |
  72. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | 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 **)** |
  74. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | 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 **)** |
  76. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`draw_style_box<class_CanvasItem_draw_style_box>` **(** :ref:`StyleBox<class_stylebox>` style_box, :ref:`Rect2<class_rect2>` rect **)** |
  78. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`draw_primitive<class_CanvasItem_draw_primitive>` **(** :ref:`Vector2Array<class_vector2array>` points, :ref:`ColorArray<class_colorarray>` colors, :ref:`Vector2Array<class_vector2array>` uvs, :ref:`Texture<class_texture>` texture=NULL, :ref:`float<class_float>` width=1 **)** |
  80. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`draw_polygon<class_CanvasItem_draw_polygon>` **(** :ref:`Vector2Array<class_vector2array>` points, :ref:`ColorArray<class_colorarray>` colors, :ref:`Vector2Array<class_vector2array>` uvs=Vector2Array(), :ref:`Texture<class_texture>` texture=NULL **)** |
  82. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`draw_colored_polygon<class_CanvasItem_draw_colored_polygon>` **(** :ref:`Vector2Array<class_vector2array>` points, :ref:`Color<class_color>` color, :ref:`Vector2Array<class_vector2array>` uvs=Vector2Array(), :ref:`Texture<class_texture>` texture=NULL **)** |
  84. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`draw_string<class_CanvasItem_draw_string>` **(** :ref:`Font<class_font>` font, :ref:`Vector2<class_vector2>` pos, :ref:`String<class_string>` text, :ref:`Color<class_color>` modulate=Color(1,1,1,1), :ref:`int<class_int>` clip_w=-1 **)** |
  86. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`float<class_float>` | :ref:`draw_char<class_CanvasItem_draw_char>` **(** :ref:`Font<class_font>` font, :ref:`Vector2<class_vector2>` pos, :ref:`String<class_string>` char, :ref:`String<class_string>` next, :ref:`Color<class_color>` modulate=Color(1,1,1,1) **)** |
  88. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`draw_set_transform<class_CanvasItem_draw_set_transform>` **(** :ref:`Vector2<class_vector2>` pos, :ref:`float<class_float>` rot, :ref:`Vector2<class_vector2>` scale **)** |
  90. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | :ref:`Matrix32<class_matrix32>` | :ref:`get_transform<class_CanvasItem_get_transform>` **(** **)** const |
  92. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`Matrix32<class_matrix32>` | :ref:`get_global_transform<class_CanvasItem_get_global_transform>` **(** **)** const |
  94. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`Matrix32<class_matrix32>` | :ref:`get_global_transform_with_canvas<class_CanvasItem_get_global_transform_with_canvas>` **(** **)** const |
  96. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`Matrix32<class_matrix32>` | :ref:`get_viewport_transform<class_CanvasItem_get_viewport_transform>` **(** **)** const |
  98. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`Rect2<class_rect2>` | :ref:`get_viewport_rect<class_CanvasItem_get_viewport_rect>` **(** **)** const |
  100. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`Matrix32<class_matrix32>` | :ref:`get_canvas_transform<class_CanvasItem_get_canvas_transform>` **(** **)** const |
  102. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`Vector2<class_vector2>` | :ref:`get_local_mouse_pos<class_CanvasItem_get_local_mouse_pos>` **(** **)** const |
  104. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`Vector2<class_vector2>` | :ref:`get_global_mouse_pos<class_CanvasItem_get_global_mouse_pos>` **(** **)** const |
  106. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | :ref:`RID<class_rid>` | :ref:`get_canvas<class_CanvasItem_get_canvas>` **(** **)** const |
  108. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | :ref:`Object<class_object>` | :ref:`get_world_2d<class_CanvasItem_get_world_2d>` **(** **)** const |
  110. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | void | :ref:`set_material<class_CanvasItem_set_material>` **(** :ref:`CanvasItemMaterial<class_canvasitemmaterial>` material **)** |
  112. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | :ref:`CanvasItemMaterial<class_canvasitemmaterial>` | :ref:`get_material<class_CanvasItem_get_material>` **(** **)** const |
  114. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | void | :ref:`set_use_parent_material<class_CanvasItem_set_use_parent_material>` **(** :ref:`bool<class_bool>` enable **)** |
  116. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | :ref:`bool<class_bool>` | :ref:`get_use_parent_material<class_CanvasItem_get_use_parent_material>` **(** **)** const |
  118. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | :ref:`InputEvent<class_inputevent>` | :ref:`make_input_local<class_CanvasItem_make_input_local>` **(** :ref:`InputEvent<class_inputevent>` event **)** const |
  120. +------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. Signals
  122. -------
  123. - **item_rect_changed** **(** **)**
  124. - **draw** **(** **)**
  125. - **visibility_changed** **(** **)**
  126. - **hide** **(** **)**
  127. Numeric Constants
  128. -----------------
  129. - **BLEND_MODE_MIX** = **0** --- Mix blending mode. Colors are assumed to be independent of the alpha (opacity) value.
  130. - **BLEND_MODE_ADD** = **1** --- Additive blending mode.
  131. - **BLEND_MODE_SUB** = **2** --- Subtractive blending mode.
  132. - **BLEND_MODE_MUL** = **3** --- Multiplicative blending mode.
  133. - **BLEND_MODE_PREMULT_ALPHA** = **4** --- Mix blending mode. Colors are assumed to be premultiplied by the alpha (opacity) value.
  134. - **NOTIFICATION_DRAW** = **30** --- CanvasItem is requested to draw.
  135. - **NOTIFICATION_VISIBILITY_CHANGED** = **31** --- Canvas item visibility has changed.
  136. - **NOTIFICATION_ENTER_CANVAS** = **32** --- Canvas item has entered the canvas.
  137. - **NOTIFICATION_EXIT_CANVAS** = **33** --- Canvas item has exited the canvas.
  138. - **NOTIFICATION_TRANSFORM_CHANGED** = **29** --- Canvas item transform has changed. Only received if requested.
  139. Description
  140. -----------
  141. 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.
  142. 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.
  143. 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).
  144. 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.
  145. Ultimately, a transform notification can be requested, which will notify the node that its global position changed in case the parent tree changed.
  146. Member Function Description
  147. ---------------------------
  148. .. _class_CanvasItem__draw:
  149. - void **_draw** **(** **)** virtual
  150. Called (if exists) to draw the canvas item.
  151. .. _class_CanvasItem_edit_set_state:
  152. - void **edit_set_state** **(** var state **)**
  153. Used for editing, returns an opaque value representing the transform state.
  154. .. _class_CanvasItem_edit_get:
  155. - void **edit_get** **(** **)** const
  156. .. _class_CanvasItem_edit_set_rect:
  157. - void **edit_set_rect** **(** :ref:`Rect2<class_rect2>` rect **)**
  158. .. _class_CanvasItem_edit_rotate:
  159. - void **edit_rotate** **(** :ref:`float<class_float>` degrees **)**
  160. Used for editing, handle rotation.
  161. .. _class_CanvasItem_get_item_rect:
  162. - :ref:`Rect2<class_rect2>` **get_item_rect** **(** **)** const
  163. Return a rect containing the editable contents of the item.
  164. .. _class_CanvasItem_get_canvas_item:
  165. - :ref:`RID<class_rid>` **get_canvas_item** **(** **)** const
  166. Return the canvas item RID used by :ref:`VisualServer<class_visualserver>` for this item.
  167. .. _class_CanvasItem_is_visible:
  168. - :ref:`bool<class_bool>` **is_visible** **(** **)** const
  169. Return true if this CanvasItem is visible. It may be invisible because itself or a parent canvas item is hidden.
  170. .. _class_CanvasItem_is_hidden:
  171. - :ref:`bool<class_bool>` **is_hidden** **(** **)** const
  172. Return true if this CanvasItem is hidden. Note that the CanvasItem may not be visible, but as long as it's not hidden (:ref:`hide<class_CanvasItem_hide>` called) the function will return false.
  173. .. _class_CanvasItem_show:
  174. - void **show** **(** **)**
  175. Show the CanvasItem currently hidden.
  176. .. _class_CanvasItem_hide:
  177. - void **hide** **(** **)**
  178. Hide the CanvasItem currently visible.
  179. .. _class_CanvasItem_set_hidden:
  180. - void **set_hidden** **(** :ref:`bool<class_bool>` hidden **)**
  181. .. _class_CanvasItem_update:
  182. - void **update** **(** **)**
  183. Queue the CanvasItem for update. NOTIFICATION_DRAW will be called on idle time to request redraw.
  184. .. _class_CanvasItem_set_as_toplevel:
  185. - void **set_as_toplevel** **(** :ref:`bool<class_bool>` enable **)**
  186. Set as toplevel. This means that it will not inherit transform from parent canvas items.
  187. .. _class_CanvasItem_is_set_as_toplevel:
  188. - :ref:`bool<class_bool>` **is_set_as_toplevel** **(** **)** const
  189. Return if set as toplevel. See :ref:`set_as_toplevel<class_CanvasItem_set_as_toplevel>`.
  190. .. _class_CanvasItem_set_blend_mode:
  191. - void **set_blend_mode** **(** :ref:`int<class_int>` blend_mode **)**
  192. Set the blending mode from enum BLEND_MODE\_\*.
  193. .. _class_CanvasItem_get_blend_mode:
  194. - :ref:`int<class_int>` **get_blend_mode** **(** **)** const
  195. Return the current blending mode from enum BLEND_MODE\_\*.
  196. .. _class_CanvasItem_set_light_mask:
  197. - void **set_light_mask** **(** :ref:`int<class_int>` light_mask **)**
  198. .. _class_CanvasItem_get_light_mask:
  199. - :ref:`int<class_int>` **get_light_mask** **(** **)** const
  200. .. _class_CanvasItem_set_opacity:
  201. - void **set_opacity** **(** :ref:`float<class_float>` opacity **)**
  202. Set canvas item opacity. This will affect the canvas item and all the children.
  203. .. _class_CanvasItem_get_opacity:
  204. - :ref:`float<class_float>` **get_opacity** **(** **)** const
  205. Return the canvas item opacity. This affects the canvas item and all the children.
  206. .. _class_CanvasItem_set_self_opacity:
  207. - void **set_self_opacity** **(** :ref:`float<class_float>` self_opacity **)**
  208. Set canvas item self-opacity. This does not affect the opacity of children items.
  209. .. _class_CanvasItem_get_self_opacity:
  210. - :ref:`float<class_float>` **get_self_opacity** **(** **)** const
  211. Return the canvas item self-opacity.
  212. .. _class_CanvasItem_set_draw_behind_parent:
  213. - void **set_draw_behind_parent** **(** :ref:`bool<class_bool>` enable **)**
  214. Sets whether the canvas item is drawn behind its parent.
  215. .. _class_CanvasItem_is_draw_behind_parent_enabled:
  216. - :ref:`bool<class_bool>` **is_draw_behind_parent_enabled** **(** **)** const
  217. Return whether the item is drawn behind its parent.
  218. .. _class_CanvasItem_draw_line:
  219. - void **draw_line** **(** :ref:`Vector2<class_vector2>` from, :ref:`Vector2<class_vector2>` to, :ref:`Color<class_color>` color, :ref:`float<class_float>` width=1 **)**
  220. Draw a line from a 2D point to another, with a given color and width.
  221. .. _class_CanvasItem_draw_rect:
  222. - void **draw_rect** **(** :ref:`Rect2<class_rect2>` rect, :ref:`Color<class_color>` color **)**
  223. Draw a colored rectangle.
  224. .. _class_CanvasItem_draw_circle:
  225. - void **draw_circle** **(** :ref:`Vector2<class_vector2>` pos, :ref:`float<class_float>` radius, :ref:`Color<class_color>` color **)**
  226. Draw a colored circle.
  227. .. _class_CanvasItem_draw_texture:
  228. - void **draw_texture** **(** :ref:`Texture<class_texture>` texture, :ref:`Vector2<class_vector2>` pos, :ref:`Color<class_color>` modulate=Color(1,1,1,1) **)**
  229. Draw a texture at a given position.
  230. .. _class_CanvasItem_draw_texture_rect:
  231. - 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 **)**
  232. Draw a textured rectangle at a given position, optionally modulated by a color. Transpose swaps the x and y coordinates when reading the texture.
  233. .. _class_CanvasItem_draw_texture_rect_region:
  234. - 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 **)**
  235. 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.
  236. .. _class_CanvasItem_draw_style_box:
  237. - void **draw_style_box** **(** :ref:`StyleBox<class_stylebox>` style_box, :ref:`Rect2<class_rect2>` rect **)**
  238. Draw a styled rectangle.
  239. .. _class_CanvasItem_draw_primitive:
  240. - void **draw_primitive** **(** :ref:`Vector2Array<class_vector2array>` points, :ref:`ColorArray<class_colorarray>` colors, :ref:`Vector2Array<class_vector2array>` uvs, :ref:`Texture<class_texture>` texture=NULL, :ref:`float<class_float>` width=1 **)**
  241. 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.
  242. .. _class_CanvasItem_draw_polygon:
  243. - void **draw_polygon** **(** :ref:`Vector2Array<class_vector2array>` points, :ref:`ColorArray<class_colorarray>` colors, :ref:`Vector2Array<class_vector2array>` uvs=Vector2Array(), :ref:`Texture<class_texture>` texture=NULL **)**
  244. Draw a polygon of any amount of points, convex or concave.
  245. .. _class_CanvasItem_draw_colored_polygon:
  246. - void **draw_colored_polygon** **(** :ref:`Vector2Array<class_vector2array>` points, :ref:`Color<class_color>` color, :ref:`Vector2Array<class_vector2array>` uvs=Vector2Array(), :ref:`Texture<class_texture>` texture=NULL **)**
  247. Draw a colored polygon of any amount of points, convex or concave.
  248. .. _class_CanvasItem_draw_string:
  249. - void **draw_string** **(** :ref:`Font<class_font>` font, :ref:`Vector2<class_vector2>` pos, :ref:`String<class_string>` text, :ref:`Color<class_color>` modulate=Color(1,1,1,1), :ref:`int<class_int>` clip_w=-1 **)**
  250. Draw a string using a custom font.
  251. .. _class_CanvasItem_draw_char:
  252. - :ref:`float<class_float>` **draw_char** **(** :ref:`Font<class_font>` font, :ref:`Vector2<class_vector2>` pos, :ref:`String<class_string>` char, :ref:`String<class_string>` next, :ref:`Color<class_color>` modulate=Color(1,1,1,1) **)**
  253. Draw a string character using a custom font. Returns the advance, depending on the char width and kerning with an optional next char.
  254. .. _class_CanvasItem_draw_set_transform:
  255. - void **draw_set_transform** **(** :ref:`Vector2<class_vector2>` pos, :ref:`float<class_float>` rot, :ref:`Vector2<class_vector2>` scale **)**
  256. Set a custom transform for drawing. Anything drawn afterwards will be transformed by this.
  257. .. _class_CanvasItem_get_transform:
  258. - :ref:`Matrix32<class_matrix32>` **get_transform** **(** **)** const
  259. .. _class_CanvasItem_get_global_transform:
  260. - :ref:`Matrix32<class_matrix32>` **get_global_transform** **(** **)** const
  261. .. _class_CanvasItem_get_global_transform_with_canvas:
  262. - :ref:`Matrix32<class_matrix32>` **get_global_transform_with_canvas** **(** **)** const
  263. .. _class_CanvasItem_get_viewport_transform:
  264. - :ref:`Matrix32<class_matrix32>` **get_viewport_transform** **(** **)** const
  265. .. _class_CanvasItem_get_viewport_rect:
  266. - :ref:`Rect2<class_rect2>` **get_viewport_rect** **(** **)** const
  267. .. _class_CanvasItem_get_canvas_transform:
  268. - :ref:`Matrix32<class_matrix32>` **get_canvas_transform** **(** **)** const
  269. .. _class_CanvasItem_get_local_mouse_pos:
  270. - :ref:`Vector2<class_vector2>` **get_local_mouse_pos** **(** **)** const
  271. .. _class_CanvasItem_get_global_mouse_pos:
  272. - :ref:`Vector2<class_vector2>` **get_global_mouse_pos** **(** **)** const
  273. .. _class_CanvasItem_get_canvas:
  274. - :ref:`RID<class_rid>` **get_canvas** **(** **)** const
  275. .. _class_CanvasItem_get_world_2d:
  276. - :ref:`Object<class_object>` **get_world_2d** **(** **)** const
  277. .. _class_CanvasItem_set_material:
  278. - void **set_material** **(** :ref:`CanvasItemMaterial<class_canvasitemmaterial>` material **)**
  279. .. _class_CanvasItem_get_material:
  280. - :ref:`CanvasItemMaterial<class_canvasitemmaterial>` **get_material** **(** **)** const
  281. .. _class_CanvasItem_set_use_parent_material:
  282. - void **set_use_parent_material** **(** :ref:`bool<class_bool>` enable **)**
  283. .. _class_CanvasItem_get_use_parent_material:
  284. - :ref:`bool<class_bool>` **get_use_parent_material** **(** **)** const
  285. .. _class_CanvasItem_make_input_local:
  286. - :ref:`InputEvent<class_inputevent>` **make_input_local** **(** :ref:`InputEvent<class_inputevent>` event **)** const