Advertisement
Guest User

Untitled

a guest
Jun 14th, 2022
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. public static int renderColorToHSB(int color, float saturation, float brightness) {
  2. Color c = new Color(color);
  3. float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
  4. if (hsb[1] < 0.05f) {
  5. return new Color(color).brighter().hashCode();
  6. }
  7. if (hsb[2] < 0.1f) {
  8. return new Color(color).brighter().brighter().brighter().brighter().brighter().hashCode();
  9. }
  10. else if (hsb[2] == 1.0f) {
  11. return Color.HSBtoRGB(hsb[0], saturation, hsb[2]);
  12. }
  13. else if (hsb[2] == 0.9f) {
  14. return Color.HSBtoRGB(hsb[0], saturation, hsb[2] + 0.1f);
  15. }
  16. else if (hsb[2] == 0.8f) {
  17. return Color.HSBtoRGB(hsb[0], saturation, hsb[2] + 0.2f);
  18. }
  19. else if (hsb[2] == 0.7f) {
  20. return Color.HSBtoRGB(hsb[0], saturation, hsb[2] + 0.3f);
  21. }
  22. else if (hsb[2] == 0.6f) {
  23. return Color.HSBtoRGB(hsb[0], saturation, hsb[2] + 0.3f);
  24. }
  25. else if (hsb[2] < 0.6f) {
  26. return Color.HSBtoRGB(hsb[0], saturation, hsb[2] + 0.4f);
  27. }
  28. else return Color.HSBtoRGB(hsb[0], saturation, brightness);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement