feat: first working version with parameters
This commit is contained in:
18
packages/utils/src/nodes.rs
Normal file
18
packages/utils/src/nodes.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
use crate::encoding;
|
||||
|
||||
pub fn math_node(args: &[i32]) -> (i32, i32) {
|
||||
let math_type = args[0];
|
||||
|
||||
let a = encoding::decode_float(args[1], args[2]);
|
||||
let b = encoding::decode_float(args[3], args[4]);
|
||||
|
||||
let result = match math_type {
|
||||
0 => a + b,
|
||||
1 => a - b,
|
||||
2 => a * b,
|
||||
3 => a / b,
|
||||
_ => 0.0,
|
||||
};
|
||||
|
||||
encoding::encode_float(result)
|
||||
}
|
||||
Reference in New Issue
Block a user