@@ -1237,9 +1237,26 @@ mod mewnala {
12371237 }
12381238
12391239 #[ pyfunction( name = "box" ) ]
1240- #[ pyo3( pass_module) ]
1241- fn draw_box ( module : & Bound < ' _ , PyModule > , x : f32 , y : f32 , z : f32 ) -> PyResult < ( ) > {
1242- graphics ! ( module) . draw_box ( x, y, z)
1240+ #[ pyo3( pass_module, signature = ( * args) ) ]
1241+ fn draw_box ( module : & Bound < ' _ , PyModule > , args : & Bound < ' _ , PyTuple > ) -> PyResult < ( ) > {
1242+ let ( w, h, d) = match args. len ( ) {
1243+ 1 => {
1244+ let s: f32 = args. get_item ( 0 ) ?. extract ( ) ?;
1245+ ( s, s, s)
1246+ }
1247+ 3 => {
1248+ let w = args. get_item ( 0 ) ?. extract ( ) ?;
1249+ let h = args. get_item ( 1 ) ?. extract ( ) ?;
1250+ let d = args. get_item ( 2 ) ?. extract ( ) ?;
1251+ ( w, h, d)
1252+ }
1253+ n => {
1254+ return Err ( pyo3:: exceptions:: PyTypeError :: new_err ( format ! (
1255+ "box() takes 1 or 3 arguments ({n} given)"
1256+ ) ) ) ;
1257+ }
1258+ } ;
1259+ graphics ! ( module) . draw_box ( w, h, d)
12431260 }
12441261
12451262 #[ pyfunction]
@@ -1339,18 +1356,41 @@ mod mewnala {
13391356 }
13401357
13411358 #[ pyfunction]
1342- #[ pyo3( pass_module, signature = ( x, y, w, h, tl=0.0 , tr=0.0 , br=0.0 , bl=0.0 ) ) ]
1343- fn rect (
1344- module : & Bound < ' _ , PyModule > ,
1345- x : f32 ,
1346- y : f32 ,
1347- w : f32 ,
1348- h : f32 ,
1349- tl : f32 ,
1350- tr : f32 ,
1351- br : f32 ,
1352- bl : f32 ,
1353- ) -> PyResult < ( ) > {
1359+ #[ pyo3( pass_module, signature = ( * args) ) ]
1360+ fn rect ( module : & Bound < ' _ , PyModule > , args : & Bound < ' _ , PyTuple > ) -> PyResult < ( ) > {
1361+ let ( x, y, w, h, tl, tr, br, bl) = match args. len ( ) {
1362+ 4 => {
1363+ let x = args. get_item ( 0 ) ?. extract ( ) ?;
1364+ let y = args. get_item ( 1 ) ?. extract ( ) ?;
1365+ let w = args. get_item ( 2 ) ?. extract ( ) ?;
1366+ let h = args. get_item ( 3 ) ?. extract ( ) ?;
1367+ ( x, y, w, h, 0.0 , 0.0 , 0.0 , 0.0 )
1368+ }
1369+ 5 => {
1370+ let x = args. get_item ( 0 ) ?. extract ( ) ?;
1371+ let y = args. get_item ( 1 ) ?. extract ( ) ?;
1372+ let w = args. get_item ( 2 ) ?. extract ( ) ?;
1373+ let h = args. get_item ( 3 ) ?. extract ( ) ?;
1374+ let r = args. get_item ( 4 ) ?. extract ( ) ?;
1375+ ( x, y, w, h, r, r, r, r)
1376+ }
1377+ 8 => {
1378+ let x = args. get_item ( 0 ) ?. extract ( ) ?;
1379+ let y = args. get_item ( 1 ) ?. extract ( ) ?;
1380+ let w = args. get_item ( 2 ) ?. extract ( ) ?;
1381+ let h = args. get_item ( 3 ) ?. extract ( ) ?;
1382+ let tl = args. get_item ( 4 ) ?. extract ( ) ?;
1383+ let tr = args. get_item ( 5 ) ?. extract ( ) ?;
1384+ let br = args. get_item ( 6 ) ?. extract ( ) ?;
1385+ let bl = args. get_item ( 7 ) ?. extract ( ) ?;
1386+ ( x, y, w, h, tl, tr, br, bl)
1387+ }
1388+ n => {
1389+ return Err ( pyo3:: exceptions:: PyTypeError :: new_err ( format ! (
1390+ "rect() takes 4, 5, or 8 arguments ({n} given)"
1391+ ) ) ) ;
1392+ }
1393+ } ;
13541394 graphics ! ( module) . rect ( x, y, w, h, tl, tr, br, bl)
13551395 }
13561396
0 commit comments