fix: allow arrow to draw full circle
This commit is contained in:
parent
077537a1e3
commit
f4c331983c
|
@ -94,6 +94,11 @@ func (r *roomTableData)ArrowData() arrowData {
|
|||
radius := 50.0
|
||||
startAngle := 90 + float64(startSector) * ( 360.0 / float64(total) )
|
||||
endAngle := 90 + float64(endSector) * ( 360.0 / float64(total) )
|
||||
// if need to draw full circle
|
||||
if startSector == endSector {
|
||||
startAngle += 3 // a bit forward
|
||||
endAngle += 357 // ~ a bit backward (almost full circle forward)
|
||||
}
|
||||
startAngleRad := startAngle * (math.Pi / float64(180))
|
||||
endAngleRad := endAngle * (math.Pi / float64(180))
|
||||
// endAngle is radius angle, so perpendicular gives direction of teh arrow
|
||||
|
@ -106,16 +111,17 @@ func (r *roomTableData)ArrowData() arrowData {
|
|||
arrowAngleOffset := math.Pi / 4 // 45 degrees
|
||||
arrowPointDirection := endAngleRad - math.Pi / 2
|
||||
arrowheadLen := 10.0
|
||||
line1Angle := arrowPointDirection - arrowAngleOffset
|
||||
line2Angle := arrowPointDirection + arrowAngleOffset
|
||||
line1EndX := x2 + arrowheadLen * math.Cos(line1Angle)
|
||||
line1EndY := y2 + arrowheadLen * math.Sin(line1Angle)
|
||||
line2EndX := x2 + arrowheadLen * math.Cos(line2Angle)
|
||||
line2EndY := y2 + arrowheadLen * math.Sin(line2Angle)
|
||||
arrowMinusAngle := arrowPointDirection - arrowAngleOffset
|
||||
arrowPlusAngle := arrowPointDirection + arrowAngleOffset
|
||||
arrowMinusEndX := x2 + arrowheadLen * math.Cos(arrowMinusAngle)
|
||||
arrowMinusEndY := y2 + arrowheadLen * math.Sin(arrowMinusAngle)
|
||||
arrowPlusEndX := x2 + arrowheadLen * math.Cos(arrowPlusAngle)
|
||||
arrowPlusEndY := y2 + arrowheadLen * math.Sin(arrowPlusAngle)
|
||||
|
||||
// indicates that the shorter of the two possible arcs should be used.
|
||||
largeArcFlag := 0
|
||||
if math.Abs(float64(endSector) - float64(startSector)) > float64(total)/2.0 {
|
||||
//
|
||||
if endAngleRad - startAngleRad > (math.Pi) {
|
||||
// specifies that the longer arc should be chosen.
|
||||
largeArcFlag = 1
|
||||
}
|
||||
|
@ -129,10 +135,10 @@ func (r *roomTableData)ArrowData() arrowData {
|
|||
EndX: int(x2),
|
||||
EndY: int(y2),
|
||||
LargeArcFlag: largeArcFlag,
|
||||
Angle1X: int(line1EndX),
|
||||
Angle1Y: int(line1EndY),
|
||||
Angle2X: int(line2EndX),
|
||||
Angle2Y: int(line2EndY),
|
||||
Angle1X: int(arrowMinusEndX),
|
||||
Angle1Y: int(arrowMinusEndY),
|
||||
Angle2X: int(arrowPlusEndX),
|
||||
Angle2Y: int(arrowPlusEndY),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue