-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Taxi edge turn radius (i.e. smooth curve on each turn) #3142
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good start, and I'm sure it would be mergeable with some iteration.
It would be useful to specify exactly how you propose your feature should be used. Give an example of how the style properties, old and new, should be specified in order to achieve your proposed effect. For instance, it's not clear why this would be coupled to haystack edges. |
Great feedback, thanks @maxkfranz - we had already begun work to make it a configurable value, will change the property name and provide some documentation on how users could make use it. |
Great. We're planning on releasing 3.26.0 on next week's Friday, the 4th of August. It would be great to have this feature in the release. Looking forward to your updates. |
@maxkfranz - we've made most of the changes now to get this feature in. Just in the process of testing / fixing up, will get the PR updated shortly... |
moved to taxi radius values
Hey, I've updated the pr with the suggestions you made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Getting close.
for( let i = 2; i + 1 < pts.length; i += 2 ){ | ||
context.lineTo( pts[ i ], pts[ i + 1] ); | ||
const taxiRadius= edge.pstyle( 'taxi-radius' ) | ||
const taxiRadiusValue = taxiRadius ? taxiRadius.value : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const taxiRadiusValue = taxiRadius ? taxiRadius.value : 0 | |
const taxiRadiusValue = taxiRadius ? taxiRadius.pfValue : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preferred value (pfValue
, i.e. px), not raw value (value
, e.g. 1em
has value
of 1
)
const taxiRadius= edge.pstyle( 'taxi-radius' ) | ||
const taxiRadiusValue = taxiRadius ? taxiRadius.value : 0 | ||
|
||
if( taxiRadiusValue > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've pushed up the latest changes @maxkfranz - let us know if you need anything else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. We're making progress. I've attached some comments below:
* This property makes the taxi edge be re-routed when the turns would be otherwise too close to the source or target. As such, it also helps to avoid turns overlapping edge endpoint arrows. | ||
* This property makes the taxi edge be re-routed when the turns would be otherwise too close to the source or target. As such, it also helps to avoid turns overlapping edge endpoint arrows | ||
* **`taxi-radius`** : The taxi-radius property applies a curve to a taxi edge, providing a rounded appearance to any 90 degree bend. | ||
* This value should be a floating point number (e.g. `3.14`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* This value should be a floating point number (e.g. `3.14`). | |
* This value should be a floating point length (e.g. `3.14px`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a clarification
){ | ||
addEle( edge, sqDist ); | ||
return true; | ||
if( rs.edgeType === 'segments' && edge.pstyle( 'taxi-radius' ).value > 0 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that this is intended to be a performant simplification, but it doesn't seem to work as intended, e.g. you get clear false positives on the debug page example:
Screen.Recording.2023-08-03.at.14.53.06.mov
The curved taxi edge gets false positives way off the edge. You can compare to other edges, such as the haystacks in the video, to get a sense of how it should feel in proximity.
The corners need to be handled more accurately. For instance, you could
- use the centre of the curve's circle to precisely calculate the distance for the corner's hit test (i.e. using the inequality of the squared tap threshold and the squared distance to avoid the performance downside of using square roots); or
- make corner checks that mimic the curve with a reasonably-close bezier approximation -- using the existing
math.inBezierVicinity()
function; or - replace the drawing of the corner of a curved taxi with a quadratic bezier -- and then you can use
math.inBezierVicinity()
with perfect accuracy (with the downside that it's not really a circle anymore).
If you try (2), temporarily using (3) would help to visualise your approximation even if you don't actually do (3) in the end result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: Hit test code that is curved-taxi-specific should check edge.pstyle( 'curve-style' ).value === 'taxi'
, just like your drawing code, so that it's explicit and bounded.
* This property makes the taxi edge be re-routed when the turns would be otherwise too close to the source or target. As such, it also helps to avoid turns overlapping edge endpoint arrows | ||
* **`taxi-radius`** : The taxi-radius property applies a curve to a taxi edge, providing a rounded appearance to any 90 degree bend. | ||
* This value should be a floating point number (e.g. `3.14`). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if we cap the radius (see the comments later on), it may be useful to have another sub-bullet-point that notes that the radius should not be too large. It depends on how your other taxi properties are specified, the layout, etc.
for( let i = 2; i + 1 < pts.length; i += 2 ){ | ||
context.lineTo( pts[ i ], pts[ i + 1] ); | ||
const taxiRadius= edge.pstyle( 'taxi-radius' ) | ||
const taxiRadiusValue = taxiRadius ? taxiRadius.pfValue : 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to how border-radius
works in ordinary CSS, it would be useful to cap the taxi radius based on the available space. For instance, a div that's a 10px by 10px square can't have a radius greater than 5px effectively.
For the edges, the radius could be capped by the available space on the line.
If you have a larger radius, then the edge will bug out depending on the orientation of the nodes:
Screen.Recording.2023-08-03.at.15.29.33.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
N.b. this issue also effects smaller radii, but not as obviously.
@Adam-Shea @hassniazi, let us know if any of the feedback is unclear. Looking forward to your updates |
Heya, all clear! Just finding some time to get the last few changes in |
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. |
@Adam-Shea, are you still interested in this feature? |
Associated issues: This is a follow up to this discussion #3135
Added rounded corners to haystacks when the
taxi-curve
property is set to yes.Happy to change property name or move elsewhere if you think there is a better format
Thanks :)
Author:
unstable
. Bug-fix patches can go on eitherunstable
ormaster
.Reviewers:
master
branch and theunstable
branch. Normally, this just requires cherry-picking the corresponding merge commit frommaster
tounstable
-- or vice versa.