Class TextureGenerator

java.lang.Object
eu.svjatoslav.sixth.e3d.renderer.raster.texture.TextureGenerator

public final class TextureGenerator extends Object
Factory class for generating reusable textures with configurable borders and glow effects.

Provides static factory methods to create common texture patterns:

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 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 pixels
      fillColor - the color filling the interior
      borderColor - the color of the border
      borderWidth - the width of the border in pixels
      maxUpscale - 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 pixels
      borderColor - the color of the glowing border
      borderWidth - 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 tint
      maxUpscale - 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

      public static Texture radialGlow(int size, Color color)
      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