@@ -61,6 +61,11 @@ impl Topology {
6161 }
6262}
6363
64+ #[ pyclass]
65+ pub struct Sketch {
66+ pub source : String ,
67+ }
68+
6469#[ pymethods]
6570impl Geometry {
6671 #[ new]
@@ -115,12 +120,20 @@ impl Drop for Graphics {
115120#[ pymethods]
116121impl Graphics {
117122 #[ new]
118- pub fn new ( width : u32 , height : u32 , asset_path : & str ) -> PyResult < Self > {
123+ pub fn new (
124+ width : u32 ,
125+ height : u32 ,
126+ asset_path : & str ,
127+ sketch_root_path : & str ,
128+ sketch_file_name : & str ,
129+ ) -> PyResult < Self > {
119130 let glfw_ctx =
120131 GlfwContext :: new ( width, height) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
121132
122133 let mut config = Config :: new ( ) ;
123134 config. set ( ConfigKey :: AssetRootPath , asset_path. to_string ( ) ) ;
135+ config. set ( ConfigKey :: SketchRootPath , sketch_root_path. to_string ( ) ) ;
136+ config. set ( ConfigKey :: SketchFileName , sketch_file_name. to_string ( ) ) ;
124137 init ( config) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
125138
126139 let surface = glfw_ctx
@@ -141,6 +154,17 @@ impl Graphics {
141154 } )
142155 }
143156
157+ pub fn poll_for_sketch_update ( & self ) -> PyResult < Sketch > {
158+ match poll_for_sketch_updates ( ) . map_err ( |_| PyRuntimeError :: new_err ( "SKETCH UPDATE ERR" ) ) ? {
159+ Some ( sketch) => Ok ( Sketch {
160+ source : sketch. source ,
161+ } ) ,
162+ None => Ok ( Sketch {
163+ source : "" . to_string ( ) ,
164+ } ) ,
165+ }
166+ }
167+
144168 pub fn background ( & self , args : Vec < f32 > ) -> PyResult < ( ) > {
145169 let ( r, g, b, a) = parse_color ( & args) ?;
146170 let color = bevy:: color:: Color :: srgba ( r, g, b, a) ;
0 commit comments