cytoscape / cytoscape.js

Graph theory (network) library for visualisation and analysis
https://js.cytoscape.org
MIT License
10.08k stars 1.64k forks source link

Allow creation of 'round-polygon' from shape-polygon-points #3018

Closed mkelly1495 closed 2 years ago

mkelly1495 commented 2 years ago

Description of new feature

Cytoscapejs already has the ability to create rounded polygons using a set of points (internally). However, the functionality is internal and cannot be utilized for custom shapes. I propose adding the ability to specify shape: round-polygon with a list of shape-polygon-points (similar to what is used for polygon). This will allow shapes that require arcs (e.g. and, or gate symbols) to be drawn without requiring a ton of points.

Motivation for new feature

I would like to be able to have graphs that include and and or gate symbols. These symbols are fairly simple but require arcs that are not easily created using straight line polygons. This issue would be resolved by having the ability to specify the polygon as round-polygon. Then the shapes could be created with only a few points and wouldn't have any jagged edges.

So essentially, I'm asking for support for shape: round-polygon that takes the points specified by a shape-polygon-points style property and invokes the node-shapes.js generateRoundPolygon function with the specified points in order to render the desired shape. Currently this function is invoked internally to support the fixed set of rounded shapes (e.g. round-diamond).

For reviewers

Reviewers should ensure that the following tasks are carried out for incorporated issues:

maxkfranz commented 2 years ago

The rounded shapes seem to only support rounded, convex corners (#2496). Your suggested shapes have concave curves, and that seems quite a bit different to me. Maybe @josejulio could chime in re. his rounded shapes feature.

It seems that it may be better to add the shapes natively. That may be easier for AND and OR, and other shapes like NOT or XOR probably aren't practical via the polygon feature anyway. Once you add AND and OR, it's inevitable that people are going to ask for the others. These shapes would probably work nicely with taxi edges.

PRs are welcome for new node shapes. You can look at @josejulio's PR #2496 for a good example of the process.

josejulio commented 2 years ago

The rounded shapes seem to only support rounded, convex corners (#2496). Your suggested shapes have concave curves, and that seems quite a bit different to me. Maybe @josejulio could chime in re. his rounded shapes feature.

That's correct. The PR only introduce support for the rounded corners. Passing the polygon points to generateRoundPolygon will only make the curved corners and that won't be useful for the and/or gates.

Referenced PR gives some reference on the needed pieces:

stale[bot] commented 2 years ago

This issue has been automatically marked as stale, because it has not had activity within the past 14 days. It will be closed if no further activity occurs within the next 7 days. If a feature request is important to you, please consider making a pull request. Thank you for your contributions.