mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-02 12:32:17 +00:00
Add more advanced math nodes (#1383)
Added nodes for the following operations: * Floor * Ceil * Round * Absolute Value * Logarithm * Natural Logarithm * sin * cos * tan
This commit is contained in:
parent
2412a3def6
commit
7558088727
4 changed files with 176 additions and 0 deletions
|
@ -83,6 +83,80 @@ where
|
|||
first.pow(second)
|
||||
}
|
||||
|
||||
// Floor
|
||||
pub struct FloorNode;
|
||||
|
||||
#[node_macro::node_fn(FloorNode)]
|
||||
fn floor(input: f32) -> f32 {
|
||||
input.floor()
|
||||
}
|
||||
|
||||
// Ceil
|
||||
pub struct CeilNode;
|
||||
|
||||
#[node_macro::node_fn(CeilNode)]
|
||||
fn ceil(input: f32) -> f32 {
|
||||
input.ceil()
|
||||
}
|
||||
|
||||
// Round
|
||||
pub struct RoundNode;
|
||||
|
||||
#[node_macro::node_fn(RoundNode)]
|
||||
fn round(input: f32) -> f32 {
|
||||
input.round()
|
||||
}
|
||||
|
||||
// Absolute Value
|
||||
pub struct AbsoluteNode;
|
||||
|
||||
#[node_macro::node_fn(AbsoluteNode)]
|
||||
fn abs(input: f32) -> f32 {
|
||||
input.abs()
|
||||
}
|
||||
|
||||
// Log
|
||||
pub struct LogParameterNode<Second> {
|
||||
second: Second,
|
||||
}
|
||||
|
||||
#[node_macro::node_fn(LogParameterNode)]
|
||||
fn ln<U: num_traits::float::Float>(first: U, second: U) -> U {
|
||||
first.log(second)
|
||||
}
|
||||
|
||||
// Natural Log
|
||||
pub struct NaturalLogNode;
|
||||
|
||||
#[node_macro::node_fn(NaturalLogNode)]
|
||||
fn ln(input: f32) -> f32 {
|
||||
input.ln()
|
||||
}
|
||||
|
||||
// Sine
|
||||
pub struct SineNode;
|
||||
|
||||
#[node_macro::node_fn(SineNode)]
|
||||
fn ln(input: f32) -> f32 {
|
||||
input.sin()
|
||||
}
|
||||
|
||||
// Cos
|
||||
pub struct CosineNode;
|
||||
|
||||
#[node_macro::node_fn(CosineNode)]
|
||||
fn ln(input: f32) -> f32 {
|
||||
input.cos()
|
||||
}
|
||||
|
||||
// Tan
|
||||
pub struct TangentNode;
|
||||
|
||||
#[node_macro::node_fn(TangentNode)]
|
||||
fn ln(input: f32) -> f32 {
|
||||
input.tan()
|
||||
}
|
||||
|
||||
// Minimum
|
||||
pub struct MinParameterNode<Second> {
|
||||
second: Second,
|
||||
|
|
|
@ -227,6 +227,15 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
|
|||
register_node!(graphene_core::ops::ExponentParameterNode<_>, input: f32, params: [f32]),
|
||||
register_node!(graphene_core::ops::ExponentParameterNode<_>, input: &f32, params: [f32]),
|
||||
register_node!(graphene_core::ops::ExponentParameterNode<_>, input: f32, params: [&f32]),
|
||||
register_node!(graphene_core::ops::FloorNode, input: f32, params: []),
|
||||
register_node!(graphene_core::ops::CeilNode, input: f32, params: []),
|
||||
register_node!(graphene_core::ops::RoundNode, input: f32, params: []),
|
||||
register_node!(graphene_core::ops::AbsoluteNode, input: f32, params: []),
|
||||
register_node!(graphene_core::ops::LogParameterNode<_>, input: f32, params: [f32]),
|
||||
register_node!(graphene_core::ops::NaturalLogNode, input: f32, params: []),
|
||||
register_node!(graphene_core::ops::SineNode, input: f32, params: []),
|
||||
register_node!(graphene_core::ops::CosineNode, input: f32, params: []),
|
||||
register_node!(graphene_core::ops::TangentNode, input: f32, params: []),
|
||||
register_node!(graphene_core::ops::MaxParameterNode<_>, input: u32, params: [u32]),
|
||||
register_node!(graphene_core::ops::MaxParameterNode<_>, input: f32, params: [f32]),
|
||||
register_node!(graphene_core::ops::MinParameterNode<_>, input: u32, params: [u32]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue