-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
I was using a FilledTriangle to draw the hands on a clock, and I noticed that the triangle for the minute hand goes outside the boundaries of the clock near the 3 o'clock and 9 o'clock positions.
Assuming there is nothing wrong with math.Sincos(), I can only assume that something is not quite right with FilledTriangle().
My logic looks something like this:
const (
hourRadius = 55
minuteRadius = 95
hourWidth = 6
minuteWidth = 5
)
// Draw the clock hands.
minuteAngle := float64(t.Minute()) / 60 * 2 * math.Pi
mx, my := math.Sincos(minuteAngle)
hourAngle := float64(t.Hour()*60+t.Minute()) / 60 / 12 * 2 * math.Pi
hx, hy := math.Sincos(hourAngle)
tinydraw.Triangle(
display,
x-int16(hourWidth*hy), y-int16(hourWidth*hx),
x+int16(hourWidth*hy), y+int16(hourWidth*hx),
x+int16(hourRadius*hx), y-int16(hourRadius*hy),
black)
tinydraw.FilledTriangle(
display,
x-int16(minuteWidth*my), y-int16(minuteWidth*mx),
x+int16(minuteWidth*my), y+int16(minuteWidth*mx),
x+int16(minuteRadius*mx), y-int16(minuteRadius*my),
black)
Metadata
Metadata
Assignees
Labels
No labels