@@ -16,19 +16,15 @@ pub struct Webcam {
1616impl Webcam {
1717 #[ new]
1818 #[ pyo3( signature = ( width=None , height=None , framerate=None ) ) ]
19- pub fn new (
20- width : Option < u32 > ,
21- height : Option < u32 > ,
22- framerate : Option < u32 > ,
23- ) -> PyResult < Self > {
19+ pub fn new ( width : Option < u32 > , height : Option < u32 > , framerate : Option < u32 > ) -> PyResult < Self > {
2420 let entity = match ( width, height, framerate) {
2521 ( Some ( w) , Some ( h) , Some ( fps) ) => webcam_create_with_format ( WebcamFormat :: Exact {
2622 resolution : bevy:: math:: UVec2 :: new ( w, h) ,
2723 framerate : fps,
2824 } ) ,
29- ( Some ( w) , Some ( h) , None ) => webcam_create_with_format ( WebcamFormat :: Resolution (
30- bevy:: math:: UVec2 :: new ( w, h) ,
31- ) ) ,
25+ ( Some ( w) , Some ( h) , None ) => {
26+ webcam_create_with_format ( WebcamFormat :: Resolution ( bevy:: math:: UVec2 :: new ( w, h) ) )
27+ }
3228 ( None , None , Some ( fps) ) => webcam_create_with_format ( WebcamFormat :: FrameRate ( fps) ) ,
3329 _ => webcam_create ( ) ,
3430 }
@@ -38,18 +34,16 @@ impl Webcam {
3834 }
3935
4036 pub fn is_connected ( & self ) -> PyResult < bool > {
41- webcam_is_connected ( self . entity )
42- . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) )
37+ webcam_is_connected ( self . entity ) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) )
4338 }
4439
4540 pub fn resolution ( & self ) -> PyResult < ( u32 , u32 ) > {
46- webcam_resolution ( self . entity )
47- . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) )
41+ webcam_resolution ( self . entity ) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) )
4842 }
4943
5044 pub fn image ( & self ) -> PyResult < Image > {
51- let entity = webcam_image ( self . entity )
52- . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
45+ let entity =
46+ webcam_image ( self . entity ) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
5347 Ok ( Image :: from_entity ( entity) )
5448 }
5549}
0 commit comments