123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- :github_url: hide
- .. DO NOT EDIT THIS FILE!!!
- .. Generated automatically from Godot engine sources.
- .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
- .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/NinePatchRect.xml.
- .. _class_NinePatchRect:
- NinePatchRect
- =============
- **Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
- A control that displays a texture by keeping its corners intact, but tiling its edges and center.
- .. rst-class:: classref-introduction-group
- Description
- -----------
- 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.
- .. rst-class:: classref-reftable-group
- Properties
- ----------
- .. table::
- :widths: auto
- +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
- | :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` | :ref:`axis_stretch_horizontal<class_NinePatchRect_property_axis_stretch_horizontal>` | ``0`` |
- +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
- | :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` | :ref:`axis_stretch_vertical<class_NinePatchRect_property_axis_stretch_vertical>` | ``0`` |
- +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`draw_center<class_NinePatchRect_property_draw_center>` | ``true`` |
- +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
- | :ref:`MouseFilter<enum_Control_MouseFilter>` | mouse_filter | ``2`` (overrides :ref:`Control<class_Control_property_mouse_filter>`) |
- +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`patch_margin_bottom<class_NinePatchRect_property_patch_margin_bottom>` | ``0`` |
- +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`patch_margin_left<class_NinePatchRect_property_patch_margin_left>` | ``0`` |
- +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`patch_margin_right<class_NinePatchRect_property_patch_margin_right>` | ``0`` |
- +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`patch_margin_top<class_NinePatchRect_property_patch_margin_top>` | ``0`` |
- +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
- | :ref:`Rect2<class_Rect2>` | :ref:`region_rect<class_NinePatchRect_property_region_rect>` | ``Rect2(0, 0, 0, 0)`` |
- +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
- | :ref:`Texture2D<class_Texture2D>` | :ref:`texture<class_NinePatchRect_property_texture>` | |
- +------------------------------------------------------------+--------------------------------------------------------------------------------------+-----------------------------------------------------------------------+
- .. rst-class:: classref-reftable-group
- Methods
- -------
- .. table::
- :widths: auto
- +-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_patch_margin<class_NinePatchRect_method_get_patch_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
- +-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`set_patch_margin<class_NinePatchRect_method_set_patch_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, value\: :ref:`int<class_int>`\ ) |
- +-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Signals
- -------
- .. _class_NinePatchRect_signal_texture_changed:
- .. rst-class:: classref-signal
- **texture_changed**\ (\ ) :ref:`🔗<class_NinePatchRect_signal_texture_changed>`
- Emitted when the node's texture changes.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Enumerations
- ------------
- .. _enum_NinePatchRect_AxisStretchMode:
- .. rst-class:: classref-enumeration
- enum **AxisStretchMode**: :ref:`🔗<enum_NinePatchRect_AxisStretchMode>`
- .. _class_NinePatchRect_constant_AXIS_STRETCH_MODE_STRETCH:
- .. rst-class:: classref-enumeration-constant
- :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **AXIS_STRETCH_MODE_STRETCH** = ``0``
- Stretches the center texture across the NinePatchRect. This may cause the texture to be distorted.
- .. _class_NinePatchRect_constant_AXIS_STRETCH_MODE_TILE:
- .. rst-class:: classref-enumeration-constant
- :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **AXIS_STRETCH_MODE_TILE** = ``1``
- 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.
- .. _class_NinePatchRect_constant_AXIS_STRETCH_MODE_TILE_FIT:
- .. rst-class:: classref-enumeration-constant
- :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **AXIS_STRETCH_MODE_TILE_FIT** = ``2``
- 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.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Property Descriptions
- ---------------------
- .. _class_NinePatchRect_property_axis_stretch_horizontal:
- .. rst-class:: classref-property
- :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **axis_stretch_horizontal** = ``0`` :ref:`🔗<class_NinePatchRect_property_axis_stretch_horizontal>`
- .. rst-class:: classref-property-setget
- - |void| **set_h_axis_stretch_mode**\ (\ value\: :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>`\ )
- - :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **get_h_axis_stretch_mode**\ (\ )
- The stretch mode to use for horizontal stretching/tiling. See :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` for possible values.
- .. rst-class:: classref-item-separator
- ----
- .. _class_NinePatchRect_property_axis_stretch_vertical:
- .. rst-class:: classref-property
- :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **axis_stretch_vertical** = ``0`` :ref:`🔗<class_NinePatchRect_property_axis_stretch_vertical>`
- .. rst-class:: classref-property-setget
- - |void| **set_v_axis_stretch_mode**\ (\ value\: :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>`\ )
- - :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` **get_v_axis_stretch_mode**\ (\ )
- The stretch mode to use for vertical stretching/tiling. See :ref:`AxisStretchMode<enum_NinePatchRect_AxisStretchMode>` for possible values.
- .. rst-class:: classref-item-separator
- ----
- .. _class_NinePatchRect_property_draw_center:
- .. rst-class:: classref-property
- :ref:`bool<class_bool>` **draw_center** = ``true`` :ref:`🔗<class_NinePatchRect_property_draw_center>`
- .. rst-class:: classref-property-setget
- - |void| **set_draw_center**\ (\ value\: :ref:`bool<class_bool>`\ )
- - :ref:`bool<class_bool>` **is_draw_center_enabled**\ (\ )
- If ``true``, draw the panel's center. Else, only draw the 9-slice's borders.
- .. rst-class:: classref-item-separator
- ----
- .. _class_NinePatchRect_property_patch_margin_bottom:
- .. rst-class:: classref-property
- :ref:`int<class_int>` **patch_margin_bottom** = ``0`` :ref:`🔗<class_NinePatchRect_property_patch_margin_bottom>`
- .. rst-class:: classref-property-setget
- - |void| **set_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, value\: :ref:`int<class_int>`\ )
- - :ref:`int<class_int>` **get_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_NinePatchRect_property_patch_margin_left:
- .. rst-class:: classref-property
- :ref:`int<class_int>` **patch_margin_left** = ``0`` :ref:`🔗<class_NinePatchRect_property_patch_margin_left>`
- .. rst-class:: classref-property-setget
- - |void| **set_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, value\: :ref:`int<class_int>`\ )
- - :ref:`int<class_int>` **get_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_NinePatchRect_property_patch_margin_right:
- .. rst-class:: classref-property
- :ref:`int<class_int>` **patch_margin_right** = ``0`` :ref:`🔗<class_NinePatchRect_property_patch_margin_right>`
- .. rst-class:: classref-property-setget
- - |void| **set_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, value\: :ref:`int<class_int>`\ )
- - :ref:`int<class_int>` **get_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_NinePatchRect_property_patch_margin_top:
- .. rst-class:: classref-property
- :ref:`int<class_int>` **patch_margin_top** = ``0`` :ref:`🔗<class_NinePatchRect_property_patch_margin_top>`
- .. rst-class:: classref-property-setget
- - |void| **set_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, value\: :ref:`int<class_int>`\ )
- - :ref:`int<class_int>` **get_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_NinePatchRect_property_region_rect:
- .. rst-class:: classref-property
- :ref:`Rect2<class_Rect2>` **region_rect** = ``Rect2(0, 0, 0, 0)`` :ref:`🔗<class_NinePatchRect_property_region_rect>`
- .. rst-class:: classref-property-setget
- - |void| **set_region_rect**\ (\ value\: :ref:`Rect2<class_Rect2>`\ )
- - :ref:`Rect2<class_Rect2>` **get_region_rect**\ (\ )
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_NinePatchRect_property_texture:
- .. rst-class:: classref-property
- :ref:`Texture2D<class_Texture2D>` **texture** :ref:`🔗<class_NinePatchRect_property_texture>`
- .. rst-class:: classref-property-setget
- - |void| **set_texture**\ (\ value\: :ref:`Texture2D<class_Texture2D>`\ )
- - :ref:`Texture2D<class_Texture2D>` **get_texture**\ (\ )
- The node's texture resource.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Method Descriptions
- -------------------
- .. _class_NinePatchRect_method_get_patch_margin:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_NinePatchRect_method_get_patch_margin>`
- Returns the size of the margin on the specified :ref:`Side<enum_@GlobalScope_Side>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_NinePatchRect_method_set_patch_margin:
- .. rst-class:: classref-method
- |void| **set_patch_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_NinePatchRect_method_set_patch_margin>`
- Sets the size of the margin on the specified :ref:`Side<enum_@GlobalScope_Side>` to ``value`` pixels.
- .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
- .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
- .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
- .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
- .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
- .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
- .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
- .. |void| replace:: :abbr:`void (No return value.)`
|