-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFaces.go
More file actions
82 lines (75 loc) · 1.69 KB
/
Copy pathFaces.go
File metadata and controls
82 lines (75 loc) · 1.69 KB
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
package types
import (
"strconv"
)
// Faces represents a set of directions, on three orthogonal axes, that are
// considered active.
type Faces struct {
Right, Top, Back, Left, Bottom, Front bool
}
// NewFacesFromAxis returns a Faces where the faces corresponding to the given
// Axis values are active.
func NewFacesFromAxis(axes ...Axis) Faces {
f := Faces{}
for _, axis := range axes {
switch axis {
case AxisX:
f.Right = true
f.Left = true
case AxisY:
f.Top = true
f.Bottom = true
case AxisZ:
f.Back = true
f.Front = true
}
}
return f
}
// NewFacesFromFace returns a Faces where the faces corresponding to the given
// Face values are active.
func NewFacesFromFace(faces ...Face) Faces {
f := Faces{}
for _, face := range faces {
switch face {
case FaceRight:
f.Right = true
case FaceLeft:
f.Left = true
case FaceTop:
f.Top = true
case FaceBottom:
f.Bottom = true
case FaceBack:
f.Back = true
case FaceFront:
f.Front = true
}
}
return f
}
// Type returns a string that identifies the type.
func (Faces) Type() string {
return "Faces"
}
// String returns a human-readable string representation of the value.
func (f Faces) String() string {
var b []byte
b = append(b, "Right:"...)
b = strconv.AppendBool(b, f.Right)
b = append(b, ", Top:"...)
b = strconv.AppendBool(b, f.Top)
b = append(b, ", Back:"...)
b = strconv.AppendBool(b, f.Back)
b = append(b, ", Left:"...)
b = strconv.AppendBool(b, f.Left)
b = append(b, ", Bottom:"...)
b = strconv.AppendBool(b, f.Bottom)
b = append(b, ", Front:"...)
b = strconv.AppendBool(b, f.Front)
return string(b)
}
// Copy returns a copy of the value.
func (f Faces) Copy() PropValue {
return f
}