diff --git a/clockface.go b/clockface.go
index 1c65078..c68d6bf 100644
--- a/clockface.go
+++ b/clockface.go
@@ -1 +1,34 @@
package clockface
+
+import (
+ "git.nerdfortress.dev/mitch/clockface"
+ "math"
+)
+
+const secondHandLength = 90
+const clockCentreX = 150
+const clockCentreY = 150
+
+type Point struct {
+ X float64
+ Y float64
+}
+
+func SecondHand(t time.Time) Point {
+ p := secondHandPoint(t)
+ p = Point{p.X * secondHandLength, p.Y * secondHandLength} //scale
+ p = Point{p.X, -p.Y} //flip
+ p = Point{p.X + clockCentreX, p.Y + clockCentreY} //translate
+ return p
+}
+
+func secondsInRadians(t time.Time) float64 {
+ return math.Pi / (30 / (float64(t.Second())))
+}
+
+func secondHandPoint(t time.Time) Point {
+ angle := secondsInRadians(t)
+ x := math.Sin(angle)
+ y := math.Cos(angle)
+ return Point{x, y}
+}
diff --git a/clockface/main.go b/clockface/main.go
index 8a191a2..3c505eb 100644
--- a/clockface/main.go
+++ b/clockface/main.go
@@ -1,42 +1,35 @@
-package clockface
+package main
import (
+ "fmt"
+ "git.nerdfortress.dev/mitch/clockface"
+ "io"
"math"
+ "os"
"time"
)
-package clockface
-
-import (
-"git.nerdfortress.dev/mitch/gotdd/clockface"
-"math"
-"time"
-)
-
-const secondHandLength = 90
-const clockCentreX = 150
-const clockCentreY = 150
-
-type Point struct {
- X float64
- Y float64
+func main() {
+ t := time.Now()
+ sh := clockface.SecondHand(t)
+ io.WriteString(os.Stdout, svgStart)
+ io.WriteString(os.Stdout, bezel)
+ io.WriteString(os.Stdout, secondHandTag(sh))
+ io.WriteString(os.Stdout, svgEnd)
}
-func SecondHand(t time.Time) Point {
- p := secondHandPoint(t)
- p = Point{p.X * secondHandLength, p.Y * secondHandLength} //scale
- p = Point{p.X, -p.Y} //flip
- p = Point{p.X + clockCentreX, p.Y + clockCentreY} //translate
- return p
+func secondHandTag(p clockface.Point) string {
+ return fmt.Sprintf(``, p.X, p.Y)
}
-func secondsInRadians(t time.Time) float64 {
- return math.Pi / (30 / (float64(t.Second())))
-}
+const svgStart = `
+
+`
diff --git a/clockface_acceptance_test.go b/clockface_acceptance_test.go
index b559a89..086fde7 100644
--- a/clockface_acceptance_test.go
+++ b/clockface_acceptance_test.go
@@ -10,6 +10,7 @@ package clockface
import (
"testing"
"time"
+"git.nerdfortress.dev/mitch/clockface"
)
func TestSecondHandAtMidnight(t *testing.T) {
diff --git a/clockface_test.go b/clockface_test.go
index 150405f..580e84f 100644
--- a/clockface_test.go
+++ b/clockface_test.go
@@ -12,6 +12,7 @@ import (
"math"
"testing"
"time"
+"git.nerdfortress.dev/mitch/clockface"
)
func simpleTime(hours, minutes, seconds int) time.Time {