summaryrefslogtreecommitdiff
path: root/grid2.html
blob: 75e6dd283870154b4786deff4b7c2b69a5c7a15c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<link rel="stylesheet" href="css/sally.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="css/ak.css" type="text/css" charset="utf-8" />
<style>
* {
  font-smooth: never;
  -webkit-font-smoothing: none;
}
</style>
<body class="loading">
<center>

<div id="canvas_rapper" style="margin: 0 auto;margin-top:7%">
</div>

</body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="js/util.js"></script>
<script src="js/color.js"></script>
<script src="js/lex.js"></script>
<script src="js/matrix.js"></script>
<script>

// var color_hue_order = ("black dark-blue purple dark-red red orange " +
//                        "yellow lime green teal cyan blue magenta dark-gray light-gray white").split(" ");

function iter (a, n) { for (; n--;) a.unshift(n); return a }
function cartesian (a, b) { var aa = []; a.forEach(function(i){ b.forEach(function(j){ aa.push([i,j]) }) }); return aa }
var xx = iter([], 16)
var yy = iter([], 16)
var xy = shuffle( cartesian(xx, yy) )

var grid_w = 6, grid_h = 4, gap = 1
//var grid_w = 3, grid_h = 3, across = 24, gap = 1
var canvas = new Matrix (96, 64, function(x,y){
  var lex = new Lex (x,y)
  
  var i = floor(x / grid_w)
  var j = floor(y / grid_h)

  if ( (x % grid_w) != grid_w-gap && (y % grid_h) != grid_h-gap) {
    var color = xy[ j * 16 + i ]
    lex.fg = all_hue( color[1] )
    lex.bg = all_hue( color[0] )
    lex.char = "x"
  }
    
  lex.opacity = 1
  lex.build()
  return lex
})
canvas.append(canvas_rapper)

document.body.className = ""
</script>