ColorRGBA: getAsSrgb() to return ColorRGBA

experimental
Kirill Vainer 10 years ago
parent 0a0fdca0b4
commit 1f0c83ae7d
  1. 36
      jme3-core/src/main/java/com/jme3/math/ColorRGBA.java

@ -607,28 +607,28 @@ public final class ColorRGBA implements Savable, Cloneable, java.io.Serializable
} }
/** /**
* Get the color in sRGB color space as a Vector4f * Get the color in sRGB color space as a <code>ColorRGBA</code>.
* *
* Note that linear values stored in the ColorRGBA will be gamma corrected * Note that linear values stored in the ColorRGBA will be gamma corrected
* and returned as a Vector4f * and returned as a ColorRGBA.
* the x atribute will be fed with the r channel in sRGB space
* the y atribute will be fed with the g channel in sRGB space
* the z atribute will be fed with the b channel in sRGB space
* the w atribute will be fed with the a channel
* *
* Note that no correction will be performed on the alpha channel as it's * The x attribute will be fed with the r channel in sRGB space.
* conventionnally doesn't represent a color itself * The y attribute will be fed with the g channel in sRGB space.
* The z attribute will be fed with the b channel in sRGB space.
* The w attribute will be fed with the a channel.
* *
* @return the color in sRGB color space as a Vector4f * Note that no correction will be performed on the alpha channel as it
*/ * conventionally doesn't represent a color itself.
public Vector4f getAsSrgb(){ *
Vector4f srgb = new Vector4f(); * @return the color in sRGB color space as a ColorRGBA.
float invGama = 1f/GAMMA; */
srgb.x = (float)Math.pow(r, invGama); public ColorRGBA getAsSrgb() {
srgb.y = (float)Math.pow(g, invGama); ColorRGBA srgb = new ColorRGBA();
srgb.z = (float)Math.pow(b, invGama); float invGama = 1f / GAMMA;
srgb.w = a; srgb.r = (float) Math.pow(r, invGama);
srgb.g = (float) Math.pow(g, invGama);
srgb.b = (float) Math.pow(b, invGama);
srgb.a = a;
return srgb; return srgb;
} }

Loading…
Cancel
Save