Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion node-graph/gcore/src/vector/vector_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::vector::misc::{MergeByDistanceAlgorithm, PointSpacingType, is_linear}
use crate::vector::misc::{handles_to_segment, segment_to_handles};
use crate::vector::style::{PaintOrder, StrokeAlign, StrokeCap, StrokeJoin};
use crate::vector::{FillId, RegionId};
use crate::{CloneVarArgs, Color, Context, Ctx, ExtractAll, Graphic, OwnedContextImpl};
use crate::{CloneVarArgs, Color, Context, Ctx, ExtractAll, ExtractVarArgs, Graphic, OwnedContextImpl};
use core::f64::consts::PI;
use core::hash::{Hash, Hasher};
use glam::{DAffine2, DVec2};
Expand Down Expand Up @@ -969,6 +969,26 @@ async fn separate_subpaths(_: impl Ctx, content: Table<Vector>) -> Table<Vector>
})
.collect()
}
#[node_macro::node(category("Vector: Modifier"), path(graphene_core::vector))]
fn extract_vector(ctx: impl Ctx + ExtractVarArgs) -> Table<Vector> {
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("Vector: Modifier"), path(graphene_core::vector))]
async fn map_instance(ctx: impl Ctx + CloneVarArgs + ExtractAll, content: Table<Vector>, map_fn: impl Node<Context<'static>, Output = Table<Vector>>) -> Table<Vector> {
let mut rows = Vec::new();
for row in content {
let owned_ctx = OwnedContextImpl::from(ctx.clone());
let owned_ctx = owned_ctx.with_vararg(Box::new(Table::new_from_row(row)));
let table = map_fn.eval(owned_ctx.into_context()).await;
for inner_row in table {
rows.push(inner_row);
}
}
rows.into_iter().collect()
}

#[node_macro::node(category("Vector"), path(graphene_core::vector))]
async fn flatten_path<I: 'n + Send>(_: impl Ctx, #[implementations(Table<Graphic>, Table<Vector>)] content: Table<I>) -> Table<Vector>
Expand Down