class_texturerect.rst 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the TextureRect.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_TextureRect:
  5. TextureRect
  6. ===========
  7. **Inherits:** :ref:`Control<class_control>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Draws a sprite or a texture inside a User Interface. The texture can tile or not.
  12. Member Functions
  13. ----------------
  14. +--------------------------------+--------------------------------------------------------------------------------------------------------------+
  15. | :ref:`int<class_int>` | :ref:`get_stretch_mode<class_TextureRect_get_stretch_mode>` **(** **)** const |
  16. +--------------------------------+--------------------------------------------------------------------------------------------------------------+
  17. | :ref:`Texture<class_texture>` | :ref:`get_texture<class_TextureRect_get_texture>` **(** **)** const |
  18. +--------------------------------+--------------------------------------------------------------------------------------------------------------+
  19. | :ref:`bool<class_bool>` | :ref:`has_expand<class_TextureRect_has_expand>` **(** **)** const |
  20. +--------------------------------+--------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`set_expand<class_TextureRect_set_expand>` **(** :ref:`bool<class_bool>` enable **)** |
  22. +--------------------------------+--------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`set_stretch_mode<class_TextureRect_set_stretch_mode>` **(** :ref:`int<class_int>` stretch_mode **)** |
  24. +--------------------------------+--------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`set_texture<class_TextureRect_set_texture>` **(** :ref:`Texture<class_texture>` texture **)** |
  26. +--------------------------------+--------------------------------------------------------------------------------------------------------------+
  27. Member Variables
  28. ----------------
  29. - :ref:`bool<class_bool>` **expand** - If [code]true[/code], the texture scales to fit its bounding rectangle. Default value: [code]false[/code].
  30. - :ref:`int<class_int>` **stretch_mode** - Controls the texture's behavior when you resize the node's bounding rectangle. Set it to one of the [code]STRETCH_*[/code] constants. See the constants to learn more.
  31. - :ref:`Texture<class_texture>` **texture** - The node's [Texture] resource.
  32. Numeric Constants
  33. -----------------
  34. - **STRETCH_SCALE_ON_EXPAND** = **0** --- Scale to fit the node's bounding rectangle, only if ``expand`` is ``true``. Default ``stretch_mode``, for backwards compatibility. Until you set ``expand`` to ``true``, the texture will behave like ``STRETCH_KEEP``.
  35. - **STRETCH_SCALE** = **1** --- Scale to fit the node's bounding rectangle.
  36. - **STRETCH_TILE** = **2** --- Tile inside the node's bounding rectangle.
  37. - **STRETCH_KEEP** = **3** --- The texture keeps its original size and stays in the bounding rectangle's top-left corner.
  38. - **STRETCH_KEEP_CENTERED** = **4** --- The texture keeps its original size and stays centered in the node's bounding rectangle.
  39. - **STRETCH_KEEP_ASPECT** = **5** --- Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.
  40. - **STRETCH_KEEP_ASPECT_CENTERED** = **6** --- Scale the texture to fit the node's bounding rectangle, center it and maintain its aspect ratio.
  41. - **STRETCH_KEEP_ASPECT_COVERED** = **7** --- Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits.
  42. Description
  43. -----------
  44. Use TextureRect to draw icons and sprites in your User Interfaces. To create panels and menu boxes, take a look at NinePatchFrame. Its Stretch Mode property controls the texture's scale and placement. It can scale, tile and stay centered inside its bounding rectangle. TextureRect is one of the 5 most common nodes to create game UI.
  45. Member Function Description
  46. ---------------------------
  47. .. _class_TextureRect_get_stretch_mode:
  48. - :ref:`int<class_int>` **get_stretch_mode** **(** **)** const
  49. .. _class_TextureRect_get_texture:
  50. - :ref:`Texture<class_texture>` **get_texture** **(** **)** const
  51. .. _class_TextureRect_has_expand:
  52. - :ref:`bool<class_bool>` **has_expand** **(** **)** const
  53. .. _class_TextureRect_set_expand:
  54. - void **set_expand** **(** :ref:`bool<class_bool>` enable **)**
  55. .. _class_TextureRect_set_stretch_mode:
  56. - void **set_stretch_mode** **(** :ref:`int<class_int>` stretch_mode **)**
  57. .. _class_TextureRect_set_texture:
  58. - void **set_texture** **(** :ref:`Texture<class_texture>` texture **)**