HSVColorWheel

by ewust

HTML

<script src="http://141.212.120.173/client.js"></script>

JavaScript

(new Blinken()).run(function (lights) {
    // My self-contained program goes here.    
    idx = 0
    colors = [0, 0, 1]

    count_up = true;

    // Update lights and return number of ms until
    // this function gets called again.
    return function () {
        for (i = 0; i < 100; i++) {
            lights[i].rgb(colors[0], colors[1], colors[2]);
        }

        if (count_up) {
            colors[idx] += 1/15;
            if (colors[idx] > 14/15) {
                count_up = false;
                idx = (idx - 1) % 3;
                if (idx < 0) idx += 3;
            }
        } else {
            colors[idx] -= 1/15;
            if (colors[idx] < 1/15) {
                count_up = true;
                idx = (idx - 1) % 3;
                if (idx < 0) idx += 3;
            }
        }

        return 100;
    };
});