@@ -1003,9 +1003,8 @@ pub fn (ctx &Context) draw_ellipse_empty(x f32, y f32, rw f32, rh f32, c Color)
10031003 sgl.begin_line_strip ()
10041004 for i := 0 ; i < 360 ; i + = 10 {
10051005 sgl.v2f (x + math.sinf (f32 (math.radians (i))) * rw, y + math.cosf (f32 (math.radians (i))) * rh)
1006- sgl.v2f (x + math.sinf (f32 (math.radians (i + 10 ))) * rw, y + math.cosf (f32 (math.radians (i +
1007- 10 ))) * rh)
10081006 }
1007+ sgl.v2f (x, y + rh)
10091008 sgl.end ()
10101009}
10111010
@@ -1021,17 +1020,16 @@ pub fn (ctx &Context) draw_ellipse_thick(x f32, y f32, rw f32, rh f32, th f32, c
10211020 }
10221021 sgl.c4b (c.r, c.g, c.b, c.a)
10231022
1024- sgl.begin_quads ()
1023+ sgl.begin_triangle_strip ()
10251024 for i := 0 ; i < 360 ; i + = 10 {
1026- sgl.v2f (x + math.sinf (f32 (math.radians (i + 10 ))) * (rw - th / 2 ), y +
1027- math.cosf (f32 (math.radians (i + 10 ))) * (rh - th / 2 ))
1028- sgl.v2f (x + math.sinf (f32 (math.radians (i))) * (rw - th / 2 ), y +
1029- math.cosf (f32 (math.radians (i))) * (rh - th / 2 ))
1030- sgl.v2f (x + math.sinf (f32 (math.radians (i))) * (rw + th / 2 ), y +
1031- math.cosf (f32 (math.radians (i))) * (rh + th / 2 ))
1032- sgl.v2f (x + math.sinf (f32 (math.radians (i + 10 ))) * (rw + th / 2 ), y +
1033- math.cosf (f32 (math.radians (i + 10 ))) * (rh + th / 2 ))
1025+ xfactor := math.sinf (f32 (math.radians (i)))
1026+ yfactor := math.cosf (f32 (math.radians (i)))
1027+
1028+ sgl.v2f (x + xfactor * (rw - th / 2 ), y + yfactor * (rh - th / 2 ))
1029+ sgl.v2f (x + xfactor * (rw + th / 2 ), y + yfactor * (rh + th / 2 ))
10341030 }
1031+ sgl.v2f (x, y + (rh - th / 2 ))
1032+ sgl.v2f (x, y + (rh + th / 2 ))
10351033 sgl.end ()
10361034}
10371035
@@ -1050,9 +1048,8 @@ pub fn (ctx &Context) draw_ellipse_filled(x f32, y f32, rw f32, rh f32, c Color)
10501048 for i := 0 ; i < 360 ; i + = 10 {
10511049 sgl.v2f (x, y)
10521050 sgl.v2f (x + math.sinf (f32 (math.radians (i))) * rw, y + math.cosf (f32 (math.radians (i))) * rh)
1053- sgl.v2f (x + math.sinf (f32 (math.radians (i + 10 ))) * rw, y + math.cosf (f32 (math.radians (i +
1054- 10 ))) * rh)
10551051 }
1052+ sgl.v2f (x, y + rh)
10561053 sgl.end ()
10571054}
10581055
@@ -1073,13 +1070,12 @@ pub fn (ctx &Context) draw_ellipse_empty_rotate(x f32, y f32, rw f32, rh f32, ro
10731070 sgl.begin_line_strip ()
10741071 for i := 0 ; i < 360 ; i + = 10 {
10751072 x_current := math.sinf (f32 (math.radians (i))) * rw
1076- x_next := math.sinf (f32 (math.radians (i + 10 ))) * rw
10771073 y_current := math.cosf (f32 (math.radians (i))) * rh
1078- y_next := math. cosf ( f32 (math. radians (i + 10 ))) * rh
1074+
10791075 sgl.v2f (x + x_current * cos_rot - y_current * sin_rot, y + x_current * sin_rot +
10801076 y_current * cos_rot)
1081- sgl.v2f (x + x_next * cos_rot - y_next * sin_rot, y + x_next * sin_rot + y_next * cos_rot)
10821077 }
1078+ sgl.v2f (x - rh * sin_rot, y + rh * cos_rot)
10831079 sgl.end ()
10841080}
10851081
@@ -1098,24 +1094,18 @@ pub fn (ctx &Context) draw_ellipse_thick_rotate(x f32, y f32, rw f32, rh f32, th
10981094
10991095 cos_rot := math.cosf (rota)
11001096 sin_rot := math.sinf (rota)
1101- sgl.begin_quads ()
1097+ sgl.begin_triangle_strip ()
11021098 for i := 0 ; i < 360 ; i + = 10 {
1103- xfactor_current := math.sinf (f32 (math.radians (i)))
1104- xfactor_next := math.sinf (f32 (math.radians (i + 10 )))
1105- yfactor_current := math.cosf (f32 (math.radians (i)))
1106- yfactor_next := math.cosf (f32 (math.radians (i + 10 )))
1107-
1108- sgl.v2f (x + xfactor_next * (rw - th / 2 ) * cos_rot - yfactor_next * (rh - th / 2 ) * sin_rot,
1109- y + yfactor_next * (rh - th / 2 ) * cos_rot + xfactor_next * (rw - th / 2 ) * sin_rot)
1110- sgl.v2f (x + xfactor_current * (rw - th / 2 ) * cos_rot - yfactor_current * (rh - th / 2 ) * sin_rot,
1111- y + yfactor_current * (rh - th / 2 ) * cos_rot +
1112- xfactor_current * (rw - th / 2 ) * sin_rot)
1113- sgl.v2f (x + xfactor_current * (rw + th / 2 ) * cos_rot - yfactor_current * (rh + th / 2 ) * sin_rot,
1114- y + yfactor_current * (rh + th / 2 ) * cos_rot + xfactor_current * (rw +
1115- th / 2 ) * sin_rot)
1116- sgl.v2f (x + xfactor_next * (rw + th / 2 ) * cos_rot - yfactor_next * (rh + th / 2 ) * sin_rot,
1117- y + yfactor_next * (rh + th / 2 ) * cos_rot + xfactor_next * (rw + th / 2 ) * sin_rot)
1099+ xfactor := math.sinf (f32 (math.radians (i)))
1100+ yfactor := math.cosf (f32 (math.radians (i)))
1101+
1102+ sgl.v2f (x + xfactor * (rw - th / 2 ) * cos_rot - yfactor * (rh - th / 2 ) * sin_rot,
1103+ y + yfactor * (rh - th / 2 ) * cos_rot + xfactor * (rw - th / 2 ) * sin_rot)
1104+ sgl.v2f (x + xfactor * (rw + th / 2 ) * cos_rot - yfactor * (rh + th / 2 ) * sin_rot,
1105+ y + yfactor * (rh + th / 2 ) * cos_rot + xfactor * (rw + th / 2 ) * sin_rot)
11181106 }
1107+ sgl.v2f (x - (rh - th / 2 ) * sin_rot, y + (rh - th / 2 ) * cos_rot)
1108+ sgl.v2f (x - (rh + th / 2 ) * sin_rot, y + (rh + th / 2 ) * cos_rot)
11191109 sgl.end ()
11201110}
11211111
@@ -1137,13 +1127,11 @@ pub fn (ctx &Context) draw_ellipse_filled_rotate(x f32, y f32, rw f32, rh f32, r
11371127 for i := 0 ; i < 360 ; i + = 10 {
11381128 sgl.v2f (x, y)
11391129 x_current := math.sinf (f32 (math.radians (i))) * rw
1140- x_next := math.sinf (f32 (math.radians (i + 10 ))) * rw
11411130 y_current := math.cosf (f32 (math.radians (i))) * rh
1142- y_next := math.cosf (f32 (math.radians (i + 10 ))) * rh
11431131 sgl.v2f (x + x_current * cos_rot - y_current * sin_rot, y + x_current * sin_rot +
11441132 y_current * cos_rot)
1145- sgl.v2f (x + x_next * cos_rot - y_next * sin_rot, y + x_next * sin_rot + y_next * cos_rot)
11461133 }
1134+ sgl.v2f (x - rh * sin_rot, y + rh * cos_rot)
11471135 sgl.end ()
11481136}
11491137
0 commit comments