Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
StyleBoxFlat¶
Inherits: StyleBox < Resource < RefCounted < Object
A customizable StyleBox that doesn't use a texture.
Description¶
By configuring various properties of this style box, you can achieve many common looks without the need of a texture. This includes optionally rounded borders, antialiasing, shadows, and skew.
Setting corner radius to high values is allowed. As soon as corners overlap, the stylebox will switch to a relative system.
Example:
height = 30
corner_radius_top_left = 50
corner_radius_bottom_left = 100
The relative system now would take the 1:2 ratio of the two left corners to calculate the actual corner width. Both corners added will never be more than the height. Result:
corner_radius_top_left: 10
corner_radius_bottom_left: 20
Properties¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods¶
get_border_width ( Side margin ) const |
|
get_border_width_min ( ) const |
|
get_corner_radius ( Corner corner ) const |
|
get_expand_margin ( Side margin ) const |
|
void |
set_border_width ( Side margin, int width ) |
void |
set_border_width_all ( int width ) |
void |
set_corner_radius ( Corner corner, int radius ) |
void |
set_corner_radius_all ( int radius ) |
void |
set_expand_margin ( Side margin, float size ) |
void |
set_expand_margin_all ( float size ) |
Property Descriptions¶
bool anti_aliasing = true
Antialiasing draws a small ring around the edges, which fades to transparency. As a result, edges look much smoother. This is only noticeable when using rounded corners or skew.
Note: When using beveled corners with 45-degree angles (corner_detail = 1), it is recommended to set anti_aliasing to false
to ensure crisp visuals and avoid possible visual glitches.
float anti_aliasing_size = 1.0
This changes the size of the antialiasing effect. 1.0
is recommended for an optimal result at 100% scale, identical to how rounded rectangles are rendered in web browsers and most vector drawing software.
Note: Higher values may produce a blur effect but can also create undesired artifacts on small boxes with large-radius corners.
Color bg_color = Color(0.6, 0.6, 0.6, 1)
The background color of the stylebox.
bool border_blend = false
If true
, the border will fade into the background color.
Color border_color = Color(0.8, 0.8, 0.8, 1)
Sets the color of the border.
int border_width_bottom = 0
Border width for the bottom border.
int border_width_left = 0
Border width for the left border.
int border_width_right = 0
Border width for the right border.
int border_width_top = 0
Border width for the top border.
int corner_detail = 8
This sets the number of vertices used for each corner. Higher values result in rounder corners but take more processing power to compute. When choosing a value, you should take the corner radius (set_corner_radius_all) into account.
For corner radii less than 10, 4
or 5
should be enough. For corner radii less than 30, values between 8
and 12
should be enough.
A corner detail o