1111mod glfw;
1212mod graphics;
1313
14- use graphics:: { Geometry , Graphics , Image , Topology , get_graphics, get_graphics_mut} ;
14+ use graphics:: { Geometry , Graphics , Image , Light , Topology , get_graphics, get_graphics_mut} ;
1515use pyo3:: {
1616 exceptions:: PyRuntimeError ,
1717 prelude:: * ,
@@ -25,7 +25,7 @@ use std::env;
2525fn processing ( m : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
2626 m. add_class :: < Graphics > ( ) ?;
2727 m. add_class :: < Image > ( ) ?;
28- m. add_class :: < Geometry > ( ) ?;
28+ m. add_class :: < Light > ( ) ?;
2929 m. add_class :: < Topology > ( ) ?;
3030 m. add_function ( wrap_pyfunction ! ( size, m) ?) ?;
3131 m. add_function ( wrap_pyfunction ! ( run, m) ?) ?;
@@ -45,6 +45,9 @@ fn processing(m: &Bound<'_, PyModule>) -> PyResult<()> {
4545 m. add_function ( wrap_pyfunction ! ( rect, m) ?) ?;
4646 m. add_function ( wrap_pyfunction ! ( image, m) ?) ?;
4747 m. add_function ( wrap_pyfunction ! ( draw_geometry, m) ?) ?;
48+ m. add_function ( wrap_pyfunction ! ( create_directional_light, m) ?) ?;
49+ m. add_function ( wrap_pyfunction ! ( create_point_light, m) ?) ?;
50+ m. add_function ( wrap_pyfunction ! ( create_spot_light, m) ?) ?;
4851
4952 Ok ( ( ) )
5053}
@@ -275,3 +278,45 @@ fn rect(
275278fn image ( module : & Bound < ' _ , PyModule > , image_file : & str ) -> PyResult < Image > {
276279 get_graphics ( module) ?. image ( image_file)
277280}
281+
282+ #[ pyfunction]
283+ #[ pyo3( pass_module, signature = ( r, g, b, illuminance) ) ]
284+ fn create_directional_light (
285+ module : & Bound < ' _ , PyModule > ,
286+ r : f32 ,
287+ g : f32 ,
288+ b : f32 ,
289+ illuminance : f32 ,
290+ ) -> PyResult < Light > {
291+ get_graphics ( module) ?. light_directional ( r, g, b, illuminance)
292+ }
293+
294+ #[ pyfunction]
295+ #[ pyo3( pass_module, signature = ( r, g, b, intensity, range, radius) ) ]
296+ fn create_point_light (
297+ module : & Bound < ' _ , PyModule > ,
298+ r : f32 ,
299+ g : f32 ,
300+ b : f32 ,
301+ intensity : f32 ,
302+ range : f32 ,
303+ radius : f32 ,
304+ ) -> PyResult < Light > {
305+ get_graphics ( module) ?. light_point ( r, g, b, intensity, range, radius)
306+ }
307+
308+ #[ pyfunction]
309+ #[ pyo3( pass_module, signature = ( r, g, b, intensity, range, radius, inner_angle, outer_angle) ) ]
310+ fn create_spot_light (
311+ module : & Bound < ' _ , PyModule > ,
312+ r : f32 ,
313+ g : f32 ,
314+ b : f32 ,
315+ intensity : f32 ,
316+ range : f32 ,
317+ radius : f32 ,
318+ inner_angle : f32 ,
319+ outer_angle : f32 ,
320+ ) -> PyResult < Light > {
321+ get_graphics ( module) ?. light_spot ( r, g, b, intensity, range, radius, inner_angle, outer_angle)
322+ }
0 commit comments