From dafb93510d92d370c6dd6efb8eefc4ef7d0631e8 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Fri, 20 Feb 2026 10:30:49 +0100 Subject: [PATCH 1/3] Rename Map Vector to Map --- .../messages/portfolio/document_migration.rs | 2 +- node-graph/nodes/vector/src/instance.rs | 38 ++++++++++++++++++- node-graph/nodes/vector/src/vector_nodes.rs | 19 ---------- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/editor/src/messages/portfolio/document_migration.rs b/editor/src/messages/portfolio/document_migration.rs index acb107867f..4d5f510662 100644 --- a/editor/src/messages/portfolio/document_migration.rs +++ b/editor/src/messages/portfolio/document_migration.rs @@ -838,7 +838,7 @@ const NODE_REPLACEMENTS: &[NodeReplacement<'static>] = &[ aliases: &["graphene_core::vector::InstanceIndexNode", "core_types::vector::InstanceIndexNode"], }, NodeReplacement { - node: graphene_std::vector::map_vector::IDENTIFIER, + node: graphene_std::vector::instance::map::IDENTIFIER, aliases: &["graphene_core::vector::InstanceMapNode"], }, NodeReplacement { diff --git a/node-graph/nodes/vector/src/instance.rs b/node-graph/nodes/vector/src/instance.rs index aa3369a869..bb01a1054e 100644 --- a/node-graph/nodes/vector/src/instance.rs +++ b/node-graph/nodes/vector/src/instance.rs @@ -1,6 +1,7 @@ -use core_types::Color; use core_types::table::{Table, TableRowRef}; +use core_types::{AnyHash, Color}; use core_types::{CloneVarArgs, Context, Ctx, ExtractAll, OwnedContextImpl}; +use dyn_any::DynAny; use graphic_types::Graphic; use graphic_types::Vector; use graphic_types::raster_types::{CPU, Raster}; @@ -82,6 +83,41 @@ async fn instance_repeat + Default + Send + Clone + 'static>( result_table } +#[node_macro::node(category("Vector"), path(graphene_core::vector))] +async fn map( + ctx: impl Ctx + CloneVarArgs + ExtractAll, + #[implementations( + Table, + Table, + Table>, + Table, + Table, + )] + content: Table, + #[implementations( + Context -> Table, + Context -> Table, + Context -> Table>, + Context -> Table, + Context -> Table, + )] + mapped: impl Node, Output = Table>, +) -> Table { + let mut rows = Vec::new(); + + for (i, row) in content.into_iter().enumerate() { + let owned_ctx = OwnedContextImpl::from(ctx.clone()); + let owned_ctx = owned_ctx.with_vararg(Box::new(Table::new_from_row(row))).with_index(i); + let table = mapped.eval(owned_ctx.into_context()).await; + + for inner_row in table { + rows.push(inner_row); + } + } + + rows.into_iter().collect() +} + #[cfg(test)] mod test { use super::*; diff --git a/node-graph/nodes/vector/src/vector_nodes.rs b/node-graph/nodes/vector/src/vector_nodes.rs index d6b9d4f233..5666095f9e 100644 --- a/node-graph/nodes/vector/src/vector_nodes.rs +++ b/node-graph/nodes/vector/src/vector_nodes.rs @@ -1325,25 +1325,6 @@ async fn separate_subpaths(_: impl Ctx, content: Table) -> Table .collect() } -// TODO: Call this "Map" once it's fully generic -#[node_macro::node(category("Vector"), path(graphene_core::vector))] -async fn map_vector(ctx: impl Ctx + CloneVarArgs + ExtractAll, content: Table, mapped: impl Node, Output = Table>) -> Table { - let mut rows = Vec::new(); - - for (i, row) in content.into_iter().enumerate() { - let owned_ctx = OwnedContextImpl::from(ctx.clone()); - let owned_ctx = owned_ctx.with_vararg(Box::new(Table::new_from_row(row))).with_index(i); - let table = mapped.eval(owned_ctx.into_context()).await; - - for inner_row in table { - rows.push(inner_row); - } - } - - rows.into_iter().collect() -} - -// TODO: Call this "Map" once it's fully generic #[node_macro::node(category("Vector"), path(graphene_core::vector))] async fn map_points(ctx: impl Ctx + CloneVarArgs + ExtractAll, content: Table, mapped: impl Node, Output = DVec2>) -> Table { let mut content = content; From f76ee725250730f7050b418f83cd6a8e071cd36e Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Fri, 20 Feb 2026 10:47:42 +0100 Subject: [PATCH 2/3] Fix compilation errors --- .../node_graph/document_node_definitions.rs | 24 +++++++++---------- node-graph/nodes/vector/src/instance.rs | 9 +++---- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs index fb7240b824..ba8c06c70f 100644 --- a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs +++ b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs @@ -479,9 +479,9 @@ fn document_node_definitions() -> HashMap 1[6:Reset Transform] // "false: bool" -> 2[6:Reset Transform] // "false: bool" -> 3[6:Reset Transform] - // [12:Flatten Vector]0 -> 0[7:Map Vector] - // [6:Reset Transform]0 -> 1[7:Map Vector] - // [7:Map Vector]0 -> 0[8:Morph] + // [12:Flatten Vector]0 -> 0[7:Map] + // [6:Reset Transform]0 -> 1[7:Map] + // [7:Map]0 -> 0[8:Morph] // [15:Multiply]0 -> 1[8:Morph] // [8:Morph]0 -> 0[9:Transform] // [4:Position on Path]0 -> 1[9:Transform] @@ -563,9 +563,9 @@ fn document_node_definitions() -> HashMap HashMap HashMap 0[2:Decompose Translation] // [2:Decompose Translation]0 -> 0[3:Vec2 to Point] // [IMPORTS]0 -> 0[4:Flatten Vector] - // [4:Flatten Vector]0 -> 0[5:Map Vector] - // [3:Vec2 to Point]0 -> 1[5:Map Vector] - // [5:Map Vector]0 -> 0[6: Flatten Path] + // [4:Flatten Vector]0 -> 0[5:Map] + // [3:Vec2 to Point]0 -> 1[5:Map] + // [5:Map]0 -> 0[6: Flatten Path] // [6:Flatten Path]0 -> 0[7:Points to Polyline] // "false: bool" -> 1[7:Points to Polyline] // [7:Points to Polyline]0 -> 0[EXPORTS] @@ -879,9 +879,9 @@ fn document_node_definitions() -> HashMap HashMap( )] mapped: impl Node, Output = Table>, ) -> Table { - let mut rows = Vec::new(); + let mut rows = Table::new(); for (i, row) in content.into_iter().enumerate() { let owned_ctx = OwnedContextImpl::from(ctx.clone()); let owned_ctx = owned_ctx.with_vararg(Box::new(Table::new_from_row(row))).with_index(i); let table = mapped.eval(owned_ctx.into_context()).await; - for inner_row in table { - rows.push(inner_row); - } + rows.extend(table); } - rows.into_iter().collect() + rows } #[cfg(test)] From 0701fb1470ebcf5d84df0a3af6907325e9a6a1fa Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Fri, 20 Feb 2026 12:56:13 -0800 Subject: [PATCH 3/3] Move to the Graphic module and add Read {Graphic, Raster, Color} nodes --- .../node_graph/document_node_definitions.rs | 4 +-- .../messages/portfolio/document_migration.rs | 2 +- node-graph/nodes/gcore/src/context.rs | 30 ++++++++++++++-- node-graph/nodes/graphic/src/graphic.rs | 36 +++++++++++++++++-- node-graph/nodes/vector/src/instance.rs | 35 +----------------- 5 files changed, 65 insertions(+), 42 deletions(-) diff --git a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs index ba8c06c70f..75c64da0d3 100644 --- a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs +++ b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs @@ -565,7 +565,7 @@ fn document_node_definitions() -> HashMap HashMap] = &[ aliases: &["graphene_core::vector::InstanceIndexNode", "core_types::vector::InstanceIndexNode"], }, NodeReplacement { - node: graphene_std::vector::instance::map::IDENTIFIER, + node: graphene_std::graphic::map::IDENTIFIER, aliases: &["graphene_core::vector::InstanceMapNode"], }, NodeReplacement { diff --git a/node-graph/nodes/gcore/src/context.rs b/node-graph/nodes/gcore/src/context.rs index abf440ea30..eee22bb4d8 100644 --- a/node-graph/nodes/gcore/src/context.rs +++ b/node-graph/nodes/gcore/src/context.rs @@ -1,10 +1,18 @@ -use core_types::ExtractVarArgs; use core_types::table::Table; +use core_types::{Color, ExtractVarArgs}; use core_types::{Ctx, ExtractIndex, ExtractPosition}; use glam::DVec2; -use graphic_types::Vector; +use graphic_types::{Graphic, Vector}; +use raster_types::{CPU, Raster}; + +#[node_macro::node(category("Context"), path(graphene_core::vector))] +fn read_graphic(ctx: impl Ctx + ExtractVarArgs) -> Table { + let Ok(var_arg) = ctx.vararg(0) else { return Default::default() }; + let var_arg = var_arg as &dyn std::any::Any; + + var_arg.downcast_ref().cloned().unwrap_or_default() +} -// TODO: Call this "Read Context" once it's fully generic #[node_macro::node(category("Context"), path(graphene_core::vector))] fn read_vector(ctx: impl Ctx + ExtractVarArgs) -> Table { let Ok(var_arg) = ctx.vararg(0) else { return Default::default() }; @@ -13,6 +21,22 @@ fn read_vector(ctx: impl Ctx + ExtractVarArgs) -> Table { var_arg.downcast_ref().cloned().unwrap_or_default() } +#[node_macro::node(category("Context"), path(graphene_core::vector))] +fn read_raster(ctx: impl Ctx + ExtractVarArgs) -> Table> { + let Ok(var_arg) = ctx.vararg(0) else { return Default::default() }; + let var_arg = var_arg as &dyn std::any::Any; + + var_arg.downcast_ref().cloned().unwrap_or_default() +} + +#[node_macro::node(category("Context"), path(graphene_core::vector))] +fn read_color(ctx: impl Ctx + ExtractVarArgs) -> Table { + let Ok(var_arg) = ctx.vararg(0) else { return Default::default() }; + let var_arg = var_arg as &dyn std::any::Any; + + var_arg.downcast_ref().cloned().unwrap_or_default() +} + #[node_macro::node(category("Context"), path(core_types::vector))] async fn read_position( ctx: impl Ctx + ExtractPosition, diff --git a/node-graph/nodes/graphic/src/graphic.rs b/node-graph/nodes/graphic/src/graphic.rs index ef76f5e4c7..ad17492941 100644 --- a/node-graph/nodes/graphic/src/graphic.rs +++ b/node-graph/nodes/graphic/src/graphic.rs @@ -1,14 +1,46 @@ -use core_types::Color; -use core_types::Ctx; use core_types::registry::types::SignedInteger; use core_types::table::{Table, TableRow}; use core_types::uuid::NodeId; +use core_types::{AnyHash, CloneVarArgs, Color, Context, Ctx, ExtractAll, OwnedContextImpl}; use glam::{DAffine2, DVec2}; use graphic_types::graphic::{Graphic, IntoGraphicTable}; use graphic_types::{Artboard, Vector}; use raster_types::{CPU, GPU, Raster}; use vector_types::GradientStops; +#[node_macro::node(category("General"), path(graphene_core::vector))] +async fn map( + ctx: impl Ctx + CloneVarArgs + ExtractAll, + #[implementations( + Table, + Table, + Table>, + Table, + Table, + )] + content: Table, + #[implementations( + Context -> Table, + Context -> Table, + Context -> Table>, + Context -> Table, + Context -> Table, + )] + mapped: impl Node, Output = Table>, +) -> Table { + let mut rows = Table::new(); + + for (i, row) in content.into_iter().enumerate() { + let owned_ctx = OwnedContextImpl::from(ctx.clone()); + let owned_ctx = owned_ctx.with_vararg(Box::new(Table::new_from_row(row))).with_index(i); + let table = mapped.eval(owned_ctx.into_context()).await; + + rows.extend(table); + } + + rows +} + /// Performs internal editor record-keeping that enables tools to target this network's layer. /// This node associates the ID of the network's parent layer to every element of output data. /// This technical detail may be ignored by users, and will be phased out in the future. diff --git a/node-graph/nodes/vector/src/instance.rs b/node-graph/nodes/vector/src/instance.rs index cc1f05c29d..aa3369a869 100644 --- a/node-graph/nodes/vector/src/instance.rs +++ b/node-graph/nodes/vector/src/instance.rs @@ -1,5 +1,5 @@ +use core_types::Color; use core_types::table::{Table, TableRowRef}; -use core_types::{AnyHash, Color}; use core_types::{CloneVarArgs, Context, Ctx, ExtractAll, OwnedContextImpl}; use graphic_types::Graphic; use graphic_types::Vector; @@ -82,39 +82,6 @@ async fn instance_repeat + Default + Send + Clone + 'static>( result_table } -#[node_macro::node(category("Vector"), path(graphene_core::vector))] -async fn map( - ctx: impl Ctx + CloneVarArgs + ExtractAll, - #[implementations( - Table, - Table, - Table>, - Table, - Table, - )] - content: Table, - #[implementations( - Context -> Table, - Context -> Table, - Context -> Table>, - Context -> Table, - Context -> Table, - )] - mapped: impl Node, Output = Table>, -) -> Table { - let mut rows = Table::new(); - - for (i, row) in content.into_iter().enumerate() { - let owned_ctx = OwnedContextImpl::from(ctx.clone()); - let owned_ctx = owned_ctx.with_vararg(Box::new(Table::new_from_row(row))).with_index(i); - let table = mapped.eval(owned_ctx.into_context()).await; - - rows.extend(table); - } - - rows -} - #[cfg(test)] mod test { use super::*;