diff --git a/node-graph/gcore/src/graphic_element/renderer.rs b/node-graph/gcore/src/graphic_element/renderer.rs index c34ae46490..53c354eab2 100644 --- a/node-graph/gcore/src/graphic_element/renderer.rs +++ b/node-graph/gcore/src/graphic_element/renderer.rs @@ -205,10 +205,14 @@ fn to_transform(transform: DAffine2) -> usvg::Transform { usvg::Transform::from_row(cols[0] as f32, cols[1] as f32, cols[2] as f32, cols[3] as f32, cols[4] as f32, cols[5] as f32) } +// TODO: Consider renaming this to better express what it does pub trait GraphicElementRendered { fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams); + fn bounding_box(&self, transform: DAffine2) -> Option<[DVec2; 2]>; + fn add_click_targets(&self, click_targets: &mut Vec); + fn to_usvg_node(&self) -> usvg::Node { let mut render = SvgRender::new(); let render_params = RenderParams::new(crate::vector::style::ViewMode::Normal, ImageRenderMode::Base64, None, false, false, false); diff --git a/node-graph/gcore/src/raster/image.rs b/node-graph/gcore/src/raster/image.rs index edae0d01da..9600352dd2 100644 --- a/node-graph/gcore/src/raster/image.rs +++ b/node-graph/gcore/src/raster/image.rs @@ -155,6 +155,7 @@ impl Image { } } } + impl Image { pub fn to_png(&self) -> Vec { use ::image::ImageEncoder; diff --git a/node-graph/gcore/src/transform.rs b/node-graph/gcore/src/transform.rs index 400c39931b..599c26c613 100644 --- a/node-graph/gcore/src/transform.rs +++ b/node-graph/gcore/src/transform.rs @@ -165,7 +165,7 @@ pub enum RenderQuality { Scale(f32), /// Flip a coin to decide if the render should be available with the current quality or done at full quality /// This should be used to gradually update the render quality of a cached node - Probabilty(f32), + Probability(f32), /// Render at full quality Full, } diff --git a/node-graph/interpreted-executor/src/node_registry.rs b/node-graph/interpreted-executor/src/node_registry.rs index 75713eae80..5bfabf7122 100644 --- a/node-graph/interpreted-executor/src/node_registry.rs +++ b/node-graph/interpreted-executor/src/node_registry.rs @@ -80,6 +80,8 @@ macro_rules! register_node { macro_rules! async_node { // TODO: we currently need to annotate the type here because the compiler would otherwise (correctly) // assign a Pin>> type to the node, which is not what we want for now. + // + // This `params` variant of the macro wraps the normal `fn_params` variant and is used as a shorthand for writing `T` instead of `() => T` ($path:ty, input: $input:ty, output: $output:ty, params: [ $($type:ty),*]) => { async_node!($path, input: $input, output: $output, fn_params: [ $(() => $type),*]) }; @@ -682,8 +684,18 @@ fn node_registry() -> HashMap, input: WasmEditorApi, output: RenderOutput, fn_params: [Footprint => ArtboardGroup, () => Arc]), async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, fn_params: [Footprint => Option, () => Arc]), async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, fn_params: [Footprint => Vec, () => Arc]), - async_node!(graphene_std::wasm_application_io::RasterizeVectorNode<_, _>, input: VectorData, output: ImageFrame, params: [Footprint, Arc]), - async_node!(graphene_std::wasm_application_io::RasterizeVectorNode<_, _>, input: GraphicGroup, output: ImageFrame, params: [Footprint, Arc]), + async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, params: [ImageFrame, Arc]), + async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, params: [VectorData, Arc]), + async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, params: [GraphicGroup, Arc]), + async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, params: [Artboard, Arc]), + async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, params: [bool, Arc]), + async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, params: [f32, Arc]), + async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, params: [f64, Arc]), + async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, params: [String, Arc]), + async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, params: [Option, Arc]), + async_node!(graphene_std::wasm_application_io::RenderNode<_, _, _>, input: WasmEditorApi, output: RenderOutput, params: [Vec, Arc]), + async_node!(graphene_std::wasm_application_io::RasterizeVectorNode<_, _>, input: VectorData, output: ImageFrame, params: [Footprint, Arc]), + async_node!(graphene_std::wasm_application_io::RasterizeVectorNode<_, _>, input: GraphicGroup, output: ImageFrame, params: [Footprint, Arc]), async_node!(graphene_core::transform::TransformNode<_, _, _, _, _, _>, input: Footprint, output: VectorData, fn_params: [Footprint => VectorData, () => DVec2, () => f64, () => DVec2, () => DVec2, () => DVec2]), async_node!(graphene_core::transform::TransformNode<_, _, _, _, _, _>, input: Footprint, output: WasmSurfaceHandleFrame, fn_params: [Footprint => WasmSurfaceHandleFrame, () => DVec2, () => f64, () => DVec2, () => DVec2, () => DVec2]), async_node!(graphene_core::transform::TransformNode<_, _, _, _, _, _>, input: Footprint, output: WasmSurfaceHandleFrame, fn_params: [Footprint => WasmSurfaceHandleFrame, () => DVec2, () => f64, () => DVec2, () => DVec2, () => DVec2]),