-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add overlay-shape property #2881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
While it's an interesting idea and it's been tried before, I'm not sure things have changed much since then. If we don't provide a good experience for all the shapes, it's not really worth it. The benefits are marginal, and users are fine with the rounded rectangle. It's familiar -- like the active indicator on links in mobile Safari. Do you think you could amend your PR to support all the shapes well, with code that would be simple and maintainable? |
I would also appreciate this feature. Actually, we are currently doing a manual hack where we are changing the shape in every cytoscape.js instance before we include it in our projects. It's really annoying not to be able to change the overlay shape. I think the devs should be able to choose a different shape when they don't want the default rounded rectangle. Since it will be a configurable thing I don't see an issue with including it into the library. |
I've requested the feature in the past because I'm using the overlay to highlight the selected state and since all of the nodes are always circle (in our case) it would be much better to have the possibility to use a circle overlay shape. Frankly, I don't understand why this option is not there already. Otherwise, the library is really great, appreciate all the hard work. |
This would be really good to have. |
+1 |
@maxkfranz I'd love to. There is a possibility for an improvement by calculating centroid position of the base shape or custom polygon, and offset the overlay shape to match the centroid. Do you think it would work well? It might not be enough for shapes with sharp angles such as For custom polygons, does it make sense to add separate |
This looks fantastic! @maxkfranz can you please take a look at it? Seems to be ready to merge. |
This looks like a great improvement over the initial result for the examples you've shown. However, there are two errors in your example: Proposal:
|
Thanks for the detailed feedback! I wondered about the last two concave polygons.
|
The requirement on visually equidistant padding means that overlay shape needs to render rounded corners for each original point, right? |
It sounds like you're talking about a line join, right? It looks like the line join should match that of the reference shape. E.g. the joins should probably be rounded for rounded shapes and sharp for sharp shapes. |
I explored the suggested approaches. It seems that the requirement of equidistant absolute padding for all shapes is not feasible. Even if drawing-shapes.js is rewritten with a new padding parameter in all methods, it would fulfill the requirement for line shapes (drawn with lineTo) only. Curved shapes (drawn with arcTo, quadraticCurveTo, ellipse) would still render non-equidistant padding along the curve. Is there any other possibility to allow finishing this PR? Limitations of custom |
Could you clarify what you mean precisely with some figures? Clearly, the corners are not going to be equidistant to the node shape given some types of line joins -- even for aesthetically pleasing cases. E.g. the rectangle shape isn't equidistant at the corner, but a user would say that it "looks right". Basically, if the result would look janky to a user, then a better approach should be used. Let's not get hung up on strict mathematical definitions. The aesthetics are what's important for styling. In order to officially support this feature, all the built-in shapes must give an aesthetically pleasing result when used with the overlays. Your initially proposed approach was tried in the past, and unfortunately, it caused more problems than benefits. Those who used the feature complained about it (i.e. bad UX and DX). Those who didn't use the feature could obviously live without it. It would be great to have this feature in the core library. In doing that, we have a responsibility to the greater community to create a positive experience -- for features to work as expected and to minimise incompatibilities wherever possible. It's definitely possible to have aesthetically pleasing overlay shapes. Granted, the math and implementation may be more involved than your initial implementation. Or you may need a simpler, creative solution. I understand that you're doing this as a part of consulting work for Graphlytic and you probably want to get things resolved quickly for your client, but we need to balance this PR with what's best for the Cytoscape community as a whole. Thanks for your PR, and I'm looking forward to seeing your next steps. If you need help or want more feedback, you're welcome to comment here. Or if you think it would be faster to clarify and discuss things in a call, we could schedule a quick one. |
Corners are clear, these could be handled by configurable line joins, e.g. so that rectangle overlay can look as rectangle (mitter), or round-rectangle (round), or cut-rectangle (bevel). I meant equidistant padding along curves. Ideally, padding should enlarge the shape in the normal direction from the curve path. Increasing radius by padding for ellipse, arcTo methods, or moving control point for quadraticCurveTo method, would enlarge the shape in the direction from the curve center instead, so it's mathematically incorrect for non-square aspect ratios. If this is an acceptable drawback, then adding padding parameter to all methods in drawing-shapes.js could be a possible way to go. The question is whether it is worth the effort. I understand your concerns. I wonder what simpler solution is possible though, given the constraints. I explored an idea of enlarging the overlay by ratio in width/height multiples depending on aspect ratio, instead of current static padding in px, but it didn't have good results for all shapes. How about implementing overlay-shape with a few basic shapes only (round-rectangle, rectangle, ellipse)? No auto or shapes that are incompatible with current overlay implementation. It would fit my client's usecase, and apparently there might be a demand for it from other users as well. |
I removed complex shapes from the PR, kept round-rectangle, rectangle, ellipse only. It's a pretty minimal change now. Generic support for all shapes can be implemented separately. |
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. |
@maxkfranz could you please take a look at this, if you still see some potential issues? The implementation was reduced to only 3 overlay shapes: "round-rectangle" (current), "rectangle", and "ellipse". Adding the "ellipse" shape is the absolute minimum that we need in our case. Thanks |
I’ll try to set aside some time within the next few days. Is there a particular motivation for including the square-cornered ‘rectangle’ option?
… On Sep 6, 2021, at 1:30 AM, demtec ***@***.***> wrote:
@maxkfranz <https://github.com/maxkfranz> could you please take a look at this, if you still see some potential issues? The implementation was reduced to only 3 overlay shapes: "round-rectangle" (current), "rectangle", and "ellipse". Adding the "ellipse" shape is the absolute minimum that we need in our case. Thanks
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#2881 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAHRO43543GPC33OJP56PFTUARGX7ANCNFSM46LWE3KQ>.
|
Thanks. There's actually no particular motivation for the square-cornered case. We have added it just because it's working well, the proportions are fine with all different sizes of the node. |
If that’s the case, might it be a bit better from the point of view of a library user if it were just the two — round-rectangle and ellipse? The ordinary square-cornered rectangle existing in tandem with the round version may give the expectation to users that other shape variants should also exist.
I don’t foresee many cases where someone would want the non-rounded version, so it may be best to omit it until there’s demand for it
… On Sep 14, 2021, at 3:42 AM, demtec ***@***.***> wrote:
Thanks. There's actually no particular motivation for the square-cornered case. We have added it just because it's working well, the proportions are fine with all different sizes of the node.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#2881 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAHRO43JXN3CEATGSUKBGGLUB34GDANCNFSM46LWE3KQ>.
|
Thanks for confirming, removed rectangle. |
Merged. Will release after #2897 is merged in |
Awesome we got it finished! I'm going to follow up with #2882 |
Minimal possible implementation for #2379
While default overlay shape remains round-rectangle, this gives users the possibility to use another shape.
The result is here:
It's clear it's not perfect for certain shapes, but at least it improves the visual look for the basic shapes.