Skip to content

SDFRectTexture

Since 2.2.1

SDFRectTexture draws a rounded rectangle using an SDF (Signed Distance Field) GPU shader. It produces sharp, anti-aliased edges at any size. Supports per-corner radii, an optional stroke border, and smooth CSS-transition interpolation.

Registry name: sdf_rect_texture
LSS function: rect(...) / sdf(...)

INFO

Extends TransformTexture — supports rotate(), scale(), transform().


Usage

java
// Filled rounded rect
IGuiTexture panel = new SDFRectTexture()
    .setColor(0xFF2A2A2A)
    .setRadius(6f);

// Rounded rect with a white stroke
IGuiTexture bordered = new SDFRectTexture()
    .setColor(0xFF1A1A1A)
    .setRadius(4f)
    .setStroke(1f)
    .setBorderColor(0xFFFFFFFF);

// Static factory
IGuiTexture simple = SDFRectTexture.of(0xFF3A3A3A);

LSS

css
/* rect(fillColor) */
background: rect(#2A2A2A);

/* rect(fillColor, radius) */
background: rect(#2A2A2A, 6);

/* rect(fillColor, radius, strokeWidth, borderColor) */
background: rect(#2A2A2A, 4, 1, #FFFFFF);

/* Per-corner radii: top-left top-right bottom-right bottom-left */
background: rect(#2A2A2A, 8 4 8 4);

Fields

NameTypeDescription
colorintFill colour (ARGB). Default: 0xFFFFFFFF.
borderColorintStroke colour (ARGB). Default: 0xFF000000.
radiusVector4fPer-corner radii: x = bottom-left, y = bottom-right, z = top-right, w = top-left.
strokefloatBorder stroke width in pixels. 0 disables the border.

Methods

MethodReturnsDescription
setColor(int)SDFRectTextureSets the fill colour.
setBorderColor(int)SDFRectTextureSets the stroke colour.
setRadius(float)SDFRectTextureSets all four corner radii to the same value.
setRadius(Vector4f)SDFRectTextureSets per-corner radii.
setStroke(float)SDFRectTextureSets the stroke width.
copy()SDFRectTextureReturns a deep copy.
interpolate(IGuiTexture, float)IGuiTextureBlends all properties toward another SDFRectTexture.
SDFRectTexture.of(int)SDFRectTextureStatic factory — creates a rect with the given fill colour.

Released under the MIT License.