public static double[] toHSL(int r, int g, int b) {
        double rp = r;
        double gp = g;
        double bp = b;
        rp /= 255;
        gp /= 255;
        bp /= 255;
        double cmax = Math.max(rp, Math.max(gp, bp));
        double cmin = Math.min(rp, Math.min(gp, bp));
        double delta = cmax - cmin;
        System.out.println(cmax + " " + cmin + " " + delta);
        double hue;
        if (cmax == rp) {
            hue = 60 * (negMod((int) ((gp - bp) / delta), 6));
        } else if (cmax == gp) {
            hue = 60 * (((bp - rp) / delta) + 2);
        } else {
            hue = 60 * (((rp - gp) / delta) + 4);
        }
        double lightness = (cmax + cmin) / 2;
        double saturation = (delta == 0) ? 0 : (delta / (1 - Math.abs(2 * lightness - 1)));
        return new double[]{hue, saturation, lightness};
    }