mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-03 21:08:18 +00:00
Improve node macro and add more diagnostics (#1999)
* Improve node macro ergonomics * Fix type error in stub import * Fix wasm nodes * Code review --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
3eb98c6d6d
commit
cd4124a596
15 changed files with 358 additions and 122 deletions
|
@ -5,7 +5,7 @@ use graphene_core::Color;
|
|||
#[node_macro::node(category("Raster"))]
|
||||
async fn image_color_palette<F: 'n + Send>(
|
||||
#[implementations((), Footprint)] footprint: F,
|
||||
#[implementations(((), ImageFrame<Color>), (Footprint, ImageFrame<Color>))] image: impl Node<F, Output = ImageFrame<Color>>,
|
||||
#[implementations(() -> ImageFrame<Color>, Footprint -> ImageFrame<Color>)] image: impl Node<F, Output = ImageFrame<Color>>,
|
||||
#[min(1.)]
|
||||
#[max(28.)]
|
||||
max_size: u32,
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::ops::{Div, Mul};
|
|||
#[node_macro::node(category(""))]
|
||||
async fn boolean_operation<F: 'n + Copy + Send>(
|
||||
#[implementations((), Footprint)] footprint: F,
|
||||
#[implementations(((), GraphicGroup), (Footprint, GraphicGroup))] group_of_paths: impl Node<F, Output = GraphicGroup>,
|
||||
#[implementations(() -> GraphicGroup, Footprint -> GraphicGroup)] group_of_paths: impl Node<F, Output = GraphicGroup>,
|
||||
operation: BooleanOperation,
|
||||
) -> VectorData {
|
||||
let group_of_paths = group_of_paths.eval(footprint).await;
|
||||
|
|
|
@ -133,7 +133,7 @@ async fn render_canvas(render_config: RenderConfig, data: impl GraphicElementRen
|
|||
#[cfg(target_arch = "wasm32")]
|
||||
async fn rasterize<T: GraphicElementRendered + graphene_core::transform::TransformMut + WasmNotSend + 'n>(
|
||||
_: (),
|
||||
#[implementations((Footprint, VectorData), (Footprint, ImageFrame<Color>), (Footprint, GraphicGroup))] data: impl Node<Footprint, Output = T>,
|
||||
#[implementations(Footprint -> VectorData, Footprint -> ImageFrame<Color>, Footprint -> GraphicGroup)] data: impl Node<Footprint, Output = T>,
|
||||
footprint: Footprint,
|
||||
surface_handle: Arc<SurfaceHandle<HtmlCanvasElement>>,
|
||||
) -> ImageFrame<Color> {
|
||||
|
@ -190,17 +190,17 @@ async fn render<'a: 'n, T: 'n + GraphicElementRendered + WasmNotSend>(
|
|||
render_config: RenderConfig,
|
||||
editor_api: &'a WasmEditorApi,
|
||||
#[implementations(
|
||||
(Footprint, VectorData),
|
||||
(Footprint, ImageFrame<Color>),
|
||||
(Footprint, GraphicGroup),
|
||||
(Footprint, graphene_core::Artboard),
|
||||
(Footprint, graphene_core::ArtboardGroup),
|
||||
(Footprint, Option<Color>),
|
||||
(Footprint, Vec<Color>),
|
||||
(Footprint, bool),
|
||||
(Footprint, f32),
|
||||
(Footprint, f64),
|
||||
(Footprint, String),
|
||||
Footprint -> VectorData,
|
||||
Footprint -> ImageFrame<Color>,
|
||||
Footprint -> GraphicGroup,
|
||||
Footprint -> graphene_core::Artboard,
|
||||
Footprint -> graphene_core::ArtboardGroup,
|
||||
Footprint -> Option<Color>,
|
||||
Footprint -> Vec<Color>,
|
||||
Footprint -> bool,
|
||||
Footprint -> f32,
|
||||
Footprint -> f64,
|
||||
Footprint -> String,
|
||||
)]
|
||||
data: impl Node<Footprint, Output = T>,
|
||||
_surface_handle: impl Node<(), Output = Option<wgpu_executor::WgpuSurface>>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue