@@ -17,7 +17,7 @@ use crate::vector::misc::{MergeByDistanceAlgorithm, PointSpacingType, is_linear}
1717use crate :: vector:: misc:: { handles_to_segment, segment_to_handles} ;
1818use crate :: vector:: style:: { PaintOrder , StrokeAlign , StrokeCap , StrokeJoin } ;
1919use crate :: vector:: { FillId , RegionId } ;
20- use crate :: { CloneVarArgs , Color , Context , Ctx , ExtractAll , Graphic , OwnedContextImpl } ;
20+ use crate :: { CloneVarArgs , Color , Context , Ctx , ExtractAll , ExtractVarArgs , Graphic , OwnedContextImpl } ;
2121use core:: f64:: consts:: PI ;
2222use core:: hash:: { Hash , Hasher } ;
2323use glam:: { DAffine2 , DVec2 } ;
@@ -970,6 +970,31 @@ async fn separate_subpaths(_: impl Ctx, content: Table<Vector>) -> Table<Vector>
970970 . collect ( )
971971}
972972
973+ #[ node_macro:: node( category( "Vector: Modifier" ) , path( graphene_core:: vector) ) ]
974+ fn instance_vector ( ctx : impl Ctx + ExtractVarArgs ) -> Table < Vector > {
975+ let Ok ( var_arg) = ctx. vararg ( 0 ) else { return Default :: default ( ) } ;
976+ let var_arg = var_arg as & dyn std:: any:: Any ;
977+
978+ var_arg. downcast_ref ( ) . cloned ( ) . unwrap_or_default ( )
979+ }
980+
981+ #[ node_macro:: node( category( "Vector: Modifier" ) , path( graphene_core:: vector) ) ]
982+ async fn instance_map ( ctx : impl Ctx + CloneVarArgs + ExtractAll , content : Table < Vector > , mapped : impl Node < Context < ' static > , Output = Table < Vector > > ) -> Table < Vector > {
983+ let mut rows = Vec :: new ( ) ;
984+
985+ for ( i, row) in content. into_iter ( ) . enumerate ( ) {
986+ let owned_ctx = OwnedContextImpl :: from ( ctx. clone ( ) ) ;
987+ let owned_ctx = owned_ctx. with_vararg ( Box :: new ( Table :: new_from_row ( row) ) ) . with_index ( i) ;
988+ let table = mapped. eval ( owned_ctx. into_context ( ) ) . await ;
989+
990+ for inner_row in table {
991+ rows. push ( inner_row) ;
992+ }
993+ }
994+
995+ rows. into_iter ( ) . collect ( )
996+ }
997+
973998#[ node_macro:: node( category( "Vector" ) , path( graphene_core:: vector) ) ]
974999async fn flatten_path < I : ' n + Send > ( _: impl Ctx , #[ implementations( Table <Graphic >, Table <Vector >) ] content : Table < I > ) -> Table < Vector >
9751000where
0 commit comments