11use bevy:: prelude:: Entity ;
22use processing_render:: {
3- begin_draw , end_draw , exit, flush , image_create , image_destroy , image_load , image_load_pixels ,
4- image_resize , init , record_command , render :: command :: DrawCommand , surface_create_from_canvas ,
5- surface_destroy, surface_resize,
3+ exit, graphics_begin_draw , graphics_end_draw , graphics_flush , graphics_record_command ,
4+ image_create , image_destroy , image_load , image_readback , image_resize , init ,
5+ render :: command :: DrawCommand , surface_create_from_canvas , surface_destroy, surface_resize,
66} ;
77use wasm_bindgen:: prelude:: * ;
88
@@ -38,33 +38,33 @@ pub fn js_surface_resize(surface_id: u64, width: u32, height: u32) -> Result<(),
3838#[ wasm_bindgen( js_name = "background" ) ]
3939pub fn js_background_color ( surface_id : u64 , r : f32 , g : f32 , b : f32 , a : f32 ) -> Result < ( ) , JsValue > {
4040 let color = bevy:: color:: Color :: srgba ( r, g, b, a) ;
41- check ( record_command (
41+ check ( graphics_record_command (
4242 Entity :: from_bits ( surface_id) ,
4343 DrawCommand :: BackgroundColor ( color) ,
4444 ) )
4545}
4646
4747#[ wasm_bindgen( js_name = "backgroundImage" ) ]
4848pub fn js_background_image ( surface_id : u64 , image_id : u64 ) -> Result < ( ) , JsValue > {
49- check ( record_command (
49+ check ( graphics_record_command (
5050 Entity :: from_bits ( surface_id) ,
5151 DrawCommand :: BackgroundImage ( Entity :: from_bits ( image_id) ) ,
5252 ) )
5353}
5454
5555#[ wasm_bindgen( js_name = "beginDraw" ) ]
5656pub fn js_begin_draw ( surface_id : u64 ) -> Result < ( ) , JsValue > {
57- check ( begin_draw ( Entity :: from_bits ( surface_id) ) )
57+ check ( graphics_begin_draw ( Entity :: from_bits ( surface_id) ) )
5858}
5959
6060#[ wasm_bindgen( js_name = "flush" ) ]
6161pub fn js_flush ( surface_id : u64 ) -> Result < ( ) , JsValue > {
62- check ( flush ( Entity :: from_bits ( surface_id) ) )
62+ check ( graphics_flush ( Entity :: from_bits ( surface_id) ) )
6363}
6464
6565#[ wasm_bindgen( js_name = "endDraw" ) ]
6666pub fn js_end_draw ( surface_id : u64 ) -> Result < ( ) , JsValue > {
67- check ( end_draw ( Entity :: from_bits ( surface_id) ) )
67+ check ( graphics_end_draw ( Entity :: from_bits ( surface_id) ) )
6868}
6969
7070#[ wasm_bindgen( js_name = "exit" ) ]
@@ -75,7 +75,7 @@ pub fn js_exit(exit_code: u8) -> Result<(), JsValue> {
7575#[ wasm_bindgen( js_name = "fill" ) ]
7676pub fn js_fill ( surface_id : u64 , r : f32 , g : f32 , b : f32 , a : f32 ) -> Result < ( ) , JsValue > {
7777 let color = bevy:: color:: Color :: srgba ( r, g, b, a) ;
78- check ( record_command (
78+ check ( graphics_record_command (
7979 Entity :: from_bits ( surface_id) ,
8080 DrawCommand :: Fill ( color) ,
8181 ) )
@@ -84,31 +84,31 @@ pub fn js_fill(surface_id: u64, r: f32, g: f32, b: f32, a: f32) -> Result<(), Js
8484#[ wasm_bindgen( js_name = "stroke" ) ]
8585pub fn js_stroke ( surface_id : u64 , r : f32 , g : f32 , b : f32 , a : f32 ) -> Result < ( ) , JsValue > {
8686 let color = bevy:: color:: Color :: srgba ( r, g, b, a) ;
87- check ( record_command (
87+ check ( graphics_record_command (
8888 Entity :: from_bits ( surface_id) ,
8989 DrawCommand :: StrokeColor ( color) ,
9090 ) )
9191}
9292
9393#[ wasm_bindgen( js_name = "strokeWeight" ) ]
9494pub fn js_stroke_weight ( surface_id : u64 , weight : f32 ) -> Result < ( ) , JsValue > {
95- check ( record_command (
95+ check ( graphics_record_command (
9696 Entity :: from_bits ( surface_id) ,
9797 DrawCommand :: StrokeWeight ( weight) ,
9898 ) )
9999}
100100
101101#[ wasm_bindgen( js_name = "noFill" ) ]
102102pub fn js_no_fill ( surface_id : u64 ) -> Result < ( ) , JsValue > {
103- check ( record_command (
103+ check ( graphics_record_command (
104104 Entity :: from_bits ( surface_id) ,
105105 DrawCommand :: NoFill ,
106106 ) )
107107}
108108
109109#[ wasm_bindgen( js_name = "noStroke" ) ]
110110pub fn js_no_stroke ( surface_id : u64 ) -> Result < ( ) , JsValue > {
111- check ( record_command (
111+ check ( graphics_record_command (
112112 Entity :: from_bits ( surface_id) ,
113113 DrawCommand :: NoStroke ,
114114 ) )
@@ -126,7 +126,7 @@ pub fn js_rect(
126126 br : f32 ,
127127 bl : f32 ,
128128) -> Result < ( ) , JsValue > {
129- check ( record_command (
129+ check ( graphics_record_command (
130130 Entity :: from_bits ( surface_id) ,
131131 DrawCommand :: Rect {
132132 x,
@@ -168,8 +168,8 @@ pub fn js_image_resize(image_id: u64, new_width: u32, new_height: u32) -> Result
168168}
169169
170170#[ wasm_bindgen( js_name = "loadPixels" ) ]
171- pub fn js_image_load_pixels ( image_id : u64 ) -> Result < Vec < f32 > , JsValue > {
172- let colors = check ( image_load_pixels ( Entity :: from_bits ( image_id) ) ) ?;
171+ pub fn js_image_readback ( image_id : u64 ) -> Result < Vec < f32 > , JsValue > {
172+ let colors = check ( image_readback ( Entity :: from_bits ( image_id) ) ) ?;
173173
174174 let mut result = Vec :: with_capacity ( colors. len ( ) * 4 ) ;
175175 for color in colors {
0 commit comments