class_ninepatchrect.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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/NinePatchRect.xml.
  6. .. _class_NinePatchRect:
  7. NinePatchRect
  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 by keeping its corners intact, but tiling its edges and center.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Also known as 9-slice panels, **NinePatchRect** produces clean panels of any size based on a small texture. To do so, it splits the texture in a 3×3 grid. When you scale the node, it tiles the texture's edges horizontally or vertically, tiles the center on both axes, and leaves the corners unchanged.
  15. .. rst-class:: classref-reftable-group
  16. Properties
  17. ----------
  18. .. table::
  19. :widths: auto
  20. +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
  21. | :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` | :ref:`axis_stretch_horizontal<class_NinePatchRect_property_axis_stretch_horizontal>` | ``0`` |
  22. +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
  23. | :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` | :ref:`axis_stretch_vertical<class_NinePatchRect_property_axis_stretch_vertical>` | ``0`` |
  24. +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
  25. | :ref:`bool<class_bool>` | :ref:`draw_center<class_NinePatchRect_property_draw_center>` | ``true`` |
  26. +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
  27. | :ref:`MouseFilter<enum_Control_MouseFilter>` | mouse_filter | ``2`` (overrides :ref:`Control<class_Control_property_mouse_filter>`) |
  28. +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
  29. | :ref:`int<class_int>` | :ref:`patch_margin_bottom<class_NinePatchRect_property_patch_margin_bottom>` | ``0`` |
  30. +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
  31. | :ref:`int<class_int>` | :ref:`patch_margin_left<class_NinePatchRect_property_patch_margin_left>` | ``0`` |
  32. +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
  33. | :ref:`int<class_int>` | :ref:`patch_margin_right<class_NinePatchRect_property_patch_margin_right>` | ``0`` |
  34. +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
  35. | :ref:`int<class_int>` | :ref:`patch_margin_top<class_NinePatchRect_property_patch_margin_top>` | ``0`` |
  36. +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
  37. | :ref:`Rect2<class_Rect2>` | :ref:`region_rect<class_NinePatchRect_property_region_rect>` | ``Rect2(0, 0, 0, 0)`` |
  38. +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
  39. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture<class_NinePatchRect_property_texture>` | |
  40. +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
  41. .. rst-class:: classref-reftable-group
  42. Methods
  43. -------
  44. .. table::
  45. :widths: auto
  46. +-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`get_patch_margin<class_NinePatchRect_method_get_patch_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
  48. +-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | |void| | :ref:`set_patch_margin<class_NinePatchRect_method_set_patch_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, value\: :ref:`int<class_int>`\ ) |
  50. +-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. .. rst-class:: classref-section-separator
  52. ----
  53. .. rst-class:: classref-descriptions-group
  54. Signals
  55. -------
  56. .. _class_NinePatchRect_signal_texture_changed:
  57. .. rst-class:: classref-signal
  58. **texture_changed**\ (\ ) :ref:`🔗<class_NinePatchRect_signal_texture_changed>`
  59. Emitted when the node's texture changes.
  60. .. rst-class:: classref-section-separator
  61. ----
  62. .. rst-class:: classref-descriptions-group
  63. Enumerations
  64. ------------
  65. .. _enum_NinePatchRect_AxisStretchMode:
  66. .. rst-class:: classref-enumeration
  67. enum **AxisStretchMode**: :ref:`🔗<enum_NinePatchRect_AxisStretchMode>`
  68. .. _class_NinePatchRect_constant_AXIS_STRETCH_MODE_STRETCH:
  69. .. rst-class:: classref-enumeration-constant
  70. :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **AXIS_STRETCH_MODE_STRETCH** = ``0``
  71. Stretches the center texture across the NinePatchRect. This may cause the texture to be distorted.
  72. .. _class_NinePatchRect_constant_AXIS_STRETCH_MODE_TILE:
  73. .. rst-class:: classref-enumeration-constant
  74. :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **AXIS_STRETCH_MODE_TILE** = ``1``
  75. Repeats the center texture across the NinePatchRect. This won't cause any visible distortion. The texture must be seamless for this to work without displaying artifacts between edges.
  76. .. _class_NinePatchRect_constant_AXIS_STRETCH_MODE_TILE_FIT:
  77. .. rst-class:: classref-enumeration-constant
  78. :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **AXIS_STRETCH_MODE_TILE_FIT** = ``2``
  79. Repeats the center texture across the NinePatchRect, but will also stretch the texture to make sure each tile is visible in full. This may cause the texture to be distorted, but less than :ref:`AXIS_STRETCH_MODE_STRETCH<class_NinePatchRect_constant_AXIS_STRETCH_MODE_STRETCH>`. The texture must be seamless for this to work without displaying artifacts between edges.
  80. .. rst-class:: classref-section-separator
  81. ----
  82. .. rst-class:: classref-descriptions-group
  83. Property Descriptions
  84. ---------------------
  85. .. _class_NinePatchRect_property_axis_stretch_horizontal:
  86. .. rst-class:: classref-property
  87. :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **axis_stretch_horizontal** = ``0`` :ref:`🔗<class_NinePatchRect_property_axis_stretch_horizontal>`
  88. .. rst-class:: classref-property-setget
  89. - |void| **set_h_axis_stretch_mode**\ (\ value\: :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>`\ )
  90. - :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **get_h_axis_stretch_mode**\ (\ )
  91. The stretch mode to use for horizontal stretching/tiling. See :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` for possible values.
  92. .. rst-class:: classref-item-separator
  93. ----
  94. .. _class_NinePatchRect_property_axis_stretch_vertical:
  95. .. rst-class:: classref-property
  96. :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **axis_stretch_vertical** = ``0`` :ref:`🔗<class_NinePatchRect_property_axis_stretch_vertical>`
  97. .. rst-class:: classref-property-setget
  98. - |void| **set_v_axis_stretch_mode**\ (\ value\: :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>`\ )
  99. - :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **get_v_axis_stretch_mode**\ (\ )
  100. The stretch mode to use for vertical stretching/tiling. See :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` for possible values.
  101. .. rst-class:: classref-item-separator
  102. ----
  103. .. _class_NinePatchRect_property_draw_center:
  104. .. rst-class:: classref-property
  105. :ref:`bool<class_bool>` **draw_center** = ``true`` :ref:`🔗<class_NinePatchRect_property_draw_center>`
  106. .. rst-class:: classref-property-setget
  107. - |void| **set_draw_center**\ (\ value\: :ref:`bool<class_bool>`\ )
  108. - :ref:`bool<class_bool>` **is_draw_center_enabled**\ (\ )
  109. If ``true``, draw the panel's center. Else, only draw the 9-slice's borders.
  110. .. rst-class:: classref-item-separator
  111. ----
  112. .. _class_NinePatchRect_property_patch_margin_bottom:
  113. .. rst-class:: classref-property
  114. :ref:`int<class_int>` **patch_margin_bottom** = ``0`` :ref:`🔗<class_NinePatchRect_property_patch_margin_bottom>`
  115. .. rst-class:: classref-property-setget
  116. - |void| **set_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, value\: :ref:`int<class_int>`\ )
  117. - :ref:`int<class_int>` **get_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
  118. The height of the 9-slice's bottom row. A margin of 16 means the 9-slice's bottom corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_NinePatchRect_property_patch_margin_left:
  122. .. rst-class:: classref-property
  123. :ref:`int<class_int>` **patch_margin_left** = ``0`` :ref:`🔗<class_NinePatchRect_property_patch_margin_left>`
  124. .. rst-class:: classref-property-setget
  125. - |void| **set_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, value\: :ref:`int<class_int>`\ )
  126. - :ref:`int<class_int>` **get_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
  127. The width of the 9-slice's left column. A margin of 16 means the 9-slice's left corners and side will have a width of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.
  128. .. rst-class:: classref-item-separator
  129. ----
  130. .. _class_NinePatchRect_property_patch_margin_right:
  131. .. rst-class:: classref-property
  132. :ref:`int<class_int>` **patch_margin_right** = ``0`` :ref:`🔗<class_NinePatchRect_property_patch_margin_right>`
  133. .. rst-class:: classref-property-setget
  134. - |void| **set_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, value\: :ref:`int<class_int>`\ )
  135. - :ref:`int<class_int>` **get_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
  136. The width of the 9-slice's right column. A margin of 16 means the 9-slice's right corners and side will have a width of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.
  137. .. rst-class:: classref-item-separator
  138. ----
  139. .. _class_NinePatchRect_property_patch_margin_top:
  140. .. rst-class:: classref-property
  141. :ref:`int<class_int>` **patch_margin_top** = ``0`` :ref:`🔗<class_NinePatchRect_property_patch_margin_top>`
  142. .. rst-class:: classref-property-setget
  143. - |void| **set_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, value\: :ref:`int<class_int>`\ )
  144. - :ref:`int<class_int>` **get_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
  145. The height of the 9-slice's top row. A margin of 16 means the 9-slice's top corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.
  146. .. rst-class:: classref-item-separator
  147. ----
  148. .. _class_NinePatchRect_property_region_rect:
  149. .. rst-class:: classref-property
  150. :ref:`Rect2<class_Rect2>` **region_rect** = ``Rect2(0, 0, 0, 0)`` :ref:`🔗<class_NinePatchRect_property_region_rect>`
  151. .. rst-class:: classref-property-setget
  152. - |void| **set_region_rect**\ (\ value\: :ref:`Rect2<class_Rect2>`\ )
  153. - :ref:`Rect2<class_Rect2>` **get_region_rect**\ (\ )
  154. Rectangular region of the texture to sample from. If you're working with an atlas, use this property to define the area the 9-slice should use. All other properties are relative to this one. If the rect is empty, NinePatchRect will use the whole texture.
  155. .. rst-class:: classref-item-separator
  156. ----
  157. .. _class_NinePatchRect_property_texture:
  158. .. rst-class:: classref-property
  159. :ref:`Texture2D<class_Texture2D>` **texture** :ref:`🔗<class_NinePatchRect_property_texture>`
  160. .. rst-class:: classref-property-setget
  161. - |void| **set_texture**\ (\ value\: :ref:`Texture2D<class_Texture2D>`\ )
  162. - :ref:`Texture2D<class_Texture2D>` **get_texture**\ (\ )
  163. The node's texture resource.
  164. .. rst-class:: classref-section-separator
  165. ----
  166. .. rst-class:: classref-descriptions-group
  167. Method Descriptions
  168. -------------------
  169. .. _class_NinePatchRect_method_get_patch_margin:
  170. .. rst-class:: classref-method
  171. :ref:`int<class_int>` **get_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_NinePatchRect_method_get_patch_margin>`
  172. Returns the size of the margin on the specified :ref:`Side<enum_@GlobalScope_Side>`.
  173. .. rst-class:: classref-item-separator
  174. ----
  175. .. _class_NinePatchRect_method_set_patch_margin:
  176. .. rst-class:: classref-method
  177. |void| **set_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_NinePatchRect_method_set_patch_margin>`
  178. Sets the size of the margin on the specified :ref:`Side<enum_@GlobalScope_Side>` to ``value`` pixels.
  179. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  180. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  181. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  182. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  183. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  184. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  185. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  186. .. |void| replace:: :abbr:`void (No return value.)`