diff --git a/node-graph/gcore/src/transform_nodes.rs b/node-graph/gcore/src/transform_nodes.rs index dd3dff8ed..ecda6b807 100644 --- a/node-graph/gcore/src/transform_nodes.rs +++ b/node-graph/gcore/src/transform_nodes.rs @@ -8,6 +8,7 @@ use core::f64; use glam::{DAffine2, DVec2}; use graphene_core_shaders::color::Color; +/// Applies the specified transform to the input value, which may be a graphic type or another transform. #[node_macro::node(category(""))] async fn transform( ctx: impl Ctx + CloneVarArgs + ExtractAll + ModifyFootprint, @@ -46,6 +47,7 @@ async fn transform( transform_target } +/// Overwrites the transform of each element in the input table with the specified transform. #[node_macro::node(category(""))] fn replace_transform( _: impl Ctx + InjectFootprint, @@ -58,6 +60,8 @@ fn replace_transform( data } +// TODO: Figure out how this node should behave once #2982 is implemented. +/// Obtains the transform of the first element in the input table, if present. #[node_macro::node(category("Math: Transform"), path(graphene_core::vector))] async fn extract_transform( _: impl Ctx, @@ -74,21 +78,25 @@ async fn extract_transform( vector.iter().next().map(|row| *row.transform).unwrap_or_default() } +/// Produces the inverse of the input transform, which is the transform that undoes the effect of the original transform. #[node_macro::node(category("Math: Transform"))] fn invert_transform(_: impl Ctx, transform: DAffine2) -> DAffine2 { transform.inverse() } +/// Extracts the translation component from the input transform. #[node_macro::node(category("Math: Transform"))] fn decompose_translation(_: impl Ctx, transform: DAffine2) -> DVec2 { transform.translation } +/// Extracts the rotation component (in degrees) from the input transform. This, together with the "Decompose Scale" node, also may jointly represent any shear component in the original transform. #[node_macro::node(category("Math: Transform"))] fn decompose_rotation(_: impl Ctx, transform: DAffine2) -> f64 { - transform.decompose_rotation() + transform.decompose_rotation().to_degrees() } +/// Extracts the scale component from the input transform. This, together with the "Decompose Rotation" node, also may jointly represent any shear component in the original transform. #[node_macro::node(category("Math: Transform"))] fn decompose_scale(_: impl Ctx, transform: DAffine2) -> DVec2 { transform.decompose_scale()