summaryrefslogtreecommitdiff
path: root/js/ui/palette.js
blob: 3976100d395e9cb6c9144d8612e2a3215424abe5 (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
var palette = (function(){

	var palette = new Matrix (32, 2, function(x,y){
		var lex = new Lex (x,y)
		lex.bg = all_inv_hue(x>>1)
		lex.build()
		return lex
	})

	palette.bind = function(){
		palette.forEach(function(lex, x, y){
  		if (lex.bound) return
  		lex.bound = true

			lex.span.addEventListener('mousedown', function(e){
				e.preventDefault()
				dragging = true
				erasing = e.which == "3"
				brush.fg = lex.bg
				brush.bg = lex.bg
				if (! brush.modified) {
					brush.generate()
				}
			})

		})
	}
	
	return palette

})()