Better JavaDoc
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / renderer / raster / shapes / basic / GlowingPoint.java
index a7b4784..b3b9929 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sixth 3D engine. Author: Svjatoslav Agejenko. 
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
  * This project is released under Creative Commons Zero (CC0) license.
  */
 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic;
@@ -15,9 +15,23 @@ import java.util.WeakHashMap;
 import static java.lang.Math.pow;
 import static java.lang.Math.sqrt;
 
+/**
+ * A glowing 3D point rendered with a circular gradient texture.
+ * <p>
+ * This class creates and reuses textures for glowing points of the same color.
+ * The texture is a circle with an alpha gradient from center to edge, ensuring
+ *  a consistent visual appearance regardless of viewing angle.
+ * <p>
+ * The static set of glowing points enables texture sharing and garbage
+ * collection of unused textures via WeakHashMap.
+ */
 public class GlowingPoint extends ForwardOrientedTexture {
 
     private static final int TEXTURE_RESOLUTION_PIXELS = 100;
+    /**
+     * A set of all existing glowing points.
+     * Used to reuse textures of glowing points of the same color.
+     */
     private static final Set<GlowingPoint> glowingPoints = Collections.newSetFromMap(new WeakHashMap<>());
     private final Color color;
 
@@ -31,10 +45,15 @@ public class GlowingPoint extends ForwardOrientedTexture {
         }
     }
 
+
     private static double computeScale(double pointSize) {
         return pointSize / ((double) (TEXTURE_RESOLUTION_PIXELS / 50f));
     }
 
+    /**
+     * Returns a texture for a glowing point of the given color.
+     * The texture is a circle with a gradient from transparent to the given color.
+     */
     private static Texture getTexture(final Color color) {
         // attempt to reuse texture from existing glowing point of the same color
         synchronized (glowingPoints) {
@@ -47,6 +66,10 @@ public class GlowingPoint extends ForwardOrientedTexture {
         return createTexture(color);
     }
 
+    /**
+     * Creates a texture for a glowing point of the given color.
+     * The texture is a circle with a gradient from transparent to the given color.
+     */
     private static Texture createTexture(final Color color) {
         final Texture texture = new Texture(TEXTURE_RESOLUTION_PIXELS, TEXTURE_RESOLUTION_PIXELS, 1);
         int halfResolution = TEXTURE_RESOLUTION_PIXELS / 2;
@@ -55,7 +78,7 @@ public class GlowingPoint extends ForwardOrientedTexture {
             for (int y = 0; y < TEXTURE_RESOLUTION_PIXELS; y++) {
                 int address = texture.primaryBitmap.getAddress(x, y);
 
-                final int distanceFromCenter = (int) sqrt(pow (halfResolution - x, 2) + pow (halfResolution - y, 2));
+                final int distanceFromCenter = (int) sqrt(pow(halfResolution - x, 2) + pow(halfResolution - y, 2));
 
                 int alpha = 255 - ((270 * distanceFromCenter) / halfResolution);
                 if (alpha < 0)