COS301-SE-2023 / AI-Photo-Editor

Blix is a cross-platform AI-assisted graph photo editor. NEW REPO: https://github.com/BlixEditor/blix
GNU General Public License v3.0
40 stars 7 forks source link

Add different options for node anchor shapes #228

Open Rec1dite opened 11 months ago

Rec1dite commented 11 months ago

I'd like if plugins had the option to specify custom shapes for anchors, instead of just circles. Also potentially they should be allowed to specify a custom fill color/outline.

This would be particularly useful for Ripple, where I need a left-pointing arrow anchor, to better represent the flow of program execution.

See the below example from Unreal Engine's blueprints system, except their arrows point to the right (ours will point to the left):

Image

The best way to do this, I think, is to expose some kind of setter in the TypeClassBuilder like so:

    const flowTypeBuilder = context.createTypeclassBuilder("Ripple flow");
    flowTypeBuilder.setDisplayConfigurator( /* ... */ );

    // Here:
    flowTypeBuilder.setStyling({
        shape: "arrow-left",
        fill: "#f43e5c",
        stroke: "#000000"
    });
Rec1dite commented 11 months ago

Make sure to abstract <DefaultAnchor /> in PluginNode.svelte into a separate .svelte file that supports all the anchor shapes. You should be able to replace <DefaultAnchor ... /> with something like this:

<PluginAnchor fill={config["fill"] ?? stringToColor(input.type)} stroke={ ... } shape={config["shape"] ?? "circle"} />