summaryrefslogtreecommitdiff
path: root/js/blit.js
blob: 09f39b202461332160dc3f3ac228d2c2d03e1ef0 (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
var blit = (function(){
	var blit = {}
	blit.and = blit.atop = function(A, B, x, y){
		x = x || 0 ; y = y || 0
		B.forEach(function(lex, u, v){
			var cell = A.getCell(u+x, v+y)
			if (cell && lex.opacity > 0) {
				cell.clone(lex)
			}
		})
	}
	blit.or = blit.under = function(A, B, x, y){
		x = x || 0 ; y = y || 0
		B.forEach(function(lex, u, v){
			var cell = A.getCell(u+x, v+y)
			if (cell && cell.opacity == 0) {
				cell.clone(lex)
			}
		})
	}
	blit.set = blit.replace = function(A, B, x, y){
		x = x || 0 ; y = y || 0
		B.forEach(function(lex, u, v){
			var cell = A.getCell(u+x, v+y)
			if (cell) {
				cell.clone(lex)
			}
		})
	}
	blit.invert = function(A, B, x, y){
		x = x || 0 ; y = y || 0
		B.forEach(function(lex, u, v){
			var cell = A.getCell(u+x, v+y)
			if (cell && lex.opacity > 0) {
				cell.fg = get_inverse(cell.fg)
				cell.bg = get_inverse(cell.bg)
			}
		})
	}
	return blit
})()