Files
godot-docs-l10n/classes/zh_Hant/class_styleboxtexture.rst

467 lines
22 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

:github_url: hide
.. _class_StyleBoxTexture:
StyleBoxTexture
===============
**繼承:** :ref:`StyleBox<class_StyleBox>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
基於紋理的九宮格 :ref:`StyleBox<class_StyleBox>`\ 。
.. rst-class:: classref-introduction-group
說明
----
基於紋理的九宮格 :ref:`StyleBox<class_StyleBox>`\ ,類似於 :ref:`NinePatchRect<class_NinePatchRect>`\ 。這種樣式盒對紋理執行 3×3 縮放,只有中心儲存格會被完全拉伸。這樣就能夠為不同大小的樣式盒設計帶邊框的樣式。
.. rst-class:: classref-reftable-group
屬性
----
.. table::
:widths: auto
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` | :ref:`axis_stretch_horizontal<class_StyleBoxTexture_property_axis_stretch_horizontal>` | ``0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` | :ref:`axis_stretch_vertical<class_StyleBoxTexture_property_axis_stretch_vertical>` | ``0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`bool<class_bool>` | :ref:`draw_center<class_StyleBoxTexture_property_draw_center>` | ``true`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`expand_margin_bottom<class_StyleBoxTexture_property_expand_margin_bottom>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`expand_margin_left<class_StyleBoxTexture_property_expand_margin_left>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`expand_margin_right<class_StyleBoxTexture_property_expand_margin_right>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`expand_margin_top<class_StyleBoxTexture_property_expand_margin_top>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`Color<class_Color>` | :ref:`modulate_color<class_StyleBoxTexture_property_modulate_color>` | ``Color(1, 1, 1, 1)`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`Rect2<class_Rect2>` | :ref:`region_rect<class_StyleBoxTexture_property_region_rect>` | ``Rect2(0, 0, 0, 0)`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`Texture2D<class_Texture2D>` | :ref:`texture<class_StyleBoxTexture_property_texture>` | |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`texture_margin_bottom<class_StyleBoxTexture_property_texture_margin_bottom>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`texture_margin_left<class_StyleBoxTexture_property_texture_margin_left>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`texture_margin_right<class_StyleBoxTexture_property_texture_margin_right>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
| :ref:`float<class_float>` | :ref:`texture_margin_top<class_StyleBoxTexture_property_texture_margin_top>` | ``0.0`` |
+--------------------------------------------------------------+----------------------------------------------------------------------------------------+-----------------------+
.. rst-class:: classref-reftable-group
方法
----
.. table::
:widths: auto
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_expand_margin<class_StyleBoxTexture_method_get_expand_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_texture_margin<class_StyleBoxTexture_method_get_texture_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_expand_margin<class_StyleBoxTexture_method_set_expand_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ ) |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_expand_margin_all<class_StyleBoxTexture_method_set_expand_margin_all>`\ (\ size\: :ref:`float<class_float>`\ ) |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_texture_margin<class_StyleBoxTexture_method_set_texture_margin>`\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ ) |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_texture_margin_all<class_StyleBoxTexture_method_set_texture_margin_all>`\ (\ size\: :ref:`float<class_float>`\ ) |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
列舉
----
.. _enum_StyleBoxTexture_AxisStretchMode:
.. rst-class:: classref-enumeration
enum **AxisStretchMode**: :ref:`🔗<enum_StyleBoxTexture_AxisStretchMode>`
.. _class_StyleBoxTexture_constant_AXIS_STRETCH_MODE_STRETCH:
.. rst-class:: classref-enumeration-constant
:ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **AXIS_STRETCH_MODE_STRETCH** = ``0``
拉伸樣式盒的紋理。這會導致可見的失真,除非紋理大小與樣式盒的大小完美配對。
.. _class_StyleBoxTexture_constant_AXIS_STRETCH_MODE_TILE:
.. rst-class:: classref-enumeration-constant
:ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **AXIS_STRETCH_MODE_TILE** = ``1``
根據九宮格系統,重複樣式盒的紋理,以配對樣式盒的大小。
.. _class_StyleBoxTexture_constant_AXIS_STRETCH_MODE_TILE_FIT:
.. rst-class:: classref-enumeration-constant
:ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **AXIS_STRETCH_MODE_TILE_FIT** = ``2``
根據九宮格系統,重複樣式盒的紋理,以配對樣式盒的大小。與 :ref:`AXIS_STRETCH_MODE_TILE<class_StyleBoxTexture_constant_AXIS_STRETCH_MODE_TILE>` 不同,可能會稍微拉伸紋理以使九宮格紋理平鋪無縫。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
屬性說明
--------
.. _class_StyleBoxTexture_property_axis_stretch_horizontal:
.. rst-class:: classref-property
:ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **axis_stretch_horizontal** = ``0`` :ref:`🔗<class_StyleBoxTexture_property_axis_stretch_horizontal>`
.. rst-class:: classref-property-setget
- |void| **set_h_axis_stretch_mode**\ (\ value\: :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>`\ )
- :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **get_h_axis_stretch_mode**\ (\ )
Controls how the stylebox's texture will be stretched or tiled horizontally.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_axis_stretch_vertical:
.. rst-class:: classref-property
:ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **axis_stretch_vertical** = ``0`` :ref:`🔗<class_StyleBoxTexture_property_axis_stretch_vertical>`
.. rst-class:: classref-property-setget
- |void| **set_v_axis_stretch_mode**\ (\ value\: :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>`\ )
- :ref:`AxisStretchMode<enum_StyleBoxTexture_AxisStretchMode>` **get_v_axis_stretch_mode**\ (\ )
Controls how the stylebox's texture will be stretched or tiled vertically.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_draw_center:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **draw_center** = ``true`` :ref:`🔗<class_StyleBoxTexture_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**\ (\ )
如果為 ``true``\ ,將繪製九宮格紋理的中心圖塊。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_expand_margin_bottom:
.. rst-class:: classref-property
:ref:`float<class_float>` **expand_margin_bottom** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_expand_margin_bottom>`
.. rst-class:: classref-property-setget
- |void| **set_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
繪製時擴充此樣式盒的下邊距,使其繪製得比請求的大。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_expand_margin_left:
.. rst-class:: classref-property
:ref:`float<class_float>` **expand_margin_left** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_expand_margin_left>`
.. rst-class:: classref-property-setget
- |void| **set_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
繪製時擴充此樣式盒的左邊距,使其繪製得比請求的大。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_expand_margin_right:
.. rst-class:: classref-property
:ref:`float<class_float>` **expand_margin_right** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_expand_margin_right>`
.. rst-class:: classref-property-setget
- |void| **set_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
繪製時擴充此樣式盒的右邊距,使其繪製得比請求的大。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_expand_margin_top:
.. rst-class:: classref-property
:ref:`float<class_float>` **expand_margin_top** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_expand_margin_top>`
.. rst-class:: classref-property-setget
- |void| **set_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
繪製時擴充此樣式盒的上邊距,使其繪製得比請求的大。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_modulate_color:
.. rst-class:: classref-property
:ref:`Color<class_Color>` **modulate_color** = ``Color(1, 1, 1, 1)`` :ref:`🔗<class_StyleBoxTexture_property_modulate_color>`
.. rst-class:: classref-property-setget
- |void| **set_modulate**\ (\ value\: :ref:`Color<class_Color>`\ )
- :ref:`Color<class_Color>` **get_modulate**\ (\ )
繪製此樣式盒時用於調變紋理的顏色。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_region_rect:
.. rst-class:: classref-property
:ref:`Rect2<class_Rect2>` **region_rect** = ``Rect2(0, 0, 0, 0)`` :ref:`🔗<class_StyleBoxTexture_property_region_rect>`
.. rst-class:: classref-property-setget
- |void| **set_region_rect**\ (\ value\: :ref:`Rect2<class_Rect2>`\ )
- :ref:`Rect2<class_Rect2>` **get_region_rect**\ (\ )
The region to use from the :ref:`texture<class_StyleBoxTexture_property_texture>`.
This is equivalent to first wrapping the :ref:`texture<class_StyleBoxTexture_property_texture>` in an :ref:`AtlasTexture<class_AtlasTexture>` with the same region.
If empty (``Rect2(0, 0, 0, 0)``), the whole :ref:`texture<class_StyleBoxTexture_property_texture>` is used.
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_texture:
.. rst-class:: classref-property
:ref:`Texture2D<class_Texture2D>` **texture** :ref:`🔗<class_StyleBoxTexture_property_texture>`
.. rst-class:: classref-property-setget
- |void| **set_texture**\ (\ value\: :ref:`Texture2D<class_Texture2D>`\ )
- :ref:`Texture2D<class_Texture2D>` **get_texture**\ (\ )
繪製此樣式盒時所使用的紋理。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_texture_margin_bottom:
.. rst-class:: classref-property
:ref:`float<class_float>` **texture_margin_bottom** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_texture_margin_bottom>`
.. rst-class:: classref-property-setget
- |void| **set_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
增加 3×3 StyleBox 的底邊距。
更高的值意味著更多的源紋理被認為是 3×3 box的底邊的一部分。
如果 :ref:`StyleBox.content_margin_bottom<class_StyleBox_property_content_margin_bottom>` 為負值,這個值也是作為後備值使用。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_texture_margin_left:
.. rst-class:: classref-property
:ref:`float<class_float>` **texture_margin_left** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_texture_margin_left>`
.. rst-class:: classref-property-setget
- |void| **set_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
增加 3×3 StyleBox 的左邊距。
較高的值意味著更多的源紋理被認為是 3×3 box左邊框的一部分。
如果 :ref:`StyleBox.content_margin_left<class_StyleBox_property_content_margin_left>` 為負值,這個值也是作為後備值使用。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_texture_margin_right:
.. rst-class:: classref-property
:ref:`float<class_float>` **texture_margin_right** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_texture_margin_right>`
.. rst-class:: classref-property-setget
- |void| **set_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
增加 3×3 StyleBox 的右邊距。
較高的值意味著更多的源紋理被認為是 3×3 box右邊框的一部分。
如果 :ref:`StyleBox.content_margin_right<class_StyleBox_property_content_margin_right>` 為負值,這個值也是作為後備值使用。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_property_texture_margin_top:
.. rst-class:: classref-property
:ref:`float<class_float>` **texture_margin_top** = ``0.0`` :ref:`🔗<class_StyleBoxTexture_property_texture_margin_top>`
.. rst-class:: classref-property-setget
- |void| **set_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const|
增加 3×3 StyleBox 的上邊距。
較高的值意味著更多的源紋理被認為是 3×3 box上邊框的一部分。
如果 :ref:`StyleBox.content_margin_top<class_StyleBox_property_content_margin_top>` 為負值,這個值也是作為後備值使用。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
方法說明
--------
.. _class_StyleBoxTexture_method_get_expand_margin:
.. rst-class:: classref-method
:ref:`float<class_float>` **get_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_StyleBoxTexture_method_get_expand_margin>`
返回指定邊 :ref:`Side<enum_@GlobalScope_Side>` 的擴充邊距大小。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_method_get_texture_margin:
.. rst-class:: classref-method
:ref:`float<class_float>` **get_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`\ ) |const| :ref:`🔗<class_StyleBoxTexture_method_get_texture_margin>`
返回指定邊 :ref:`Side<enum_@GlobalScope_Side>` 的邊距大小。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_method_set_expand_margin:
.. rst-class:: classref-method
|void| **set_expand_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ ) :ref:`🔗<class_StyleBoxTexture_method_set_expand_margin>`
將指定邊 :ref:`Side<enum_@GlobalScope_Side>` 的擴充邊距設定為 ``size`` 圖元。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_method_set_expand_margin_all:
.. rst-class:: classref-method
|void| **set_expand_margin_all**\ (\ size\: :ref:`float<class_float>`\ ) :ref:`🔗<class_StyleBoxTexture_method_set_expand_margin_all>`
將所有邊的擴充邊距都設定為 ``size`` 圖元。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_method_set_texture_margin:
.. rst-class:: classref-method
|void| **set_texture_margin**\ (\ margin\: :ref:`Side<enum_@GlobalScope_Side>`, size\: :ref:`float<class_float>`\ ) :ref:`🔗<class_StyleBoxTexture_method_set_texture_margin>`
將指定邊 :ref:`Side<enum_@GlobalScope_Side>` 的邊距設定為 ``size`` 圖元。
.. rst-class:: classref-item-separator
----
.. _class_StyleBoxTexture_method_set_texture_margin_all:
.. rst-class:: classref-method
|void| **set_texture_margin_all**\ (\ size\: :ref:`float<class_float>`\ ) :ref:`🔗<class_StyleBoxTexture_method_set_texture_margin_all>`
將所有邊的邊距都設定為 ``size`` 圖元。
.. |virtual| replace:: :abbr:`virtual (本方法通常需要使用者覆寫才能生效。)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (本方法沒有副作用。不會修改該實例的任何成員變數。)`
.. |vararg| replace:: :abbr:`vararg (本方法除了這裡描述的參數外,還可以接受任意數量的參數。)`
.. |constructor| replace:: :abbr:`constructor (本方法用於建構一個型別。)`
.. |static| replace:: :abbr:`static (本方法無需實例即可呼叫,因此可以直接使用類別名稱呼叫。)`
.. |operator| replace:: :abbr:`operator (本方法描述將本型別作為左運算元時可用的有效運算子。)`
.. |bitfield| replace:: :abbr:`BitField (此值是由下列旗標組成的位元遮罩整數。)`
.. |void| replace:: :abbr:`void (無回傳值。)`