Skip to content

RectTexture ​

Since 2.2.1

RectTexture draws a rounded rectangle using CPU-side tessellation. It is a fallback alternative to SDFRectTexture for environments where the SDF shader is unavailable. Both classes expose the same properties, plus cornerSegments on RectTexture.

Registry name: rect_texture
LSS function: rect(...)

INFO

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

TIP

For most use cases, prefer SDFRectTexture which provides better visual quality at all sizes. Use RectTexture only when you need CPU-side rendering.


Usage ​

java
// Filled rounded rect
IGuiTexture panel = new RectTexture()
    .setColor(0xFF2A2A2A)
    .setRadius(new Vector4f(6, 6, 6, 6));

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

// Static factory
IGuiTexture simple = RectTexture.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 8 0 0);

/* rect(fillColor, radius, strokeWidth, borderColor, cornerSegments) */
background: rect(#2A2A2A, 12, 0, #00000000, 16);
Since 2.2.41

The fifth argument, cornerSegments, was added in 2.2.41. Raise it for large radii that look faceted.

WARNING

rect() reads four radii in CSS order (top-left first), while sdf() reads them from bottom-left. See Texture in LSS.


Fields ​

NameTypeDescription
colorintFill colour (ARGB). Default: 0xFFFFFFFF.
borderColorintStroke colour (ARGB). Default: 0xFF000000.
radiusVector4fPer-corner radii: x = top-left, y = top-right, z = bottom-right, w = bottom-left.
strokefloatBorder stroke width. 0 disables the border.
cornerSegmentsintNumber of line segments per corner arc. Higher = smoother but more vertices. Default: 8.

Methods ​

MethodReturnsDescription
setColor(int)RectTextureSets the fill colour.
setBorderColor(int)RectTextureSets the stroke colour.
setRadius(Vector4f)RectTextureSets per-corner radii.
setStroke(float)RectTextureSets the stroke width.
setCornerSegments(int)RectTextureSets the number of arc segments per corner.
copy()RectTextureReturns a deep copy.
interpolate(IGuiTexture, float)IGuiTextureBlends all properties toward another RectTexture.
RectTexture.of(int)RectTextureStatic factory — creates a rect with the given fill colour.

Released under the MIT License.