@@ -466,24 +466,16 @@ pub extern "C" fn processing_shear_y(graphics_id: u64, angle: f32) {
466466 error:: check ( || graphics_record_command ( graphics_entity, DrawCommand :: ShearY { angle } ) ) ;
467467}
468468
469- /// Set the blend mode.
470- ///
471- /// Mode values: 0=BLEND, 1=ADD, 2=SUBTRACT, 3=DARKEST, 4=LIGHTEST,
472- /// 5=DIFFERENCE, 6=EXCLUSION, 7=MULTIPLY, 8=SCREEN, 9=REPLACE
473469#[ unsafe( no_mangle) ]
474470pub extern "C" fn processing_set_blend_mode ( graphics_id : u64 , mode : u8 ) {
475471 error:: clear_error ( ) ;
476472 let graphics_entity = Entity :: from_bits ( graphics_id) ;
477- let blend_state = processing:: prelude:: BlendMode :: from ( mode) . to_blend_state ( ) ;
478- error:: check ( || graphics_record_command ( graphics_entity, DrawCommand :: BlendMode ( blend_state) ) ) ;
473+ error:: check ( || {
474+ let blend_state = processing:: prelude:: BlendMode :: try_from ( mode) ?. to_blend_state ( ) ;
475+ graphics_record_command ( graphics_entity, DrawCommand :: BlendMode ( blend_state) )
476+ } ) ;
479477}
480478
481- /// Set a custom blend mode by specifying individual blend components.
482- ///
483- /// Each factor/operation is a u8 mapping to the WebGPU BlendFactor/BlendOperation enums.
484- /// BlendFactor: 0=Zero, 1=One, 2=Src, 3=OneMinusSrc, 4=SrcAlpha, 5=OneMinusSrcAlpha,
485- /// 6=Dst, 7=OneMinusDst, 8=DstAlpha, 9=OneMinusDstAlpha, 10=SrcAlphaSaturated
486- /// BlendOperation: 0=Add, 1=Subtract, 2=ReverseSubtract, 3=Min, 4=Max
487479#[ unsafe( no_mangle) ]
488480pub extern "C" fn processing_set_custom_blend_mode (
489481 graphics_id : u64 ,
@@ -496,10 +488,10 @@ pub extern "C" fn processing_set_custom_blend_mode(
496488) {
497489 error:: clear_error ( ) ;
498490 let graphics_entity = Entity :: from_bits ( graphics_id) ;
499- let blend_state = custom_blend_state (
500- color_src, color_dst, color_op, alpha_src, alpha_dst, alpha_op,
501- ) ;
502491 error:: check ( || {
492+ let blend_state = custom_blend_state (
493+ color_src, color_dst, color_op, alpha_src, alpha_dst, alpha_op,
494+ ) ?;
503495 graphics_record_command ( graphics_entity, DrawCommand :: BlendMode ( Some ( blend_state) ) )
504496 } ) ;
505497}
@@ -805,6 +797,35 @@ pub const PROCESSING_STROKE_JOIN_ROUND: u8 = 0;
805797pub const PROCESSING_STROKE_JOIN_MITER : u8 = 1 ;
806798pub const PROCESSING_STROKE_JOIN_BEVEL : u8 = 2 ;
807799
800+ pub const PROCESSING_BLEND_MODE_BLEND : u8 = 0 ;
801+ pub const PROCESSING_BLEND_MODE_ADD : u8 = 1 ;
802+ pub const PROCESSING_BLEND_MODE_SUBTRACT : u8 = 2 ;
803+ pub const PROCESSING_BLEND_MODE_DARKEST : u8 = 3 ;
804+ pub const PROCESSING_BLEND_MODE_LIGHTEST : u8 = 4 ;
805+ pub const PROCESSING_BLEND_MODE_DIFFERENCE : u8 = 5 ;
806+ pub const PROCESSING_BLEND_MODE_EXCLUSION : u8 = 6 ;
807+ pub const PROCESSING_BLEND_MODE_MULTIPLY : u8 = 7 ;
808+ pub const PROCESSING_BLEND_MODE_SCREEN : u8 = 8 ;
809+ pub const PROCESSING_BLEND_MODE_REPLACE : u8 = 9 ;
810+
811+ pub const PROCESSING_BLEND_FACTOR_ZERO : u8 = 0 ;
812+ pub const PROCESSING_BLEND_FACTOR_ONE : u8 = 1 ;
813+ pub const PROCESSING_BLEND_FACTOR_SRC : u8 = 2 ;
814+ pub const PROCESSING_BLEND_FACTOR_ONE_MINUS_SRC : u8 = 3 ;
815+ pub const PROCESSING_BLEND_FACTOR_SRC_ALPHA : u8 = 4 ;
816+ pub const PROCESSING_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA : u8 = 5 ;
817+ pub const PROCESSING_BLEND_FACTOR_DST : u8 = 6 ;
818+ pub const PROCESSING_BLEND_FACTOR_ONE_MINUS_DST : u8 = 7 ;
819+ pub const PROCESSING_BLEND_FACTOR_DST_ALPHA : u8 = 8 ;
820+ pub const PROCESSING_BLEND_FACTOR_ONE_MINUS_DST_ALPHA : u8 = 9 ;
821+ pub const PROCESSING_BLEND_FACTOR_SRC_ALPHA_SATURATED : u8 = 10 ;
822+
823+ pub const PROCESSING_BLEND_OP_ADD : u8 = 0 ;
824+ pub const PROCESSING_BLEND_OP_SUBTRACT : u8 = 1 ;
825+ pub const PROCESSING_BLEND_OP_REVERSE_SUBTRACT : u8 = 2 ;
826+ pub const PROCESSING_BLEND_OP_MIN : u8 = 3 ;
827+ pub const PROCESSING_BLEND_OP_MAX : u8 = 4 ;
828+
808829#[ unsafe( no_mangle) ]
809830pub extern "C" fn processing_geometry_layout_create ( ) -> u64 {
810831 error:: clear_error ( ) ;
@@ -1602,6 +1623,16 @@ pub extern "C" fn processing_key_is_down(key_code: u32) -> bool {
16021623 . unwrap_or ( false )
16031624}
16041625
1626+ #[ unsafe( no_mangle) ]
1627+ pub extern "C" fn processing_key_just_pressed ( key_code : u32 ) -> bool {
1628+ error:: clear_error ( ) ;
1629+ error:: check ( || {
1630+ let kc = key_code_from_u32 ( key_code) ?;
1631+ input_key_just_pressed ( kc)
1632+ } )
1633+ . unwrap_or ( false )
1634+ }
1635+
16051636#[ unsafe( no_mangle) ]
16061637pub extern "C" fn processing_key ( ) -> u32 {
16071638 error:: clear_error ( ) ;
0 commit comments