analogousColor

Color Gen JS Example - RandomRGB

Code

            
<div class="container" style="width: 100%; height: 100px; display: flex; justify-content: space-between;">
    <div class="b" style="width: 100px; height: 100px;"></div>
    <div class="b" style="width: 100px; height: 100px;"></div>
    <div class="b" style="width: 100px; height: 100px;"></div>
    <div class="b" style="width: 100px; height: 100px;"></div>
    <div class="b" style="width: 100px; height: 100px;"></div>
    <div class="b" style="width: 100px; height: 100px;"></div>
</div>
<script src="../../../dist/colorgen.js"></script>
<script>
    let container = document.getElementsByClassName("container")[0];
    function go(){
        let blocks = container.getElementsByClassName("b");
        let n = blocks.length;
        let colors = colorgen.analogousColor(n, 0.4);
        for (let i = 0; i < blocks.length; i++) {
            let hexc = colorgen.to24BitRGB(colors[i]).toString(16);
            while(hexc.length < 6) hexc = "0" + hexc;
            blocks[i].style.backgroundColor = "#" + hexc;
        }
    }
    go();
    container.onclick = go;
</script>
            
        

Result