code: public float bFlat(float y, float A, float B, float C) {
      float tmp1 = Math.min((float) 0, (float) Math.floor(y - B)) * A * (B - y) / B;
      float tmp2 = Math.min((float) 0, (float) Math.floor(C - y)) * (1 - A) * (y - C) / (1 - C);
  
      return correctTo01(A + tmp1 - tmp2);
    }
docs: bFlat transformation