le75
clone your own copy | download snapshot

Snapshots | iceberg

Inside this repository

atkins-rgb.html
text/html

Download raw (1.1 KB)

<html>
    <head>
        <title>Dither</title>
    </head>
    <body>  
        <img src="assets/images/cave.jpg" />
        <script type="text/javascript" src="assets/js/dither.js"></script>
        <script type="text/javascript">
            window.addEventListener('load', function () {
                elements = document.getElementsByTagName('img');
                
                function toggleDither() {
                    var src = this.getAttribute('src'),
                        alt = this.getAttribute('alt-src');
                        
                    this.setAttribute('src', alt);
                    this.setAttribute('alt-src', src);
                }
                
                for (var e=0; e < elements.length;e++) {
                    elements[e].setAttribute('alt-src', elements[e].getAttribute('src'));
                    AtkinsDitherRGB(elements[e], 80);
                    elements[e].addEventListener('mouseenter', toggleDither);
                    elements[e].addEventListener('mouseleave', toggleDither);
                }
            }, false);
        </script>
    </body>
</html>