mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-05 14:10:19 +03:00
This reverts commit 57781dc0bc.
The rename, although in line with what we did in the engine, caused problems with RTD we need to fix (or push for a fix) first.
278 lines
11 KiB
ReStructuredText
278 lines
11 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. _class_TextureRect:
|
|
|
|
TextureRect
|
|
===========
|
|
|
|
**繼承:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
|
|
|
顯示紋理的控制項。
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
說明
|
|
----
|
|
|
|
顯示紋理的控制項,例如顯示 GUI 中的圖示。可以使用 :ref:`stretch_mode<class_TextureRect_property_stretch_mode>` 屬性控制紋理的放置。可以在邊界框中進行縮放、平鋪、居中。
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
教學
|
|
----
|
|
|
|
- `3D 體素示範 <https://godotengine.org/asset-library/asset/2755>`__
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
屬性
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
|
|
| :ref:`ExpandMode<enum_TextureRect_ExpandMode>` | :ref:`expand_mode<class_TextureRect_property_expand_mode>` | ``0`` |
|
|
+--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`flip_h<class_TextureRect_property_flip_h>` | ``false`` |
|
|
+--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`flip_v<class_TextureRect_property_flip_v>` | ``false`` |
|
|
+--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
|
|
| :ref:`MouseFilter<enum_Control_MouseFilter>` | mouse_filter | ``1`` (overrides :ref:`Control<class_Control_property_mouse_filter>`) |
|
|
+--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
|
|
| :ref:`StretchMode<enum_TextureRect_StretchMode>` | :ref:`stretch_mode<class_TextureRect_property_stretch_mode>` | ``0`` |
|
|
+--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
|
|
| :ref:`Texture2D<class_Texture2D>` | :ref:`texture<class_TextureRect_property_texture>` | |
|
|
+--------------------------------------------------+--------------------------------------------------------------+-----------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
列舉
|
|
----
|
|
|
|
.. _enum_TextureRect_ExpandMode:
|
|
|
|
.. rst-class:: classref-enumeration
|
|
|
|
enum **ExpandMode**: :ref:`🔗<enum_TextureRect_ExpandMode>`
|
|
|
|
.. _class_TextureRect_constant_EXPAND_KEEP_SIZE:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`ExpandMode<enum_TextureRect_ExpandMode>` **EXPAND_KEEP_SIZE** = ``0``
|
|
|
|
最小尺寸將等於紋理尺寸,即 **TextureRect** 不能小於紋理。
|
|
|
|
.. _class_TextureRect_constant_EXPAND_IGNORE_SIZE:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`ExpandMode<enum_TextureRect_ExpandMode>` **EXPAND_IGNORE_SIZE** = ``1``
|
|
|
|
紋理尺寸不會用於計算最小尺寸,所以 **TextureRect** 可以縮減得比紋理尺寸小。
|
|
|
|
.. _class_TextureRect_constant_EXPAND_FIT_WIDTH:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`ExpandMode<enum_TextureRect_ExpandMode>` **EXPAND_FIT_WIDTH** = ``2``
|
|
|
|
會忽略紋理的高度。最小寬度與目前高度一致。可用於橫向佈局,例如在 :ref:`HBoxContainer<class_HBoxContainer>` 中。
|
|
|
|
.. _class_TextureRect_constant_EXPAND_FIT_WIDTH_PROPORTIONAL:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`ExpandMode<enum_TextureRect_ExpandMode>` **EXPAND_FIT_WIDTH_PROPORTIONAL** = ``3``
|
|
|
|
與 :ref:`EXPAND_FIT_WIDTH<class_TextureRect_constant_EXPAND_FIT_WIDTH>` 相同,但保持紋理的長寬比。
|
|
|
|
.. _class_TextureRect_constant_EXPAND_FIT_HEIGHT:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`ExpandMode<enum_TextureRect_ExpandMode>` **EXPAND_FIT_HEIGHT** = ``4``
|
|
|
|
會忽略紋理的寬度。最小高度與目前寬度一致。可用於縱向佈局,例如在 :ref:`VBoxContainer<class_VBoxContainer>` 中。
|
|
|
|
.. _class_TextureRect_constant_EXPAND_FIT_HEIGHT_PROPORTIONAL:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`ExpandMode<enum_TextureRect_ExpandMode>` **EXPAND_FIT_HEIGHT_PROPORTIONAL** = ``5``
|
|
|
|
與 :ref:`EXPAND_FIT_HEIGHT<class_TextureRect_constant_EXPAND_FIT_HEIGHT>` 相同,但保持紋理的長寬比。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _enum_TextureRect_StretchMode:
|
|
|
|
.. rst-class:: classref-enumeration
|
|
|
|
enum **StretchMode**: :ref:`🔗<enum_TextureRect_StretchMode>`
|
|
|
|
.. _class_TextureRect_constant_STRETCH_SCALE:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_SCALE** = ``0``
|
|
|
|
縮放以適應節點的邊界矩形。
|
|
|
|
.. _class_TextureRect_constant_STRETCH_TILE:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_TILE** = ``1``
|
|
|
|
在節點的邊界矩形內平鋪。
|
|
|
|
.. _class_TextureRect_constant_STRETCH_KEEP:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_KEEP** = ``2``
|
|
|
|
紋理保持它的原始尺寸,並保持在邊界矩形的左上角。
|
|
|
|
.. _class_TextureRect_constant_STRETCH_KEEP_CENTERED:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_KEEP_CENTERED** = ``3``
|
|
|
|
紋理保持其原始大小,並在節點的邊界矩形中保持居中。
|
|
|
|
.. _class_TextureRect_constant_STRETCH_KEEP_ASPECT:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_KEEP_ASPECT** = ``4``
|
|
|
|
縮放紋理以適應節點的邊界矩形,但保持紋理的長寬比。
|
|
|
|
.. _class_TextureRect_constant_STRETCH_KEEP_ASPECT_CENTERED:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_KEEP_ASPECT_CENTERED** = ``5``
|
|
|
|
縮放紋理以適應節點的邊界矩形,使其居中並保持其長寬比。
|
|
|
|
.. _class_TextureRect_constant_STRETCH_KEEP_ASPECT_COVERED:
|
|
|
|
.. rst-class:: classref-enumeration-constant
|
|
|
|
:ref:`StretchMode<enum_TextureRect_StretchMode>` **STRETCH_KEEP_ASPECT_COVERED** = ``6``
|
|
|
|
縮放紋理,使較短的一邊適應邊界矩形。另一邊則裁剪到節點的界限內。
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
屬性說明
|
|
--------
|
|
|
|
.. _class_TextureRect_property_expand_mode:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`ExpandMode<enum_TextureRect_ExpandMode>` **expand_mode** = ``0`` :ref:`🔗<class_TextureRect_property_expand_mode>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_expand_mode**\ (\ value\: :ref:`ExpandMode<enum_TextureRect_ExpandMode>`\ )
|
|
- :ref:`ExpandMode<enum_TextureRect_ExpandMode>` **get_expand_mode**\ (\ )
|
|
|
|
**實驗性:** 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.
|
|
|
|
Defines how minimum size is determined based on the texture's size.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_TextureRect_property_flip_h:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **flip_h** = ``false`` :ref:`🔗<class_TextureRect_property_flip_h>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_flip_h**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_flipped_h**\ (\ )
|
|
|
|
若為 ``true``\ ,紋理將水平翻轉。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_TextureRect_property_flip_v:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **flip_v** = ``false`` :ref:`🔗<class_TextureRect_property_flip_v>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_flip_v**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_flipped_v**\ (\ )
|
|
|
|
若為 ``true``\ ,紋理將垂直翻轉。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_TextureRect_property_stretch_mode:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`StretchMode<enum_TextureRect_StretchMode>` **stretch_mode** = ``0`` :ref:`🔗<class_TextureRect_property_stretch_mode>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_stretch_mode**\ (\ value\: :ref:`StretchMode<enum_TextureRect_StretchMode>`\ )
|
|
- :ref:`StretchMode<enum_TextureRect_StretchMode>` **get_stretch_mode**\ (\ )
|
|
|
|
Controls the texture's behavior when resizing the node's bounding rectangle.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_TextureRect_property_texture:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`Texture2D<class_Texture2D>` **texture** :ref:`🔗<class_TextureRect_property_texture>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_texture**\ (\ value\: :ref:`Texture2D<class_Texture2D>`\ )
|
|
- :ref:`Texture2D<class_Texture2D>` **get_texture**\ (\ )
|
|
|
|
該節點的 :ref:`Texture2D<class_Texture2D>` 資源。
|
|
|
|
.. |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 (無回傳值。)`
|