Skip to content

Commit a057a6d

Browse files
committed
Add method to convert RGBA255 colors to ColorRGBA
1 parent e3161f4 commit a057a6d

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

jme3-core/src/main/java/com/jme3/math/ColorRGBA.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,18 @@ public ColorRGBA fromIntABGR(int color) {
625625
return this;
626626
}
627627

628+
/**
629+
* Converts a color from RGBA 255 values.
630+
* @param r the red value in 0-255 range.
631+
* @param g the green value in 0-255 range.
632+
* @param b the blue value in 0-255 range.
633+
* @param a the alpha value in 0-255 range.
634+
* @return the ColorRGBA equivalent of the RGBA 255 color.
635+
*/
636+
public static ColorRGBA fromRGBA255(int r, int g, int b, int a) {
637+
return new ColorRGBA(r / 255.0F, g / 255.0F, b / 255.0F, a / 255.0F);
638+
}
639+
628640
/**
629641
* Transform this <code>ColorRGBA</code> to a <code>Vector3f</code> using
630642
* x = r, y = g, z = b. The Alpha value is not used.

0 commit comments

Comments
 (0)