-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Daniel Schauer edited this page Jun 13, 2017
·
6 revisions
randPrttyClrs is a JavaScript library that generates random, pretty colors
Limits the random colors in both their saturation and luminance values to avoid overly bright, or overly dull/gray colors |
<script type="text/javascript" src="../rpc.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("DIV").each(function(){
var cPair = rpc.getRandomPrettyColorPair("HSL");
$(this).css({"background-color":cPair[1],"color":cPair[0]});
});
});
</script>
-
This code will generate a pair of CSS HSL color values for a random hue. The first color element in the returned array is for the darker shade, and the second element is for the lighter shade.
var cPair = rpc.getRandomPrettyColorPair("HSL"); $("DIV").each(function(){ $(this).css({"background-color":cPair[0],"color":cPair[1]}); });