Guest User

Untitled

a guest
Nov 2nd, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1.     public static String rainbowText(String data) {
  2.         StringBuilder builder = new StringBuilder();
  3.         for(int i = 0; i < data.length(); i++) {
  4.             float hue = map(i, 0F, data.length(), 0.1F, 1F);
  5.             float saturation = 0.6f; //saturation
  6.             float brightness = 1f; //brightness
  7.             Color color = Color.getHSBColor(hue, saturation, brightness);
  8.             builder.append(String.format("#%s#%s", Integer.toHexString(-color.getRGB()), data.charAt(i)));
  9.         }
  10.         return builder.toString();
  11.     }
  12.    
  13.     public static final float map(float value, float minValue, float maxValue, float minExpectedValue, float maxExpectedValue) {
  14.         return minExpectedValue + (maxExpectedValue - minExpectedValue) * ((value - minValue) / (maxValue - minValue));
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment