mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 05:18:19 +00:00
Add more math nodes (#1378)
* Adds Max, Min and Equal Nodes * Add LogToConsoleNode Logs the data given as the input to the browser console and returns it as the output
This commit is contained in:
parent
e820cf48f6
commit
2377240d07
6 changed files with 133 additions and 1 deletions
|
@ -9,6 +9,7 @@ extern crate log;
|
|||
|
||||
pub mod consts;
|
||||
pub mod generic;
|
||||
pub mod logic;
|
||||
pub mod ops;
|
||||
pub mod structural;
|
||||
#[cfg(feature = "std")]
|
||||
|
|
9
node-graph/gcore/src/logic.rs
Normal file
9
node-graph/gcore/src/logic.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use crate::Node;
|
||||
|
||||
pub struct LogToConsoleNode;
|
||||
|
||||
#[node_macro::node_fn(LogToConsoleNode)]
|
||||
fn log_to_console<T: core::fmt::Debug>(value: T) -> T {
|
||||
debug!("{:#?}", value);
|
||||
value
|
||||
}
|
|
@ -83,6 +83,42 @@ where
|
|||
first.pow(second)
|
||||
}
|
||||
|
||||
// Minimum
|
||||
pub struct MinParameterNode<Second> {
|
||||
second: Second,
|
||||
}
|
||||
|
||||
#[node_macro::node_fn(MinParameterNode)]
|
||||
fn min<T: core::cmp::PartialOrd>(first: T, second: T) -> T {
|
||||
match first < second {
|
||||
true => first,
|
||||
false => second,
|
||||
}
|
||||
}
|
||||
|
||||
// Maximum
|
||||
pub struct MaxParameterNode<Second> {
|
||||
second: Second,
|
||||
}
|
||||
|
||||
#[node_macro::node_fn(MaxParameterNode)]
|
||||
fn max<T: core::cmp::PartialOrd>(first: T, second: T) -> T {
|
||||
match first > second {
|
||||
true => first,
|
||||
false => second,
|
||||
}
|
||||
}
|
||||
|
||||
// Equality
|
||||
pub struct EqParameterNode<Second> {
|
||||
second: Second,
|
||||
}
|
||||
|
||||
#[node_macro::node_fn(EqParameterNode)]
|
||||
fn eq<T: core::cmp::PartialEq>(first: T, second: T) -> bool {
|
||||
first == second
|
||||
}
|
||||
|
||||
// Modulo
|
||||
pub struct ModuloParameterNode<Second> {
|
||||
second: Second,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue