Class MyColor

java.lang.Object
jme3utilities.math.MyColor

public final class MyColor extends Object
Utility methods for RGBA colors.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Logger
    message logger for this class
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    describe(com.jme3.math.ColorRGBA color)
    Generate a textual description of a ColorRGBA value.
    static com.jme3.math.ColorRGBA
    interpolateLinear(float fraction, com.jme3.math.ColorRGBA start, com.jme3.math.ColorRGBA end)
    Interpolate linearly between 2 colors (with no side effect).
    static com.jme3.math.ColorRGBA
    lerp(float t, com.jme3.math.ColorRGBA c0, com.jme3.math.ColorRGBA c1, com.jme3.math.ColorRGBA storeResult)
    Interpolate linearly between (or extrapolate linearly from) 2 colors.
    static com.jme3.math.ColorRGBA
    parse(String textString)
    Parse a color from the specified text string.
    static com.jme3.math.ColorRGBA
    renderColor(com.jme3.texture.image.ColorSpace colorSpace, com.jme3.math.ColorRGBA encodedColor)
    Convert a gamma-encoded color to the specified ColorSpace.
    static com.jme3.math.ColorRGBA
    saturate(com.jme3.math.ColorRGBA baseColor)
    Generate a brightened and saturated version of a specified color (with no side effect).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      public static final Logger logger
      message logger for this class
  • Method Details

    • describe

      public static String describe(com.jme3.math.ColorRGBA color)
      Generate a textual description of a ColorRGBA value.
      Parameters:
      color - the value to describe (may be null, unaffected)
      Returns:
      a description (not null, not empty)
    • interpolateLinear

      public static com.jme3.math.ColorRGBA interpolateLinear(float fraction, com.jme3.math.ColorRGBA start, com.jme3.math.ColorRGBA end)
      Interpolate linearly between 2 colors (with no side effect).

      Use instead of ColorRGBA.interpolate(), which got renamed in JME 3.1.

      Parameters:
      fraction - (≤1, ≥0)
      start - the first input color (not null, unaffected)
      end - the 2nd input color (not null, unaffected)
      Returns:
      new color, start*(1-fraction) + end*fraction
    • lerp

      public static com.jme3.math.ColorRGBA lerp(float t, com.jme3.math.ColorRGBA c0, com.jme3.math.ColorRGBA c1, com.jme3.math.ColorRGBA storeResult)
      Interpolate linearly between (or extrapolate linearly from) 2 colors.
      Parameters:
      t - the weight given to c1
      c0 - the function value at t=0 (not null, unaffected unless it's storeResult)
      c1 - the function value at t=1 (not null, unaffected unless it's storeResult)
      storeResult - storage for the result (modified if not null, may be c0 or c1)
      Returns:
      the interpolated color (either storeResult or a new instance)
    • parse

      public static com.jme3.math.ColorRGBA parse(String textString)
      Parse a color from the specified text string.
      Parameters:
      textString - input text (not null, not empty)
      Returns:
      a new color instance, or null if text is invalid
    • renderColor

      public static com.jme3.math.ColorRGBA renderColor(com.jme3.texture.image.ColorSpace colorSpace, com.jme3.math.ColorRGBA encodedColor)
      Convert a gamma-encoded color to the specified ColorSpace.
      Parameters:
      colorSpace - the target ColorSpace (not null)
      encodedColor - the input color (not null, unaffected, gamma-encoded)
      Returns:
      a new instance, suitable for use as the color of a viewport background or an unshaded material
    • saturate

      public static com.jme3.math.ColorRGBA saturate(com.jme3.math.ColorRGBA baseColor)
      Generate a brightened and saturated version of a specified color (with no side effect).
      Parameters:
      baseColor - input color (not null, unaffected)
      Returns:
      new color with the same hue, but full brightness and full saturation