private static int ratio(int val1, int val2, float ratio) {
    int value = (int)(val1 + (val2 - val1) * ratio);
    return MathUtil.clamp(value, 0, 255);
  }
private static int ratio(int val1, int val2, float ratio)