@@ -319,8 +319,10 @@ public ColorRGBA setAlpha(float value) {
319319 }
320320
321321 /**
322- * Saturate that color ensuring all channels have a value between 0 and 1
323- */
322+ * Saturates this color by clamping all four channels (r, g, b, a)
323+ * to the range [0.0, 1.0] in place.
324+ * Values below 0.0 are raised to 0.0; values above 1.0 are lowered to 1.0.
325+ */
324326 public void clamp () {
325327 r = FastMath .clamp (r , 0f , 1f );
326328 g = FastMath .clamp (g , 0f , 1f );
@@ -807,22 +809,33 @@ public ColorRGBA getAsSrgb() {
807809 }
808810
809811 /**
810- * Helper method to convert a float (0-1) to a byte (0-255).
811- */
812+ * Converts a normalized float channel value to an unsigned byte.
813+ * @param channel the float color channel value, expected in the range [0.0, 1.0]
814+ * @return the channel value scaled to the range [0, 255] and packed as a byte
815+ */
812816 private byte toByte (float channel ) {
813817 return (byte ) ((int ) (channel * 255 ) & 0xFF );
814818 }
815819
816820 /**
817- * Helper method to convert an int (shifted byte) to a float (0-1).
818- */
821+ * Converts a raw shifted integer (representing an unsigned byte) back to a
822+ * normalized float channel value in the range [0.0, 1.0].
823+ * @param channelByte the raw shifted integer from which the lowest 8 bits are extracted
824+ * @return the normalized float channel value in the range [0.0, 1.0]
825+ */
819826 private float fromByte (int channelByte ) {
820827 return ((byte ) (channelByte ) & 0xFF ) / 255f ;
821828 }
822829
823830 /**
824- * Helper method to combine four float channels into an int.
825- */
831+ * Combines four normalized float color channels into a single packed 32-bit integer.
832+ * Each channel is scaled from [0.0, 1.0] to [0, 255] and packed into 8-bit segments.
833+ * @param c1 the first channel (occupies bits 24–31)
834+ * @param c2 the second channel (occupies bits 16–23)
835+ * @param c3 the third channel (occupies bits 8–15)
836+ * @param c4 the fourth channel (occupies bits 0–7)
837+ * @return the four channels combined into a single int
838+ */
826839 private int toInt (float c1 , float c2 , float c3 , float c4 ) {
827840 int r = ((int ) (c1 * 255 ) & 0xFF );
828841 int g = ((int ) (c2 * 255 ) & 0xFF );
0 commit comments