snapapps / edgy

a visual programming language inspired by Scratch
http://snapapps.github.io/
GNU Affero General Public License v3.0
51 stars 21 forks source link

Use morphic for graph drawing #371

Closed cyderize closed 7 years ago

cyderize commented 8 years ago

At the moment we use JSNetworkX's built in d3-based SVG drawing. Unfortunately it has certain limitations, such as appearing in front of the world canvas (#153), no native support for webcola layout, no native support for self-loops, as well as some bugs when dealing with mutations.

These issues (except the first one) have been fixed by modifying JSNetworkX itself, because with its minified code blob we can't monkey patch changes on top. This required recompilation of JSNetworkX, which can only be done on Unix-like operating systems and is rather inconvenient.

I propose that we instead implement drawing using Snap!'s morphic paradigm, because this would tie in better with the 'status quo' for Snap!-based projects, and also would allow us to address all these issues (including #153). We would then be able to stop using the JSNetworkX SVG drawing API, which is unstable, and instead use our own morphic drawing (I've been doing some tests and it seems feasible to implement) on top of the more stable NetworkX based API.

Performance wise, they are pretty much identical (although canvas is theoretically faster than SVG for large graphs, overhead from morphic keeping track of what to draw makes performance very similar).