-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstring_data.go
More file actions
51 lines (39 loc) · 733 Bytes
/
string_data.go
File metadata and controls
51 lines (39 loc) · 733 Bytes
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
package gen
import (
"bufio"
"strconv"
"strings"
)
type StringData struct {
Type string
Pos *Point
Angle float64
Height float64
String string
}
func readStringData(s *bufio.Scanner) *StringData {
sd := new(StringData)
pos := new(Point)
for s.Scan() {
k, v, ok := strings.Cut(s.Text(), "=")
if !ok {
break
}
switch k {
case "STRING_TYPE":
sd.Type = v
case "STRING_POSITION_U":
pos.X, _ = strconv.ParseFloat(v, 64)
case "STRING_POSITION_V":
pos.Y, _ = strconv.ParseFloat(v, 64)
case "STRING_ANGLE":
sd.Angle, _ = strconv.ParseFloat(v, 64)
case "STRING_HEIGHT":
sd.Height, _ = strconv.ParseFloat(v, 64)
case "STRING":
sd.String = v
}
}
sd.Pos = pos
return sd
}