baseColorPicker.colorProperty().addListener(updateReverse);
desiredColorPicker.colorProperty().addListener(updateReverse);
}
private void updateReverse() {
Color desiredColor = desiredColorPicker.getColor();
final Color base = baseColorPicker.getColor();
// System.out.println("base = " + base);
double desiredBrightness = desiredColor.getBrightness();
// System.out.println("desiredBrightness = " + desiredBrightness);
double desiredSaturation = desiredColor.getSaturation();
// System.out.println("desiredSaturation = " + desiredSaturation);
double derivation = 0, max = 1, min = -1;
Color derivedColor = Color.WHITE;
for(int i=0; i< 100;i++){
// System.out.println("---------- "+i+" ----------------");
// System.out.println("derivation = " + derivation);
// System.out.println("max = " + max);
// System.out.println("min = " + min);
derivedColor = Utils.deriveColor(base, derivation);
double derivedBrightness = derivedColor.getBrightness();
// System.out.println("derivedBrightness = " + derivedBrightness);
double derivedSaturation = derivedColor.getSaturation();
// System.out.println("derivedSaturation = " + derivedSaturation);
double saturationDifference = Math.abs(derivedSaturation-desiredSaturation);
// System.out.println("saturationDifference = " + saturationDifference);
double difference = Math.abs(derivedBrightness-desiredBrightness);
// System.out.println("brightness difference = " + difference);