~whatsthepalette/whatsthepalette/main

« back to all changes in this revision

Viewing changes to js_test.html

  • Committer: Jesse Dunlap
  • Date: 2011-10-02 05:11:06 UTC
  • Revision ID: jdunlap0@gmail.com-20111002051106-0v9id723xno911x0
Ported the PHP image algorithm to JavaScript and added a test file (js_test.html)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!--
 
2
 
 
3
This page tests out the JavaScript image algorithm. The algorithm is a port of the php
 
4
algorithm that can be found in app/php/image_algorithm.php.
 
5
 
 
6
-->
 
7
 
 
8
<!DOCTYPE html>
 
9
<html>
 
10
        <head>
 
11
                <title>WTPImage JS Test</title>
 
12
                
 
13
                <script type="text/javascript" src="app/javascripts/wtpimage.js"></script>
 
14
 
 
15
                <script type="text/javascript">
 
16
                function run()
 
17
                {
 
18
                        // Get all of the colors (skip every 4 pixels for speed)
 
19
                        var colors = WTPImage.getColors('app/php/test_image.png', 4);
 
20
                        
 
21
                        // Get unique colors from the list of colors
 
22
                        var unique = WTPImage.uniqueColors(colors, 5);
 
23
 
 
24
                        // Print out the colors to the screen
 
25
                        var total = unique.length;
 
26
                        var html = '';
 
27
 
 
28
                        for (var i = 0; i < total; i++)
 
29
                        {
 
30
                                console.log(WTPImage.getRGB(unique[i]));
 
31
                                html += '<div style="float: left; margin: 20px; width: 30px; height: 30px; box-shadow: 0px 1px 2px #000; background-color: ' + WTPImage.getRGB(unique[i]) + ';"></div>';
 
32
                        }
 
33
 
 
34
                        // Display the HTML
 
35
                        document.write(html);
 
36
                }
 
37
                </script>
 
38
        </head>
 
39
        
 
40
        <body onLoad="run()">
 
41
                <!-- This allows us to manipulate the images -->
 
42
                <canvas id="wtpc" style="display: none;"></canvas>
 
43
        </body>
 
44
</html>
 
 
b'\\ No newline at end of file'