-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmosaictypes.go
60 lines (49 loc) · 1.18 KB
/
mosaictypes.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
package gomosaic
import (
"fmt"
)
type Config struct {
GoogleClientId string
GoogleClientSecret string
Sources []ImageSource
}
type ImageSource struct {
Kind string
Path string
Options string
}
//Type representing a tile that can be used in a mosaic
type MosaicTile struct {
Loc string
Filename string
AvgR uint32
AvgG uint32
AvgB uint32
}
func (t MosaicTile) ToString() string {
return fmt.Sprintf("%s;%s;%d;%d;%d", t.Loc, t.Filename, t.AvgR, t.AvgG, t.AvgB)
}
//define a type so we can implement Sort interface
type MosaicTiles []MosaicTile
func (slice MosaicTiles) Len() int {
return len(slice)
}
func (slice MosaicTiles) Less(i, j int) bool {
return slice[i].Filename < slice[j].Filename
}
func (slice MosaicTiles) Swap(i, j int) {
slice[i], slice[j] = slice[j], slice[i]
}
//type representing the average color values of a segment of an image defined by the min/max X/Y coordinates
type ImageSegment struct {
XMin int
YMin int
XMax int
YMax int
RVal uint32
GVal uint32
BVal uint32
}
func (t ImageSegment) ToString() string {
return fmt.Sprintf("(%d,%d) to (%d,%d): %d;%d;%d", t.XMin, t.YMin, t.XMax, t.YMax, t.RVal, t.GVal, t.BVal)
}