-
Notifications
You must be signed in to change notification settings - Fork 1
/
interp.go
108 lines (93 loc) · 1.88 KB
/
interp.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package hq2x
import "image/color"
func _interp1(a, b uint8) uint8 {
return uint8((uint(a)*3 + uint(b)) / 4)
}
func interp1(a, b color.RGBA) color.RGBA {
R := _interp1(a.R, b.R)
G := _interp1(a.G, b.G)
B := _interp1(a.B, b.B)
return color.RGBA{
R: R,
G: G,
B: B,
}
}
func _interp2(a, b, c uint8) uint8 {
return uint8((uint(a)*2 + uint(b) + uint(c)) / 4)
}
func interp2(a, b, c color.RGBA) color.RGBA {
R := _interp2(a.R, b.R, c.R)
G := _interp2(a.G, b.G, c.G)
B := _interp2(a.B, b.B, c.B)
return color.RGBA{
R: R,
G: G,
B: B,
}
}
func _interp5(a, b uint8) uint8 {
return uint8((uint(a) + uint(b)) / 2)
}
func interp5(a, b color.RGBA) color.RGBA {
R := _interp5(a.R, b.R)
G := _interp5(a.G, b.G)
B := _interp5(a.B, b.B)
return color.RGBA{
R: R,
G: G,
B: B,
}
}
func _interp6(a, b, c uint8) uint8 {
return uint8((uint(a)*5 + uint(b)*2 + uint(c)) / 8)
}
func interp6(a, b, c color.RGBA) color.RGBA {
R := _interp6(a.R, b.R, c.R)
G := _interp6(a.G, b.G, c.G)
B := _interp6(a.B, b.B, c.B)
return color.RGBA{
R: R,
G: G,
B: B,
}
}
func _interp7(a, b, c uint8) uint8 {
return uint8((uint(a)*6 + uint(b) + uint(c)) / 8)
}
func interp7(a, b, c color.RGBA) color.RGBA {
R := _interp7(a.R, b.R, c.R)
G := _interp7(a.G, b.G, c.G)
B := _interp7(a.B, b.B, c.B)
return color.RGBA{
R: R,
G: G,
B: B,
}
}
func _interp9(a, b, c uint8) uint8 {
return uint8((uint(a)*2 + uint(b)*3 + uint(c)*3) / 8)
}
func interp9(a, b, c color.RGBA) color.RGBA {
R := _interp9(a.R, b.R, c.R)
G := _interp9(a.G, b.G, c.G)
B := _interp9(a.B, b.B, c.B)
return color.RGBA{
R: R,
G: G,
B: B,
}
}
func _interp10(a, b, c uint8) uint8 {
return uint8((uint(a)*14 + uint(b) + uint(c)) / 16)
}
func interp10(a, b, c color.RGBA) color.RGBA {
R := _interp10(a.R, b.R, c.R)
G := _interp10(a.G, b.G, c.G)
B := _interp10(a.B, b.B, c.B)
return color.RGBA{
R: R,
G: G,
B: B,
}
}