Class TextureGenerator
Provides static factory methods to create common texture patterns:
solidWithBorder(int, Color, Color, int, int)- solid fill color with opaque border (for bordered polygons)glowingBorder(int, Color, int, int, boolean, int)- transparent center with glowing edges (for wireframe-effect shapes)radialGlow(int, Color)- circular radial gradient (for point/billboard glows)
Texture caching: Textures are cached by their generation parameters using a
WeakReference-based cache. When textures are no longer referenced elsewhere,
they are automatically garbage collected. This reduces memory usage when many shapes
share identical textures.
Example usage:
// RGB cube plate with black border
Texture tex1 = TextureGenerator.solidWithBorder(64, new Color(255, 0, 0), new Color(0, 0, 0), 3);
// Wireframe-effect texture (glowing cyan edges, transparent center)
Texture tex2 = TextureGenerator.glowingBorder(64, new Color(0, 255, 255), 6, 120, true);
// Circular glow point
Texture tex3 = TextureGenerator.radialGlow(100, new Color(255, 200, 100));
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic TextureglowingBorder(int size, Color borderColor, int borderWidth, int glowIntensity, boolean transparent, int maxUpscale) Creates a texture with a transparent center and glowing border edges.static TextureradialGlow(int size, Color color) Creates a texture with a circular radial gradient glow.static TexturesolidWithBorder(int size, Color fillColor, Color borderColor, int borderWidth, int maxUpscale) Creates a texture with a solid fill color and an opaque border.
-
Method Details
-
solidWithBorder
public static Texture solidWithBorder(int size, Color fillColor, Color borderColor, int borderWidth, int maxUpscale) Creates a texture with a solid fill color and an opaque border.The fill color fills the entire texture except for the border region. The border is drawn as an opaque rectangle inset from the edges.
Caching: Identical parameters produce the same cached texture instance.
- Parameters:
size- the texture width and height in pixelsfillColor- the color filling the interiorborderColor- the color of the borderborderWidth- the width of the border in pixelsmaxUpscale- the maximum number of upscaled mipmap levels (0 = no upscale, 1 = 2x upscale, 2 = 4x upscale)- Returns:
- a texture with solid fill and opaque border
-
glowingBorder
public static Texture glowingBorder(int size, Color borderColor, int borderWidth, int glowIntensity, boolean transparent, int maxUpscale) Creates a texture with a transparent center and glowing border edges.This texture is useful for creating wireframe-effect shapes: the polygon appears to have only edges, with the interior being transparent. The border has a glow effect where intensity decreases from the edge toward the center.
Glow effect: Multiple concentric border lines are drawn with decreasing alpha values, creating a luminous edge appearance. The glow intensity controls how bright the innermost edge appears.
Caching: Identical parameters produce the same cached texture instance.
- Parameters:
size- the texture width and height in pixelsborderColor- the color of the glowing borderborderWidth- the width of the border region in pixels (where glow appears)glowIntensity- the base intensity added to the border color (0-255 range)transparent- if true, center is fully transparent; if false, has slight tintmaxUpscale- the maximum number of upscaled mipmap levels (0 = no upscale, 1 = 2x upscale, 2 = 4x upscale)- Returns:
- a texture with glowing edges and transparent center
-
radialGlow
Creates a texture with a circular radial gradient glow.The texture has a circular alpha gradient: fully opaque at the center, transitioning to fully transparent at the edges. The color intensity remains constant while alpha decreases radially.
This is suitable for rendering glowing points or circular billboards. The center of the texture is the brightest point, fading outward.
Caching: Identical parameters produce the same cached texture instance.
- Parameters:
size- the texture width and height in pixels (should be even)color- the color of the glow (alpha is overridden by radial gradient)- Returns:
- a texture with circular radial alpha gradient
-