Would ColorRGBA interpolation interest anyone?

Nothing extremely hardcore, but just made that one based off the Vector3f interpolation.

[java]

This patch file was generated by NetBeans IDE

It uses platform neutral UTF-8 encoding and \n newlines.

— Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -584,6 +584,56 @@
}

 /**
  • * Linear color interpolation from startColor to endColor by the given percent
    
  • * while ignoring the alpha value of the color.
    
  • * 
    
  • * Basically: ((1 - percent) * startColor) + (percent * endColor)
    
  • *
    
  • * @param scale
    
  • *            scale value to use. if 1, use endColor, if 0, use startColor.
    
  • * @param startColor
    
  • *            Begining color. 0% of f
    
  • * @param endColor
    
  • *            ending color. 100% of f
    
  • * @param store a ColorRGBA to store the result in.
    
  • * @return The interpolated value between startColor and endColor.
    
  • */
    
  • public static ColorRGBA interpolateColorsLinear(float scale, ColorRGBA startColor, ColorRGBA endColor, ColorRGBA store) {
  •    if (store == null) {
    
  •        store = new ColorRGBA();
    
  •    }
    
  •    store.r = FastMath.interpolateLinear(scale, startColor.r, endColor.r);
    
  •    store.g = FastMath.interpolateLinear(scale, startColor.g, endColor.g);
    
  •    store.b = FastMath.interpolateLinear(scale, startColor.b, endColor.b);
    
  •    return store;
    
  • }
  • /**
  • * Linear interpolation from startColor to endColor by the given percent 
    
  • * including the colors' alpha value.
    
  • * Basically: ((1 - percent) * startColor) + (percent * endColor)
    
  • *
    
  • * @param scale
    
  • *            scale color value to use. if 1, use endColor, if 0, use startColor.
    
  • * @param startColor
    
  • *            Begining color. 0% of f
    
  • * @param endColor
    
  • *            ending color. 100% of f
    
  • * @param store a ColorRGBA to store the result in.
    
  • * @return The interpolated value between startColor and endColor.
    
  • */
    
  • public static ColorRGBA interpolateColorsAndAlphaLinear(float scale, ColorRGBA startColor, ColorRGBA endColor, ColorRGBA store) {
  •    if (store == null) {
    
  •        store = new ColorRGBA();
    
  •    }
    
  •    store.r = FastMath.interpolateLinear(scale, startColor.r, endColor.r);
    
  •    store.g = FastMath.interpolateLinear(scale, startColor.g, endColor.g);
    
  •    store.b = FastMath.interpolateLinear(scale, startColor.b, endColor.b);
    
  •    store.a = FastMath.interpolateLinear(scale, startColor.a, endColor.a);
    
  •    return store;
    
  • }
  • /**
    • Transform this ColorRGBA to a Vector4f using
    • x = r, y = g, z = b, w = a.
    • This method is useful to use for shaders assignment.
      [/java]

AFAIK there is already methods for interpolation on the ColorRGBA object =)

@kwando said: AFAIK there is already methods for interpolation on the ColorRGBA object =)

Yep:
http://hub.jmonkeyengine.org/javadoc/com/jme3/math/ColorRGBA.html#interpolate(com.jme3.math.ColorRGBA,%20float)
http://hub.jmonkeyengine.org/javadoc/com/jme3/math/ColorRGBA.html#interpolate(com.jme3.math.ColorRGBA,%20com.jme3.math.ColorRGBA,%20float)

I guess that’s what happens when you pull a 12 hours. XD

I guess I was thrown off by the fact that none of those are static, as one would expect these I guess.

I added an interpolation without the alpha.

[java]
public void interpolateNoAlpha(ColorRGBA beginColor, ColorRGBA finalColor, float changeAmnt) {
this.r = (1 - changeAmnt) * beginColor.r + changeAmnt * finalColor.r;
this.g = (1 - changeAmnt) * beginColor.g + changeAmnt * finalColor.g;
this.b = (1 - changeAmnt) * beginColor.b + changeAmnt * finalColor.b;
}
[/java]