Skip to content

RectTexture

自 2.2.1

RectTexture 使用 CPU 端曲面细分绘制圆角矩形。在无法使用 SDF Shader 的环境中,它可作为 SDFRectTexture 的备用方案。两个类公开的属性完全相同。

注册名:rect_texture

INFO

继承自 TransformTexture —— 支持 rotate()scale()transform()

TIP

对于大多数用例,建议优先使用 SDFRectTexture,它在所有尺寸下都能提供更好的视觉效果。仅在需要 CPU 端渲染时使用 RectTexture


用法

java
// 填充圆角矩形
IGuiTexture panel = new RectTexture()
    .setColor(0xFF2A2A2A)
    .setRadius(new Vector4f(6, 6, 6, 6));

// 带描边
IGuiTexture bordered = new RectTexture()
    .setColor(0xFF1A1A1A)
    .setRadius(new Vector4f(4, 4, 4, 4))
    .setStroke(1f)
    .setBorderColor(0xFFFFFFFF);

// 静态工厂方法
IGuiTexture simple = RectTexture.of(0xFF3A3A3A);

字段

名称类型描述
colorint填充颜色(ARGB)。默认值:0xFFFFFFFF
borderColorint描边颜色(ARGB)。默认值:0xFF000000
radiusVector4f每个角的半径:x = 左下角,y = 右下角,z = 右上角,w = 左上角。
strokefloat边框描边宽度。0 表示禁用边框。
cornerSegmentsint每个角圆弧的线段数。数值越高越平滑,但顶点数也越多。默认值:8

方法

方法返回描述
setColor(int)RectTexture设置填充颜色。
setBorderColor(int)RectTexture设置描边颜色。
setRadius(Vector4f)RectTexture设置每个角的半径。
setStroke(float)RectTexture设置描边宽度。
setCornerSegments(int)RectTexture设置每个角圆弧的线段数。
copy()RectTexture返回深拷贝。
interpolate(IGuiTexture, float)IGuiTexture将所有属性混合到另一个 RectTexture
RectTexture.of(int)RectTexture静态工厂方法 —— 创建具有指定填充颜色的矩形。

Released under the MIT License.