-
Notifications
You must be signed in to change notification settings - Fork 8
/
imagemap.go
97 lines (84 loc) · 2.28 KB
/
imagemap.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
package linebot
// ImagemapActionType ...
type ImagemapActionType string
// ImagemapActionType ...
const (
ImagemapActionTypeURI ImagemapActionType = "uri"
ImagemapActionTypeMessage ImagemapActionType = "message"
)
// ImagemapAction ...
type ImagemapAction interface {
imagemapAction()
}
// ImagemapMessage ...
type ImagemapMessage struct {
Type MessageType `json:"type"`
BaseURL string `json:"baseUrl"`
AltText string `json:"altText"`
BaseSize ImagemapBaseSize `json:"baseSize"`
Actions []ImagemapAction `json:"actions"`
}
// ImagemapBaseSize ...
type ImagemapBaseSize struct {
Width int `json:"width"`
Height int `json:"height"`
}
// ImagemapArea ...
type ImagemapArea struct {
X int `json:"x"`
Y int `json:"y"`
Width int `json:"width"`
Height int `json:"height"`
}
// ImagemapURIAction ...
type ImagemapURIAction struct {
Type ImagemapActionType `json:"type"`
LinkURI string `json:"linkUri"`
Area ImagemapArea `json:"area"`
}
// ImagemapMessageAction ...
type ImagemapMessageAction struct {
Type ImagemapActionType `json:"type"`
Text string `json:"text"`
Area ImagemapArea `json:"area"`
}
func (*ImagemapURIAction) imagemapAction() {}
func (*ImagemapMessageAction) imagemapAction() {}
// NewImagemapMessage ...
func NewImagemapMessage(baseURL, altText string, baseSizeWidth, baseSizeHeght int, actions ...ImagemapAction) *ImagemapMessage {
m := new(ImagemapMessage)
m.Type = MessageTypeImagemap
m.BaseURL = baseURL
m.AltText = altText
size := new(ImagemapBaseSize)
size.Width = baseSizeWidth
size.Height = baseSizeHeght
m.BaseSize = *size
m.Actions = actions
return m
}
// NewImagemapURIAction ...
func NewImagemapURIAction(linkURI string, area ImagemapArea) *ImagemapURIAction {
a := new(ImagemapURIAction)
a.Type = ImagemapActionTypeURI
a.LinkURI = linkURI
a.Area = area
return a
}
// NewImagemapMessageAction ...
func NewImagemapMessageAction(text string, area ImagemapArea) *ImagemapMessageAction {
a := new(ImagemapMessageAction)
a.Type = ImagemapActionTypeMessage
a.Text = text
a.Area = area
return a
}
// NewImagemapArea ...
func NewImagemapArea(x, y, width, height int) *ImagemapArea {
a := new(ImagemapArea)
a.X = x
a.Y = y
a.Width = width
a.Height = height
return a
}