@@ -86,6 +86,11 @@ impl Topology {
8686 }
8787}
8888
89+ #[ pyclass]
90+ pub struct Sketch {
91+ pub source : String ,
92+ }
93+
8994#[ pymethods]
9095impl Geometry {
9196 #[ new]
@@ -140,12 +145,20 @@ impl Drop for Graphics {
140145#[ pymethods]
141146impl Graphics {
142147 #[ new]
143- pub fn new ( width : u32 , height : u32 , asset_path : & str ) -> PyResult < Self > {
148+ pub fn new (
149+ width : u32 ,
150+ height : u32 ,
151+ asset_path : & str ,
152+ sketch_root_path : & str ,
153+ sketch_file_name : & str ,
154+ ) -> PyResult < Self > {
144155 let glfw_ctx =
145156 GlfwContext :: new ( width, height) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
146157
147158 let mut config = Config :: new ( ) ;
148159 config. set ( ConfigKey :: AssetRootPath , asset_path. to_string ( ) ) ;
160+ config. set ( ConfigKey :: SketchRootPath , sketch_root_path. to_string ( ) ) ;
161+ config. set ( ConfigKey :: SketchFileName , sketch_file_name. to_string ( ) ) ;
149162 init ( config) . map_err ( |e| PyRuntimeError :: new_err ( format ! ( "{e}" ) ) ) ?;
150163
151164 let surface = glfw_ctx
@@ -166,6 +179,17 @@ impl Graphics {
166179 } )
167180 }
168181
182+ pub fn poll_for_sketch_update ( & self ) -> PyResult < Sketch > {
183+ match poll_for_sketch_updates ( ) . map_err ( |_| PyRuntimeError :: new_err ( "SKETCH UPDATE ERR" ) ) ? {
184+ Some ( sketch) => Ok ( Sketch {
185+ source : sketch. source ,
186+ } ) ,
187+ None => Ok ( Sketch {
188+ source : "" . to_string ( ) ,
189+ } ) ,
190+ }
191+ }
192+
169193 pub fn background ( & self , args : Vec < f32 > ) -> PyResult < ( ) > {
170194 let ( r, g, b, a) = parse_color ( & args) ?;
171195 let color = bevy:: color:: Color :: srgba ( r, g, b, a) ;
0 commit comments