-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitblt_opt.go
61 lines (53 loc) · 1.51 KB
/
bitblt_opt.go
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
55
56
57
58
59
60
61
package tcg
// Options for BitBlt
type BitBltOpt func(*bitBltOptions)
type bitBltOptions struct {
// if true, then BitBlt will not copy pixels with color 0 (transparent)
transparent bool
// mask - if not nil, then BitBlt will copy only pixels with color != 0 in mask
mask *Buffer
// list of operations for each pixel
operations []func(orig, src int) int
}
// BBTransparent - if true, then BitBlt will not copy pixels with color 0 (transparent)
func BBTransparent() BitBltOpt {
return func(o *bitBltOptions) {
o.transparent = true
}
}
// BBMask - copy only pixels with color != 0 in mask
func BBMask(mask *Buffer) BitBltOpt {
return func(o *bitBltOptions) {
o.mask = mask
}
}
// BBOpFn - add function for each pixel of source and destination
func BBOpFn(fn func(orig, src int) int) BitBltOpt {
return func(o *bitBltOptions) {
o.operations = append(o.operations, fn)
}
}
// BBAnd - AND operation for each pixel of source and destination
func BBAnd() BitBltOpt {
return func(o *bitBltOptions) {
o.operations = append(o.operations, func(orig, src int) int {
return orig & src
})
}
}
// BBOr - OR operation for each pixel of source and destination
func BBOr() BitBltOpt {
return func(o *bitBltOptions) {
o.operations = append(o.operations, func(orig, src int) int {
return orig | src
})
}
}
// BBXor - XOR operation for each pixel of source and destination
func BBXor() BitBltOpt {
return func(o *bitBltOptions) {
o.operations = append(o.operations, func(orig, src int) int {
return orig ^ src
})
}
}