@@ -1093,9 +1093,26 @@ mod mewnala {
10931093 }
10941094
10951095 #[ pyfunction( name = "box" ) ]
1096- #[ pyo3( pass_module) ]
1097- fn draw_box ( module : & Bound < ' _ , PyModule > , x : f32 , y : f32 , z : f32 ) -> PyResult < ( ) > {
1098- graphics ! ( module) . draw_box ( x, y, z)
1096+ #[ pyo3( pass_module, signature = ( * args) ) ]
1097+ fn draw_box ( module : & Bound < ' _ , PyModule > , args : & Bound < ' _ , PyTuple > ) -> PyResult < ( ) > {
1098+ let ( w, h, d) = match args. len ( ) {
1099+ 1 => {
1100+ let s: f32 = args. get_item ( 0 ) ?. extract ( ) ?;
1101+ ( s, s, s)
1102+ }
1103+ 3 => {
1104+ let w = args. get_item ( 0 ) ?. extract ( ) ?;
1105+ let h = args. get_item ( 1 ) ?. extract ( ) ?;
1106+ let d = args. get_item ( 2 ) ?. extract ( ) ?;
1107+ ( w, h, d)
1108+ }
1109+ n => {
1110+ return Err ( pyo3:: exceptions:: PyTypeError :: new_err ( format ! (
1111+ "box() takes 1 or 3 arguments ({n} given)"
1112+ ) ) ) ;
1113+ }
1114+ } ;
1115+ graphics ! ( module) . draw_box ( w, h, d)
10991116 }
11001117
11011118 #[ pyfunction]
@@ -1195,18 +1212,41 @@ mod mewnala {
11951212 }
11961213
11971214 #[ pyfunction]
1198- #[ pyo3( pass_module, signature = ( x, y, w, h, tl=0.0 , tr=0.0 , br=0.0 , bl=0.0 ) ) ]
1199- fn rect (
1200- module : & Bound < ' _ , PyModule > ,
1201- x : f32 ,
1202- y : f32 ,
1203- w : f32 ,
1204- h : f32 ,
1205- tl : f32 ,
1206- tr : f32 ,
1207- br : f32 ,
1208- bl : f32 ,
1209- ) -> PyResult < ( ) > {
1215+ #[ pyo3( pass_module, signature = ( * args) ) ]
1216+ fn rect ( module : & Bound < ' _ , PyModule > , args : & Bound < ' _ , PyTuple > ) -> PyResult < ( ) > {
1217+ let ( x, y, w, h, tl, tr, br, bl) = match args. len ( ) {
1218+ 4 => {
1219+ let x = args. get_item ( 0 ) ?. extract ( ) ?;
1220+ let y = args. get_item ( 1 ) ?. extract ( ) ?;
1221+ let w = args. get_item ( 2 ) ?. extract ( ) ?;
1222+ let h = args. get_item ( 3 ) ?. extract ( ) ?;
1223+ ( x, y, w, h, 0.0 , 0.0 , 0.0 , 0.0 )
1224+ }
1225+ 5 => {
1226+ let x = args. get_item ( 0 ) ?. extract ( ) ?;
1227+ let y = args. get_item ( 1 ) ?. extract ( ) ?;
1228+ let w = args. get_item ( 2 ) ?. extract ( ) ?;
1229+ let h = args. get_item ( 3 ) ?. extract ( ) ?;
1230+ let r = args. get_item ( 4 ) ?. extract ( ) ?;
1231+ ( x, y, w, h, r, r, r, r)
1232+ }
1233+ 8 => {
1234+ let x = args. get_item ( 0 ) ?. extract ( ) ?;
1235+ let y = args. get_item ( 1 ) ?. extract ( ) ?;
1236+ let w = args. get_item ( 2 ) ?. extract ( ) ?;
1237+ let h = args. get_item ( 3 ) ?. extract ( ) ?;
1238+ let tl = args. get_item ( 4 ) ?. extract ( ) ?;
1239+ let tr = args. get_item ( 5 ) ?. extract ( ) ?;
1240+ let br = args. get_item ( 6 ) ?. extract ( ) ?;
1241+ let bl = args. get_item ( 7 ) ?. extract ( ) ?;
1242+ ( x, y, w, h, tl, tr, br, bl)
1243+ }
1244+ n => {
1245+ return Err ( pyo3:: exceptions:: PyTypeError :: new_err ( format ! (
1246+ "rect() takes 4, 5, or 8 arguments ({n} given)"
1247+ ) ) ) ;
1248+ }
1249+ } ;
12101250 graphics ! ( module) . rect ( x, y, w, h, tl, tr, br, bl)
12111251 }
12121252
0 commit comments