File tree 1 file changed +15
-9
lines changed
1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -17,14 +17,29 @@ type Image128 struct {
17
17
bounds image.Rectangle
18
18
}
19
19
20
+ // ColorModel returns the Image's color model.
20
21
func (img * Image128 ) ColorModel () color.Model {
21
22
return color .RGBA64Model
22
23
}
23
24
25
+ // Bounds returns the domain for which At can return non-zero color.
26
+ // The bounds do not necessarily contain the point (0, 0).
24
27
func (img * Image128 ) Bounds () image.Rectangle {
25
28
return img .bounds
26
29
}
27
30
31
+ // At returns the color of the pixel at (x, y).
32
+ // At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid.
33
+ // At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one.
34
+ func (img * Image128 ) At (x int , y int ) color.Color {
35
+ o := img .offset (x , y )
36
+ if o < 0 {
37
+ return color.RGBA {}
38
+ }
39
+ img .at ++
40
+ return img .pix [o ]
41
+ }
42
+
28
43
func (img * Image128 ) offset (x , y int ) int {
29
44
p := image.Point {x , y }
30
45
if ! p .In (img .bounds ) {
@@ -38,15 +53,6 @@ func (img *Image128) offset(x, y int) int {
38
53
return ny * stride + nx
39
54
}
40
55
41
- func (img * Image128 ) At (x int , y int ) color.Color {
42
- o := img .offset (x , y )
43
- if o < 0 {
44
- return color.RGBA {}
45
- }
46
- img .at ++
47
- return img .pix [o ]
48
- }
49
-
50
56
func (img * Image128 ) Set (x int , y int , c color.Color ) {
51
57
o := img .offset (x , y )
52
58
if o < 0 {
You can’t perform that action at this time.
0 commit comments