Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int renderColorToHSB(int color, float saturation, float brightness) {
- Color c = new Color(color);
- float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
- if (hsb[1] < 0.05f) {
- return new Color(color).brighter().hashCode();
- }
- if (hsb[2] < 0.1f) {
- return new Color(color).brighter().brighter().brighter().brighter().brighter().hashCode();
- }
- else if (hsb[2] == 1.0f) {
- return Color.HSBtoRGB(hsb[0], saturation, hsb[2]);
- }
- else if (hsb[2] == 0.9f) {
- return Color.HSBtoRGB(hsb[0], saturation, hsb[2] + 0.1f);
- }
- else if (hsb[2] == 0.8f) {
- return Color.HSBtoRGB(hsb[0], saturation, hsb[2] + 0.2f);
- }
- else if (hsb[2] == 0.7f) {
- return Color.HSBtoRGB(hsb[0], saturation, hsb[2] + 0.3f);
- }
- else if (hsb[2] == 0.6f) {
- return Color.HSBtoRGB(hsb[0], saturation, hsb[2] + 0.3f);
- }
- else if (hsb[2] < 0.6f) {
- return Color.HSBtoRGB(hsb[0], saturation, hsb[2] + 0.4f);
- }
- else return Color.HSBtoRGB(hsb[0], saturation, brightness);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement