class_texturerect.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/TextureRect.xml.
  6. .. _class_TextureRect:
  7. TextureRect
  8. ===========
  9. **Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. A control that displays a texture.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A control that displays a texture, for example an icon inside a GUI. The texture's placement can be controlled with the :ref:`stretch_mode<class_TextureRect_property_stretch_mode>` property. It can scale, tile, or stay centered inside its bounding rectangle.
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - `3D Voxel Demo <https://godotengine.org/asset-library/asset/2755>`__
  19. .. rst-class:: classref-reftable-group
  20. Properties
  21. ----------
  22. .. table::
  23. :widths: auto
  24. +--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
  25. | :ref:`ExpandMode<enum_TextureRect_ExpandMode>` | :ref:`expand_mode<class_TextureRect_property_expand_mode>` | ``0`` |
  26. +--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`flip_h<class_TextureRect_property_flip_h>` | ``false`` |
  28. +--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`flip_v<class_TextureRect_property_flip_v>` | ``false`` |
  30. +--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
  31. | :ref:`MouseFilter<enum_Control_MouseFilter>` | mouse_filter | ``1`` (overrides :ref:`Control<class_Control_property_mouse_filter>`) |
  32. +--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
  33. | :ref:`StretchMode<enum_TextureRect_StretchMode>` | :ref:`stretch_mode<class_TextureRect_property_stretch_mode>` | ``0`` |
  34. +--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
  35. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture<class_TextureRect_property_texture>` | |
  36. +--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
  37. .. rst-class:: classref-section-separator
  38. ----
  39. .. rst-class:: classref-descriptions-group
  40. Enumerations
  41. ------------
  42. .. _enum_TextureRect_ExpandMode:
  43. .. rst-class:: classref-enumeration
  44. enum **ExpandMode**: :ref:`🔗<enum_TextureRect_ExpandMode>`
  45. .. _class_TextureRect_constant_EXPAND_KEEP_SIZE:
  46. .. rst-class:: classref-enumeration-constant
  47. :ref:`ExpandMode<enum_TextureRect_ExpandMode>` **EXPAND_KEEP_SIZE** = ``0``
  48. The minimum size will be equal to texture size, i.e. **TextureRect** can't be smaller than the texture.
  49. .. _class_TextureRect_constant_EXPAND_IGNORE_SIZE:
  50. .. rst-class:: classref-enumeration-constant
  51. :ref:`ExpandMode<enum_TextureRect_ExpandMode>` **EXPAND_IGNORE_SIZE** = ``1``
  52. The size of the texture won't be considered for minimum size calculation, so the **TextureRect** can be shrunk down past the texture size.
  53. .. _class_TextureRect_constant_EXPAND_FIT_WIDTH:
  54. .. rst-class:: classref-enumeration-constant
  55. :ref:`ExpandMode<enum_TextureRect_ExpandMode>` **EXPAND_FIT_WIDTH** = ``2``
  56. The height of the texture will be ignored. Minimum width will be equal to the current height. Useful for horizontal layouts, e.g. inside :ref:`HBoxContainer<class_HBoxContainer>`.
  57. .. _class_TextureRect_constant_EXPAND_FIT_WIDTH_PROPORTIONAL:
  58. .. rst-class:: classref-enumeration-constant
  59. :ref:`ExpandMode<enum_TextureRect_ExpandMode>` **EXPAND_FIT_WIDTH_PROPORTIONAL** = ``3``
  60. Same as :ref:`EXPAND_FIT_WIDTH<class_TextureRect_constant_EXPAND_FIT_WIDTH>`, but keeps texture's aspect ratio.
  61. .. _class_TextureRect_constant_EXPAND_FIT_HEIGHT:
  62. .. rst-class:: classref-enumeration-constant
  63. :ref:`ExpandMode<enum_TextureRect_ExpandMode>` **EXPAND_FIT_HEIGHT** = ``4``
  64. The width of the texture will be ignored. Minimum height will be equal to the current width. Useful for vertical layouts, e.g. inside :ref:`VBoxContainer<class_VBoxContainer>`.
  65. .. _class_TextureRect_constant_EXPAND_FIT_HEIGHT_PROPORTIONAL:
  66. .. rst-class:: classref-enumeration-constant
  67. :ref:`ExpandMode<enum_TextureRect_ExpandMode>` **EXPAND_FIT_HEIGHT_PROPORTIONAL** = ``5``
  68. Same as :ref:`EXPAND_FIT_HEIGHT<class_TextureRect_constant_EXPAND_FIT_HEIGHT>`, but keeps texture's aspect ratio.
  69. .. rst-class:: classref-item-separator
  70. ----
  71. .. _enum_TextureRect_StretchMode:
  72. .. rst-class:: classref-enumeration
  73. enum **StretchMode**: :ref:`🔗<enum_TextureRect_StretchMode>`
  74. .. _class_TextureRect_constant_STRETCH_SCALE:
  75. .. rst-class:: classref-enumeration-constant
  76. :ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_SCALE** = ``0``
  77. Scale to fit the node's bounding rectangle.
  78. .. _class_TextureRect_constant_STRETCH_TILE:
  79. .. rst-class:: classref-enumeration-constant
  80. :ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_TILE** = ``1``
  81. Tile inside the node's bounding rectangle.
  82. .. _class_TextureRect_constant_STRETCH_KEEP:
  83. .. rst-class:: classref-enumeration-constant
  84. :ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_KEEP** = ``2``
  85. The texture keeps its original size and stays in the bounding rectangle's top-left corner.
  86. .. _class_TextureRect_constant_STRETCH_KEEP_CENTERED:
  87. .. rst-class:: classref-enumeration-constant
  88. :ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_KEEP_CENTERED** = ``3``
  89. The texture keeps its original size and stays centered in the node's bounding rectangle.
  90. .. _class_TextureRect_constant_STRETCH_KEEP_ASPECT:
  91. .. rst-class:: classref-enumeration-constant
  92. :ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_KEEP_ASPECT** = ``4``
  93. Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.
  94. .. _class_TextureRect_constant_STRETCH_KEEP_ASPECT_CENTERED:
  95. .. rst-class:: classref-enumeration-constant
  96. :ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_KEEP_ASPECT_CENTERED** = ``5``
  97. Scale the texture to fit the node's bounding rectangle, center it and maintain its aspect ratio.
  98. .. _class_TextureRect_constant_STRETCH_KEEP_ASPECT_COVERED:
  99. .. rst-class:: classref-enumeration-constant
  100. :ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_KEEP_ASPECT_COVERED** = ``6``
  101. Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits.
  102. .. rst-class:: classref-section-separator
  103. ----
  104. .. rst-class:: classref-descriptions-group
  105. Property Descriptions
  106. ---------------------
  107. .. _class_TextureRect_property_expand_mode:
  108. .. rst-class:: classref-property
  109. :ref:`ExpandMode<enum_TextureRect_ExpandMode>` **expand_mode** = ``0`` :ref:`🔗<class_TextureRect_property_expand_mode>`
  110. .. rst-class:: classref-property-setget
  111. - |void| **set_expand_mode**\ (\ value\: :ref:`ExpandMode<enum_TextureRect_ExpandMode>`\ )
  112. - :ref:`ExpandMode<enum_TextureRect_ExpandMode>` **get_expand_mode**\ (\ )
  113. **Experimental:** Using :ref:`EXPAND_FIT_WIDTH<class_TextureRect_constant_EXPAND_FIT_WIDTH>`, :ref:`EXPAND_FIT_WIDTH_PROPORTIONAL<class_TextureRect_constant_EXPAND_FIT_WIDTH_PROPORTIONAL>`, :ref:`EXPAND_FIT_HEIGHT<class_TextureRect_constant_EXPAND_FIT_HEIGHT>`, or :ref:`EXPAND_FIT_HEIGHT_PROPORTIONAL<class_TextureRect_constant_EXPAND_FIT_HEIGHT_PROPORTIONAL>` may result in unstable behavior in some :ref:`Container<class_Container>` controls. This behavior may be re-evaluated and changed in the future.
  114. Defines how minimum size is determined based on the texture's size. See :ref:`ExpandMode<enum_TextureRect_ExpandMode>` for options.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_TextureRect_property_flip_h:
  118. .. rst-class:: classref-property
  119. :ref:`bool<class_bool>` **flip_h** = ``false`` :ref:`🔗<class_TextureRect_property_flip_h>`
  120. .. rst-class:: classref-property-setget
  121. - |void| **set_flip_h**\ (\ value\: :ref:`bool<class_bool>`\ )
  122. - :ref:`bool<class_bool>` **is_flipped_h**\ (\ )
  123. If ``true``, texture is flipped horizontally.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_TextureRect_property_flip_v:
  127. .. rst-class:: classref-property
  128. :ref:`bool<class_bool>` **flip_v** = ``false`` :ref:`🔗<class_TextureRect_property_flip_v>`
  129. .. rst-class:: classref-property-setget
  130. - |void| **set_flip_v**\ (\ value\: :ref:`bool<class_bool>`\ )
  131. - :ref:`bool<class_bool>` **is_flipped_v**\ (\ )
  132. If ``true``, texture is flipped vertically.
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_TextureRect_property_stretch_mode:
  136. .. rst-class:: classref-property
  137. :ref:`StretchMode<enum_TextureRect_StretchMode>` **stretch_mode** = ``0`` :ref:`🔗<class_TextureRect_property_stretch_mode>`
  138. .. rst-class:: classref-property-setget
  139. - |void| **set_stretch_mode**\ (\ value\: :ref:`StretchMode<enum_TextureRect_StretchMode>`\ )
  140. - :ref:`StretchMode<enum_TextureRect_StretchMode>` **get_stretch_mode**\ (\ )
  141. Controls the texture's behavior when resizing the node's bounding rectangle. See :ref:`StretchMode<enum_TextureRect_StretchMode>`.
  142. .. rst-class:: classref-item-separator
  143. ----
  144. .. _class_TextureRect_property_texture:
  145. .. rst-class:: classref-property
  146. :ref:`Texture2D<class_Texture2D>` **texture** :ref:`🔗<class_TextureRect_property_texture>`
  147. .. rst-class:: classref-property-setget
  148. - |void| **set_texture**\ (\ value\: :ref:`Texture2D<class_Texture2D>`\ )
  149. - :ref:`Texture2D<class_Texture2D>` **get_texture**\ (\ )
  150. The node's :ref:`Texture2D<class_Texture2D>` resource.
  151. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  152. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  153. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  154. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  155. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  156. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  157. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  158. .. |void| replace:: :abbr:`void (No return value.)`