@@ -1009,6 +1009,32 @@ pub fn (ctx &Context) draw_ellipse_empty(x f32, y f32, rw f32, rh f32, c Color)
10091009 sgl.end ()
10101010}
10111011
1012+ // draw_ellipse_empty draws the outline of an ellipse.
1013+ // `x`,`y` defines the center of the ellipse.
1014+ // `rw` defines the *width* radius of the ellipse.
1015+ // `rh` defines the *height* radius of the ellipse.
1016+ // `th` defines the *thickness* of the ellipse.
1017+ // `c` is the color of the outline.
1018+ pub fn (ctx &Context) draw_ellipse_thick (x f32 , y f32 , rw f32 , rh f32 , th f32 , c Color) {
1019+ if c.a != 255 {
1020+ sgl.load_pipeline (ctx.pipeline.alpha)
1021+ }
1022+ sgl.c4b (c.r, c.g, c.b, c.a)
1023+
1024+ sgl.begin_quads ()
1025+ 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 ))
1034+ }
1035+ sgl.end ()
1036+ }
1037+
10121038// draw_ellipse_filled draws an opaque ellipse.
10131039// `x`,`y` defines the center of the ellipse.
10141040// `rw` defines the *width* radius of the ellipse.
@@ -1057,6 +1083,42 @@ pub fn (ctx &Context) draw_ellipse_empty_rotate(x f32, y f32, rw f32, rh f32, ro
10571083 sgl.end ()
10581084}
10591085
1086+ // draw_ellipse_empty draws the outline of an ellipse.
1087+ // `x`,`y` defines the center of the ellipse.
1088+ // `rw` defines the *width* radius of the ellipse.
1089+ // `rh` defines the *height* radius of the ellipse.
1090+ // `th` defines the *thickness* of the ellipse.
1091+ // `rota` defines the *rotation* angle of the ellipse, in radians.
1092+ // `c` is the color of the outline.
1093+ pub fn (ctx &Context) draw_ellipse_thick_rotate (x f32 , y f32 , rw f32 , rh f32 , th f32 , rota f32 , c Color) {
1094+ if c.a != 255 {
1095+ sgl.load_pipeline (ctx.pipeline.alpha)
1096+ }
1097+ sgl.c4b (c.r, c.g, c.b, c.a)
1098+
1099+ cos_rot := math.cosf (rota)
1100+ sin_rot := math.sinf (rota)
1101+ sgl.begin_quads ()
1102+ 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)
1118+ }
1119+ sgl.end ()
1120+ }
1121+
10601122// draw_ellipse_filled draws an opaque ellipse.
10611123// `x`,`y` defines the center of the ellipse.
10621124// `rw` defines the *width* radius of the ellipse.
0 commit comments