Example #1
0
  /**
   * Get the intepolated colour at the given location on the gradient
   *
   * @param p The point of the gradient (0 >= n >= 1)
   * @return The interpolated colour at the given location
   */
  public Color getColorAt(float p) {
    if (p <= 0) return steps.get(0).col;
    if (p > 1) return steps.get(steps.size() - 1).col;

    for (int i = 1; i < steps.size(); i++) {
      Step prev = (steps.get(i - 1));
      Step current = (steps.get(i));

      if (p <= current.location) {
        float dis = current.location - prev.location;
        p -= prev.location;
        float v = p / dis;

        Color c = new Color(1, 1, 1, 1);
        c.a = (prev.col.a * (1 - v)) + (current.col.a * (v));
        c.r = (prev.col.r * (1 - v)) + (current.col.r * (v));
        c.g = (prev.col.g * (1 - v)) + (current.col.g * (v));
        c.b = (prev.col.b * (1 - v)) + (current.col.b * (v));

        return c;
      }
    }

    // shouldn't ever happen
    return Color.black;
  }
Example #2
0
 private Color ret(Color dst, int r, int g, int b, int a) {
   dst.r = r / 255.0f;
   dst.g = g / 255.0f;
   dst.b = b / 255.0f;
   dst.a = a / 255.0f;
   return dst;
 }
Example #3
0
 public static void visualSeekColors(
     Color currentColor,
     float targetR,
     float targetG,
     float targetB,
     float currentStep,
     float stepCount) {
   currentColor.r += ((targetR - currentColor.r) * currentStep) / stepCount;
   currentColor.g += ((targetG - currentColor.g) * currentStep) / stepCount;
   currentColor.b += ((targetB - currentColor.b) * currentStep) / stepCount;
 }
Example #4
0
 public void SetColor(Color refCol) {
   c.a = refCol.a;
   c.r = refCol.r;
   c.g = refCol.g;
   c.b = refCol.b;
 }
Example #5
0
 public static void visualSeekColors(
     Color currentColor, float targetR, float targetG, float targetB, float animationSpeed) {
   currentColor.r += (targetR - currentColor.r) * animationSpeed;
   currentColor.g += (targetG - currentColor.g) * animationSpeed;
   currentColor.b += (targetB - currentColor.b) * animationSpeed;
 }