-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
52 lines (41 loc) · 924 Bytes
/
main.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
package main
import (
"go-cubic/pkg/cube"
"html/template"
"os"
"path"
)
var (
tmpl *template.Template
)
const (
outPath = "out/"
)
func GenerateHTML(c *cube.Cube, filename string) error {
file, err := os.Create(path.Join(outPath, filename))
if err != nil {
return err
}
defer file.Close()
data := struct {
Faces *cube.CubeFaces
Dimension int
}{c.Faces(), c.Dimension()}
return tmpl.ExecuteTemplate(file, "cube", data)
}
func init() {
var err error
tmpl, err = template.ParseFiles("ui/html/cube.tmpl")
if err != nil {
panic("Failed to parse template: " + err.Error())
}
}
func main() {
input := "U2 R2 B L2 U2 D2 F' U2 F B2 L' B' D F U L' B' D R2 Fw2 D L Rw2 Fw2 L D2 F2 L' U' R' F Fw' D' R2 D B2 Rw' Uw2 R Rw' D Rw2 Uw'"
group, _ := cube.ParseNotation(input)
group.Print()
moves, _ := group.Expand()
c := cube.NewCube(4)
c.ExecuteMoves(moves...)
GenerateHTML(c, "cube.html")
}