package clockface
import (
"fmt"
"io"
"time"
)
const (
hourHandLength = 50
secondHandLength = 90
minuteHandLength = 80
clockCentreX = 150
clockCentreY = 150
)
const svgStart = `
`
//SVGWriter writes an SVG representation of an analog clock, showing the time t, to the writer w
func SVGWriter(w io.Writer, t time.Time) {
io.WriteString(w, svgStart)
io.WriteString(w, bezel)
SecondHand(w, t)
MinuteHand(w, t)
HourHand(w, t)
io.WriteString(w, svgEnd)
}
func makeHand(p Point, length float64) Point {
p = Point{p.X * length, p.Y * length}
p = Point{p.X, -p.Y}
return Point{p.X + clockCentreX, p.Y + clockCentreY}
}
func SecondHand(w io.Writer, t time.Time) {
p := makeHand(secondHandPoint(t), secondHandLength)
fmt.Fprintf(w, ``, p.X, p.Y)
}
func MinuteHand(w io.Writer, t time.Time) {
p := makeHand(minuteHandPoint(t), minuteHandLength)
fmt.Fprintf(w, ``, p.X, p.Y)
}
func HourHand(w io.Writer, t time.Time) {
p := makeHand(hourHandPoint(t), hourHandLength)
fmt.Fprintf(w, ``, p.X, p.Y)
}