Make CopyToPoints node resolution aware (#1536)
* Make CopyToPoints node resolution aware * Add unfinished code review as todo comment --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
947a131a4b
commit
0e49388312
|
|
@ -2281,7 +2281,8 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
|||
DocumentNodeDefinition {
|
||||
name: "Copy to Points",
|
||||
category: "Vector",
|
||||
implementation: NodeImplementation::proto("graphene_core::vector::CopyToPoints<_>"),
|
||||
implementation: NodeImplementation::proto("graphene_core::vector::CopyToPoints<_, _>"),
|
||||
manual_composition: Some(concrete!(Footprint)),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Points", TaggedValue::VectorData(graphene_core::vector::VectorData::empty()), true),
|
||||
DocumentInputType::value("Instance", TaggedValue::VectorData(graphene_core::vector::VectorData::empty()), true),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
use super::style::{Fill, FillType, Gradient, GradientType, Stroke};
|
||||
use super::VectorData;
|
||||
use crate::transform::Footprint;
|
||||
use crate::{Color, Node};
|
||||
use core::future::Future;
|
||||
|
||||
use bezier_rs::{Subpath, SubpathTValue};
|
||||
use glam::{DAffine2, DVec2};
|
||||
|
|
@ -144,12 +146,21 @@ fn generate_bounding_box(vector_data: VectorData) -> VectorData {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct CopyToPoints<Instance> {
|
||||
pub struct CopyToPoints<Points, Instance> {
|
||||
points: Points,
|
||||
instance: Instance,
|
||||
}
|
||||
|
||||
#[node_macro::node_fn(CopyToPoints)]
|
||||
fn copy_to_points(points: VectorData, instance: VectorData) -> VectorData {
|
||||
async fn copy_to_points<FP: Future<Output = VectorData>, FI: Future<Output = VectorData>>(
|
||||
footprint: Footprint,
|
||||
points: impl Node<Footprint, Output = FP>,
|
||||
instance: impl Node<Footprint, Output = FI>,
|
||||
) -> VectorData {
|
||||
// TODO: https://github.com/GraphiteEditor/Graphite/pull/1536#discussion_r1436422419
|
||||
let points = self.points.eval(footprint).await;
|
||||
let instance = self.instance.eval(footprint).await;
|
||||
|
||||
let points_list = points.subpaths.iter().flat_map(|s| s.anchors());
|
||||
|
||||
let instance_bounding_box = instance.bounding_box().unwrap_or_default();
|
||||
|
|
|
|||
|
|
@ -676,115 +676,11 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
|||
async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, fn_params: [Footprint => Option<Color>, () => Arc<WasmSurfaceHandle>]),
|
||||
async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, fn_params: [() => Vec<Color>, () => Arc<WasmSurfaceHandle>]),
|
||||
async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, fn_params: [Footprint => Vec<Color>, () => Arc<WasmSurfaceHandle>]),
|
||||
//register_node!(graphene_core::transform::TranformNode<_, _, _, _, _, _>, input: , output: RenderOutput, fn_params: [Footprint => GraphicGroup, () => Arc<WasmSurfaceHandle>]),
|
||||
vec![
|
||||
(
|
||||
ProtoNodeIdentifier::new("graphene_core::transform::TransformNode<_, _, _, _, _, _>"),
|
||||
|mut args| {
|
||||
Box::pin(async move {
|
||||
args.reverse();
|
||||
let node = <graphene_core::transform::TransformNode<_, _, _, _, _, _>>::new(
|
||||
DowncastBothNode::<Footprint, VectorData>::new(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<f32>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
);
|
||||
let any: DynAnyNode<Footprint, _, _> = graphene_std::any::DynAnyNode::new(node);
|
||||
Box::new(any) as TypeErasedBox
|
||||
})
|
||||
},
|
||||
{
|
||||
let params = vec![fn_type!(Footprint, VectorData), fn_type!(DVec2), fn_type!(f32), fn_type!(DVec2), fn_type!(DVec2), fn_type!(DVec2)];
|
||||
NodeIOTypes::new(concrete!(Footprint), concrete!(VectorData), params)
|
||||
},
|
||||
),
|
||||
(
|
||||
ProtoNodeIdentifier::new("graphene_core::transform::TransformNode<_, _, _, _, _, _>"),
|
||||
|mut args| {
|
||||
Box::pin(async move {
|
||||
args.reverse();
|
||||
let node = <graphene_core::transform::TransformNode<_, _, _, _, _, _>>::new(
|
||||
DowncastBothNode::<Footprint, WasmSurfaceHandleFrame>::new(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<f32>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
);
|
||||
let any: DynAnyNode<Footprint, _, _> = graphene_std::any::DynAnyNode::new(node);
|
||||
Box::new(any) as TypeErasedBox
|
||||
})
|
||||
},
|
||||
{
|
||||
let params = vec![
|
||||
fn_type!(Footprint, WasmSurfaceHandleFrame),
|
||||
fn_type!(DVec2),
|
||||
fn_type!(f32),
|
||||
fn_type!(DVec2),
|
||||
fn_type!(DVec2),
|
||||
fn_type!(DVec2),
|
||||
];
|
||||
NodeIOTypes::new(concrete!(Footprint), concrete!(WasmSurfaceHandleFrame), params)
|
||||
},
|
||||
),
|
||||
(
|
||||
ProtoNodeIdentifier::new("graphene_core::transform::TransformNode<_, _, _, _, _, _>"),
|
||||
|mut args| {
|
||||
Box::pin(async move {
|
||||
args.reverse();
|
||||
let node = <graphene_core::transform::TransformNode<_, _, _, _, _, _>>::new(
|
||||
DowncastBothNode::<Footprint, ImageFrame<Color>>::new(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<f32>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect("Not enough arguments provided to construct node")),
|
||||
);
|
||||
let any: DynAnyNode<Footprint, _, _> = graphene_std::any::DynAnyNode::new(node);
|
||||
Box::new(any) as TypeErasedBox
|
||||
})
|
||||
},
|
||||
{
|
||||
let params = vec![
|
||||
fn_type!(Footprint, ImageFrame<Color>),
|
||||
fn_type!(DVec2),
|
||||
fn_type!(f32),
|
||||
fn_type!(DVec2),
|
||||
fn_type!(DVec2),
|
||||
fn_type!(DVec2),
|
||||
];
|
||||
NodeIOTypes::new(concrete!(Footprint), concrete!(ImageFrame<Color>), params)
|
||||
},
|
||||
),
|
||||
(
|
||||
ProtoNodeIdentifier::new("graphene_core::transform::TransformNode<_, _, _, _, _, _>"),
|
||||
|mut args| {
|
||||
Box::pin(async move {
|
||||
const EXPECT_MESSAGE: &str = "Not enough arguments provided to construct node";
|
||||
|
||||
args.reverse();
|
||||
|
||||
let node = <graphene_core::transform::TransformNode<_, _, _, _, _, _>>::new(
|
||||
DowncastBothNode::<Footprint, GraphicGroup>::new(args.pop().expect(EXPECT_MESSAGE)),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect(EXPECT_MESSAGE)),
|
||||
graphene_std::any::input_node::<f32>(args.pop().expect(EXPECT_MESSAGE)),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect(EXPECT_MESSAGE)),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect(EXPECT_MESSAGE)),
|
||||
graphene_std::any::input_node::<DVec2>(args.pop().expect(EXPECT_MESSAGE)),
|
||||
);
|
||||
|
||||
let any: DynAnyNode<Footprint, _, _> = graphene_std::any::DynAnyNode::new(node);
|
||||
Box::new(any) as TypeErasedBox
|
||||
})
|
||||
},
|
||||
{
|
||||
let params = vec![fn_type!(Footprint, GraphicGroup), fn_type!(DVec2), fn_type!(f32), fn_type!(DVec2), fn_type!(DVec2), fn_type!(DVec2)];
|
||||
NodeIOTypes::new(concrete!(Footprint), concrete!(GraphicGroup), params)
|
||||
},
|
||||
),
|
||||
],
|
||||
async_node!(graphene_core::transform::TransformNode<_, _, _, _, _, _>, input: Footprint, output: VectorData, fn_params: [Footprint => VectorData, () => DVec2, () => f32, () => DVec2, () => DVec2, () => DVec2]),
|
||||
async_node!(graphene_core::transform::TransformNode<_, _, _, _, _, _>, input: Footprint, output: WasmSurfaceHandleFrame, fn_params: [Footprint => WasmSurfaceHandleFrame, () => DVec2, () => f32, () => DVec2, () => DVec2, () => DVec2]),
|
||||
async_node!(graphene_core::transform::TransformNode<_, _, _, _, _, _>, input: Footprint, output: WasmSurfaceHandleFrame, fn_params: [Footprint => WasmSurfaceHandleFrame, () => DVec2, () => f32, () => DVec2, () => DVec2, () => DVec2]),
|
||||
async_node!(graphene_core::transform::TransformNode<_, _, _, _, _, _>, input: Footprint, output: ImageFrame<Color>, fn_params: [Footprint => ImageFrame<Color>, () => DVec2, () => f32, () => DVec2, () => DVec2, () => DVec2]),
|
||||
async_node!(graphene_core::transform::TransformNode<_, _, _, _, _, _>, input: Footprint, output: GraphicGroup, fn_params: [Footprint => GraphicGroup, () => DVec2, () => f32, () => DVec2, () => DVec2, () => DVec2]),
|
||||
register_node!(graphene_core::transform::SetTransformNode<_>, input: VectorData, params: [VectorData]),
|
||||
register_node!(graphene_core::transform::SetTransformNode<_>, input: ImageFrame<Color>, params: [ImageFrame<Color>]),
|
||||
register_node!(graphene_core::transform::SetTransformNode<_>, input: VectorData, params: [DAffine2]),
|
||||
|
|
@ -836,7 +732,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
|
|||
)],
|
||||
register_node!(graphene_std::raster::SampleNode<_>, input: Footprint, params: [ImageFrame<Color>]),
|
||||
register_node!(graphene_std::raster::MandelbrotNode, input: Footprint, params: []),
|
||||
register_node!(graphene_core::vector::CopyToPoints<_>, input: VectorData, params: [VectorData]),
|
||||
async_node!(graphene_core::vector::CopyToPoints<_, _>, input: Footprint, output: VectorData, fn_params: [Footprint => VectorData, Footprint => VectorData]),
|
||||
register_node!(graphene_core::vector::ResamplePoints<_>, input: VectorData, params: [f64]),
|
||||
register_node!(graphene_core::vector::SplinesFromPointsNode, input: VectorData, params: []),
|
||||
register_node!(graphene_core::vector::generator_nodes::CircleGenerator<_>, input: (), params: [f32]),
|
||||
|
|
|
|||
Loading…
Reference in New Issue