-
-
Save dandelion-lowcode/8480ec0a37e6faab400aeaf5377b7562 to your computer and use it in GitHub Desktop.
Random EOL color
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
operation String getRandomColor() { | |
var seed = new Native("java.lang.Long")(self.hashCode().longValue()); | |
var random = new Native("java.util.Random")(seed); | |
var h = random.nextFloat(); | |
var s = random.nextFloat() * 0.5f; | |
var b = random.nextFloat() * 0.50f + 0.40f; | |
var color = Native("java.awt.Color").getHSBColor(h, s, b); | |
return "#" + color.getRed().toHex() + color.getGreen().toHex() + color.getBlue().toHex(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment