-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdxfObject.go
53 lines (44 loc) · 1.17 KB
/
dxfObject.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
// Package dxfeather is a small library for building DXF12 files.
package dxfeather
import (
"strconv"
"strings"
)
// Format a float64 to DXF12 format
func formatFloat64(groupCode string, value float64) string {
return groupCode + "\n" + strconv.FormatFloat(value, 'f', -1, 64) + "\n"
}
// Format a int64 to DXF12 format
func formatInt64(groupCode string, value int64) string {
return groupCode + "\n" + strconv.FormatInt(value, 10) + "\n"
}
// Format a string to DXF12 format
func formatString(groupCode string, value string) string {
return groupCode + "\n" + value + "\n"
}
// Clean up any non-DXF12 characters
func cleanString(value string) string {
value = strings.Replace(value, "#", "_", -1)
value = strings.Replace(value, ".", "_", -1)
return value
}
func renderShape(s interface{}) string {
var res string
switch s.(type) {
case Arc:
res += s.(Arc).toDxfString()
case Circle:
res += s.(Circle).toDxfString()
case Insert:
res += s.(Insert).toDxfString()
case Line:
res += s.(Line).toDxfString()
case Polyline:
res += s.(Polyline).toDxfString()
case Solid:
res += s.(Solid).toDxfString()
case Text:
res += s.(Text).toDxfString()
}
return res
}