@@ -25,15 +25,15 @@ func FromRect(r Rect) Polygon {
2525// segments to break the ellipse contour into. Passing a value less than 4 for 'sections' will result in an automatic
2626// choice based on a call to EllipseSegmentCount, using half of the longest dimension for the 'r' parameter and 0.2 for
2727// the 'e' parameter.
28- func FromEllipse (r Rect , sections Num ) Polygon {
29- if sections < Four {
28+ func FromEllipse (r Rect , sections int ) Polygon {
29+ if sections < 4 {
3030 sections = EllipseSegmentCount (max (r .Width , r .Height ).Div (Two ), PointTwo )
3131 }
3232 halfWidth := r .Width .Div (Two )
3333 halfHeight := r .Height .Div (Two )
34- inc := Pi .Mul (Two ).Div (sections )
34+ inc := Pi .Mul (Two ).Div (NumFromInteger ( sections ) )
3535 center := r .Center ()
36- contour := make (Contour , NumAsInteger [ int ]( sections ) )
36+ contour := make (Contour , sections )
3737 var angle Num
3838 for i := range sections {
3939 contour [i ] = NewPoint (center .X + Cos (angle ).Mul (halfWidth ), center .Y + Sin (angle ).Mul (halfHeight ))
@@ -44,7 +44,7 @@ func FromEllipse(r Rect, sections Num) Polygon {
4444
4545// EllipseSegmentCount returns a suggested number of segments to use when generating an ellipse. 'r' is the largest
4646// radius of the ellipse. 'e' is the acceptable error, typically 1 or less.
47- func EllipseSegmentCount (r , e Num ) Num {
47+ func EllipseSegmentCount (r , e Num ) int {
4848 d := One - e .Div (r )
49- return max (((Two .Mul (Pi ).Div (Acos (Two .Mul (d ).Mul (d ) - One ))).Ceil ()), Four )
49+ return max (NumAsInteger [ int ] ((Two .Mul (Pi ).Div (Acos (Two .Mul (d ).Mul (d ) - One ))).Ceil ()), 4 )
5050}
0 commit comments