Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
NinePatchRect
繼承: Control < CanvasItem < Node < Object
顯示紋理的控制項,會保持角落不變,但平鋪邊緣和中心。
說明
也叫 9 片式面板,NinePatchRect 能夠根據較小的紋理,生成任何大小的乾淨面板。為了做到這一點,它將紋理分割成 3×3 的網格。當你縮放節點時,它會在水平或垂直方向上平鋪紋理的側邊,在兩個軸上平鋪中心,但不會縮放或平鋪角落。
屬性
|
||
|
||
|
||
mouse_filter |
|
|
|
||
|
||
|
||
|
||
|
||
方法
get_patch_margin(margin: Side) const |
|
void |
set_patch_margin(margin: Side, value: int) |
訊號
texture_changed() 🔗
當節點的紋理發生變化時觸發。
列舉
enum AxisStretchMode: 🔗
AxisStretchMode AXIS_STRETCH_MODE_STRETCH = 0
在 NinePatchRect 上拉伸中心紋理。這可能會導致紋理失真。
AxisStretchMode AXIS_STRETCH_MODE_TILE = 1
在 NinePatchRect 上重複中心紋理。這不會導致任何可見的失真。 紋理必須是無縫的,這樣才能在邊緣之間不顯示偽影。
AxisStretchMode AXIS_STRETCH_MODE_TILE_FIT = 2
在 NinePatchRect 上重複中心紋理,但也會拉伸紋理以確保每個圖塊都完整可見。這可能會導致紋理扭曲,但少於 AXIS_STRETCH_MODE_STRETCH。紋理必須是無縫的,這樣才能在邊緣之間不顯示偽影。
屬性說明
AxisStretchMode axis_stretch_horizontal = 0 🔗
void set_h_axis_stretch_mode(value: AxisStretchMode)
AxisStretchMode get_h_axis_stretch_mode()
The stretch mode to use for horizontal stretching/tiling.
AxisStretchMode axis_stretch_vertical = 0 🔗
void set_v_axis_stretch_mode(value: AxisStretchMode)
AxisStretchMode get_v_axis_stretch_mode()
The stretch mode to use for vertical stretching/tiling.
如果為 true,則繪製面板的中心。否則,只畫9-slice的邊框。
9-切片底行的高度。邊距為 16 意味著 9-切片的底角和側面將有 16 圖元的高度。你可以單獨設定所有 4 個邊距值,來建立有非均勻邊框的面板。
9-切片左列的寬度。邊距為 16 意味著 9-切片的左角和側面將有 16 圖元的寬度。你可以單獨設定所有 4 個邊距值,來建立有非均勻邊框的面板。
9-切片右列的寬度。邊距為 16 意味著 9-切片的右角和側面將有 16 圖元的寬度。你可以單獨設定所有 4 個邊距值,來建立有非均勻邊框的面板。
9-切片頂行的高度。邊距為 16 意味著 9-切片的頂角和側面將有 16 圖元的高度。你可以單獨設定所有 4 個邊距值,來建立有非均勻邊框的面板。
Rect2 region_rect = Rect2(0, 0, 0, 0) 🔗
要取樣的紋理的矩形區域。如果你正在使用一個合集,使用這個屬性來定義 9-切片應該使用的區域。所有其他屬性都是相對於這個屬性而言的。如果矩形為空,NinePatchRect 將使用整個紋理。
節點的紋理資源。
方法說明
int get_patch_margin(margin: Side) const 🔗
返回指定 Side 的邊距大小。
void set_patch_margin(margin: Side, value: int) 🔗
將給定 Side 的邊距大小設定為 value 圖元。