I found your HSL class not working as expected, which results in wrong initial position of the progress bars when working in HSL mode
Current code:
float[] hsv2hsl(float[] hsv) {
float a = hsv[0];
float b = hsv[1];
float c = hsv[2];
return new float[] { a, b * c / ((a = (2 - b) * c) < 1 ? a : 2), a/2 };
}
........
@Override
public List<Channel> getChannels() {
List<Channel> list = new ArrayList<>();
list.add(new Channel(R.string.channel_hue, 0, 360, new Channel.ColorExtractor() {
@Override
public int extract(int color) {
return (int) color2hsl(color)[0];
}
}));
list.add(new Channel(R.string.channel_saturation, 0, 100, new Channel.ColorExtractor() {
@Override
public int extract(int color) {
return 100 - (int) color2hsl(color)[1] * 100;
}
}));
list.add(new Channel(R.string.channel_lightness, 0, 100, new Channel.ColorExtractor() {
@Override
public int extract(int color) {
return Math.abs(50 - (int) color2hsl(color)[2] * 100);
}
}));
return list;
}
See proposed fix code below, it works for me as a solution:
float[] hsv2hsl(float[] hsv) {
float a = hsv[0];
float b = hsv[1];
float c = hsv[2];
float l = (2 - b) * c / 2;
return new float[] {a, b * c / (l < 0.5 ? l * 2 : 2 - l * 2), l};
}
.........
@Override
public List<Channel> getChannels() {
List<Channel> list = new ArrayList<>();
list.add(new Channel(R.string.channel_hue, 0, 360, new Channel.ColorExtractor() {
@Override
public int extract(int color) {
return (int) color2hsl(color)[0];
}
}));
list.add(new Channel(R.string.channel_saturation, 0, 100, new Channel.ColorExtractor() {
@Override
public int extract(int color) {
return (int) (color2hsl(color)[1] * 100);
}
}));
list.add(new Channel(R.string.channel_lightness, 0, 100, new Channel.ColorExtractor() {
@Override
public int extract(int color) {
return (int) (color2hsl(color)[2] * 100);
}
}));
return list;
}
I found your HSL class not working as expected, which results in wrong initial position of the progress bars when working in HSL mode
Current code:
........
See proposed fix code below, it works for me as a solution:
.........
Formulas are based on the code found here