Node macro lambda parameters (#1309)

* Implement parsing of impl Node<I, …> syntax for the macro

* Extend node macro to allow specifying lambda nodes
This commit is contained in:
Dennis Kobert
2023-06-09 16:43:46 +02:00
committed by GitHub
parent 6ee9e20e4c
commit cf1d294013
15 changed files with 109 additions and 106 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
/* eslint-disable max-classes-per-file */
import {writable} from "svelte/store";
import { writable } from "svelte/store";
import { downloadFileText, downloadFileBlob, upload, downloadFileURL } from "@graphite/utility-functions/files";
import { extractPixelData, imageToPNG, rasterizeSVG, rasterizeSVGCanvas } from "@graphite/utility-functions/rasterization";
@@ -98,7 +98,7 @@ export function createPortfolioState(editor: Editor) {
});
});
editor.subscriptions.subscribeJsMessage(TriggerRasterizeRegionBelowLayer, async (triggerRasterizeRegionBelowLayer) => {
const { documentId, layerPath, svg, size, imaginateNodePath } = triggerRasterizeRegionBelowLayer;
const { documentId, layerPath, svg, size } = triggerRasterizeRegionBelowLayer;
// Rasterize the SVG to an image file
try {
@@ -106,7 +106,7 @@ export function createPortfolioState(editor: Editor) {
const imageData = (await rasterizeSVGCanvas(svg, size[0], size[1])).getContext("2d")?.getImageData(0, 0, size[0], size[1]);
if (!imageData) return;
editor.instance.renderGraphUsingRasterizedRegionBelowLayer(documentId, layerPath, new Uint8Array(imageData.data), imageData.width, imageData.height, imaginateNodePath);
editor.instance.renderGraphUsingRasterizedRegionBelowLayer(documentId, layerPath, new Uint8Array(imageData.data), imageData.width, imageData.height);
}
}
// getImageData may throw an exception if the resolution is too high
+1 -3
View File
@@ -545,8 +545,6 @@ export class TriggerRasterizeRegionBelowLayer extends JsMessage {
readonly svg!: string;
readonly size!: [number, number];
readonly imaginateNodePath!: BigUint64Array | undefined;
}
export class TriggerRefreshBoundsOfViewports extends JsMessage { }
@@ -700,7 +698,7 @@ export class ImaginateImageData {
readonly imageData!: Uint8Array;
readonly transform!: Float64Array ;
readonly transform!: Float64Array;
}
export class DisplayDialogDismiss extends JsMessage { }
+1 -10
View File
@@ -588,21 +588,12 @@ impl JsEditorHandle {
/// Sends the blob URL generated by JS to the Imaginate layer in the respective document
#[wasm_bindgen(js_name = renderGraphUsingRasterizedRegionBelowLayer)]
pub fn render_graph_using_rasterized_region_below_layer(
&self,
document_id: u64,
layer_path: Vec<LayerId>,
input_image_data: Vec<u8>,
width: u32,
height: u32,
imaginate_node_path: Option<Vec<NodeId>>,
) {
pub fn render_graph_using_rasterized_region_below_layer(&self, document_id: u64, layer_path: Vec<LayerId>, input_image_data: Vec<u8>, width: u32, height: u32) {
let message = PortfolioMessage::RenderGraphUsingRasterizedRegionBelowLayer {
document_id,
layer_path,
input_image_data,
size: (width, height),
imaginate_node_path,
};
self.dispatch(message);
}