class_ninepatchrect.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/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. Scalable texture-based frame that tiles the texture's centers and sides, but keeps the corners' original size. Perfect for panels and dialog boxes.
  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 sides horizontally or vertically, the center on both axes but it doesn't scale or tile the corners.
  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:`Texture<class_Texture>` | :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>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const| |
  48. +-----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_patch_margin<class_NinePatchRect_method_set_patch_margin>` **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`int<class_int>` value **)** |
  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** **(** **)**
  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**:
  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. \ **Note:** Only supported when using the GLES3 renderer. When using the GLES2 renderer, this will behave like :ref:`AXIS_STRETCH_MODE_STRETCH<class_NinePatchRect_constant_AXIS_STRETCH_MODE_STRETCH>`.
  77. .. _class_NinePatchRect_constant_AXIS_STRETCH_MODE_TILE_FIT:
  78. .. rst-class:: classref-enumeration-constant
  79. :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **AXIS_STRETCH_MODE_TILE_FIT** = ``2``
  80. 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.
  81. \ **Note:** Only supported when using the GLES3 renderer. When using the GLES2 renderer, this will behave like :ref:`AXIS_STRETCH_MODE_STRETCH<class_NinePatchRect_constant_AXIS_STRETCH_MODE_STRETCH>`.
  82. .. rst-class:: classref-section-separator
  83. ----
  84. .. rst-class:: classref-descriptions-group
  85. Property Descriptions
  86. ---------------------
  87. .. _class_NinePatchRect_property_axis_stretch_horizontal:
  88. .. rst-class:: classref-property
  89. :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **axis_stretch_horizontal** = ``0``
  90. .. rst-class:: classref-property-setget
  91. - void **set_h_axis_stretch_mode** **(** :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` value **)**
  92. - :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **get_h_axis_stretch_mode** **(** **)**
  93. The stretch mode to use for horizontal stretching/tiling. See :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` for possible values.
  94. .. rst-class:: classref-item-separator
  95. ----
  96. .. _class_NinePatchRect_property_axis_stretch_vertical:
  97. .. rst-class:: classref-property
  98. :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **axis_stretch_vertical** = ``0``
  99. .. rst-class:: classref-property-setget
  100. - void **set_v_axis_stretch_mode** **(** :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` value **)**
  101. - :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **get_v_axis_stretch_mode** **(** **)**
  102. The stretch mode to use for vertical stretching/tiling. See :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` for possible values.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_NinePatchRect_property_draw_center:
  106. .. rst-class:: classref-property
  107. :ref:`bool<class_bool>` **draw_center** = ``true``
  108. .. rst-class:: classref-property-setget
  109. - void **set_draw_center** **(** :ref:`bool<class_bool>` value **)**
  110. - :ref:`bool<class_bool>` **is_draw_center_enabled** **(** **)**
  111. If ``true``, draw the panel's center. Else, only draw the 9-slice's borders.
  112. .. rst-class:: classref-item-separator
  113. ----
  114. .. _class_NinePatchRect_property_patch_margin_bottom:
  115. .. rst-class:: classref-property
  116. :ref:`int<class_int>` **patch_margin_bottom** = ``0``
  117. .. rst-class:: classref-property-setget
  118. - void **set_patch_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`int<class_int>` value **)**
  119. - :ref:`int<class_int>` **get_patch_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  120. 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.
  121. .. rst-class:: classref-item-separator
  122. ----
  123. .. _class_NinePatchRect_property_patch_margin_left:
  124. .. rst-class:: classref-property
  125. :ref:`int<class_int>` **patch_margin_left** = ``0``
  126. .. rst-class:: classref-property-setget
  127. - void **set_patch_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`int<class_int>` value **)**
  128. - :ref:`int<class_int>` **get_patch_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  129. 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.
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _class_NinePatchRect_property_patch_margin_right:
  133. .. rst-class:: classref-property
  134. :ref:`int<class_int>` **patch_margin_right** = ``0``
  135. .. rst-class:: classref-property-setget
  136. - void **set_patch_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`int<class_int>` value **)**
  137. - :ref:`int<class_int>` **get_patch_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  138. 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.
  139. .. rst-class:: classref-item-separator
  140. ----
  141. .. _class_NinePatchRect_property_patch_margin_top:
  142. .. rst-class:: classref-property
  143. :ref:`int<class_int>` **patch_margin_top** = ``0``
  144. .. rst-class:: classref-property-setget
  145. - void **set_patch_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`int<class_int>` value **)**
  146. - :ref:`int<class_int>` **get_patch_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  147. 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.
  148. .. rst-class:: classref-item-separator
  149. ----
  150. .. _class_NinePatchRect_property_region_rect:
  151. .. rst-class:: classref-property
  152. :ref:`Rect2<class_Rect2>` **region_rect** = ``Rect2( 0, 0, 0, 0 )``
  153. .. rst-class:: classref-property-setget
  154. - void **set_region_rect** **(** :ref:`Rect2<class_Rect2>` value **)**
  155. - :ref:`Rect2<class_Rect2>` **get_region_rect** **(** **)**
  156. 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.
  157. .. rst-class:: classref-item-separator
  158. ----
  159. .. _class_NinePatchRect_property_texture:
  160. .. rst-class:: classref-property
  161. :ref:`Texture<class_Texture>` **texture**
  162. .. rst-class:: classref-property-setget
  163. - void **set_texture** **(** :ref:`Texture<class_Texture>` value **)**
  164. - :ref:`Texture<class_Texture>` **get_texture** **(** **)**
  165. The node's texture resource.
  166. .. rst-class:: classref-section-separator
  167. ----
  168. .. rst-class:: classref-descriptions-group
  169. Method Descriptions
  170. -------------------
  171. .. _class_NinePatchRect_method_get_patch_margin:
  172. .. rst-class:: classref-method
  173. :ref:`int<class_int>` **get_patch_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin **)** |const|
  174. Returns the size of the margin identified by the given :ref:`Margin<enum_@GlobalScope_Margin>` constant.
  175. .. rst-class:: classref-item-separator
  176. ----
  177. .. _class_NinePatchRect_method_set_patch_margin:
  178. .. rst-class:: classref-method
  179. void **set_patch_margin** **(** :ref:`Margin<enum_@GlobalScope_Margin>` margin, :ref:`int<class_int>` value **)**
  180. Sets the size of the margin identified by the given :ref:`Margin<enum_@GlobalScope_Margin>` constant to ``value`` in pixels.
  181. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  182. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  183. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  184. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`