From a057a6d74d25a4f8bc769f9d72c98ead4d28492c Mon Sep 17 00:00:00 2001 From: jayfella Date: Wed, 22 Apr 2020 09:32:55 +0100 Subject: [PATCH] Add method to convert RGBA255 colors to ColorRGBA --- jme3-core/src/main/java/com/jme3/math/ColorRGBA.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/jme3-core/src/main/java/com/jme3/math/ColorRGBA.java b/jme3-core/src/main/java/com/jme3/math/ColorRGBA.java index 60b554f5f..f3b1f5350 100644 --- a/jme3-core/src/main/java/com/jme3/math/ColorRGBA.java +++ b/jme3-core/src/main/java/com/jme3/math/ColorRGBA.java @@ -625,6 +625,18 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable return this; } + /** + * Converts a color from RGBA 255 values. + * @param r the red value in 0-255 range. + * @param g the green value in 0-255 range. + * @param b the blue value in 0-255 range. + * @param a the alpha value in 0-255 range. + * @return the ColorRGBA equivalent of the RGBA 255 color. + */ + public static ColorRGBA fromRGBA255(int r, int g, int b, int a) { + return new ColorRGBA(r / 255.0F, g / 255.0F, b / 255.0F, a / 255.0F); + } + /** * Transform this ColorRGBA to a Vector3f using * x = r, y = g, z = b. The Alpha value is not used.