public static int hue(int color) {

        double red = (color & RED_MASK) >> 16;
        double green = (color & GREEN_MASK) >> 8;
        double blue = (color & BLUE_MASK);

        return (int)Math.atan2(Math.sqrt(3)*(green - blue), 2*red - green - blue);
    }