Repository navigation
Add support for round corners if there is no animations - #451
Merged
Merged
Conversation
aborziak-ms
force-pushed
the
user/aborziak-ms/round-corners-support
branch
from
June 23, 2021 16:58
551f6f4 to
9dc0805
Compare
eliezerpMS
reviewed
Jun 23, 2021
eliezerpMS
reviewed
Jun 23, 2021
eliezerpMS
reviewed
Jun 23, 2021
eliezerpMS
reviewed
Jun 23, 2021
eliezerpMS
reviewed
Jun 25, 2021
delete-merged-branch
Bot
deleted the
user/aborziak-ms/round-corners-support
branch
June 25, 2021 19:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implemented After Effects algorithm for "Round Corners" effect. (There is a comment in Shapes.cs:634 that mentioned this // TODO - can round corners be implemented by composing cubic Beziers?)
For now I added support only for one-path + no-animations scenario, in following PR will also add support for multiple paths and animated path/radius. Just to keep this PR small.
.
.
.
To make a round corner we are stepping
radiuspixels in both directions from the corner, and joining resulting points together with a bezier curve (MakeCubicBeziertakes 3 points and creates a bezier curve). But also there is a tricky case, when one end of the segment is already curved, this case described on picture 2.Algorithm loops over segments and creates new array of segments, there are several cases that can happen when we are processing current segment:

0 If current segment has both ends curved we do not need to change anything, just add current segment to the result
1 If current segment has both ends that are not curved:
On this step we are creating new segments
(prevControlPoint, point0)and(point0, point1)2 If current segment has first end curved:

New point will be created on distance
radiusfrom the second end of the segment, on the line that connects second end of the segment and controlPoint1 of original bezier curve.
.
.
Here how it looks in lottie (it is pixel-perfect with how it looks in After Effects) :

(red - original shape, green - with round corners)