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.

Registry name: rect_texture

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);

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. 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.