Skip to content

Add support for round corners if there is no animations - #451

Merged
aborziak-ms merged 5 commits into
masterfrom
user/aborziak-ms/round-corners-support
Jun 25, 2021
Merged

aborziak-ms merged 5 commits into
masterfrom
user/aborziak-ms/round-corners-support

Conversation

@aborziak-ms

@aborziak-ms aborziak-ms commented Jun 22, 2021 •

Copy link
Copy Markdown
Collaborator

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 radius pixels in both directions from the corner, and joining resulting points together with a bezier curve (MakeCubicBezier takes 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 radius from 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)

@aborziak-ms
aborziak-ms requested a review from a team as a code owner June 22, 2021 23:53
@aborziak-ms
aborziak-ms force-pushed the user/aborziak-ms/round-corners-support branch from 551f6f4 to 9dc0805 Compare June 23, 2021 16:58
Comment thread source/LottieToWinComp/Paths.cs Resolved
Comment thread source/LottieToWinComp/Paths.cs Resolved
Comment thread source/LottieToWinComp/Paths.cs Resolved
Comment thread source/LottieToWinComp/Paths.cs Resolved
eliezerpMS
eliezerpMS previously approved these changes Jun 23, 2021

@eliezerpMS eliezerpMS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Comment thread source/LottieToWinComp/Paths.cs Resolved
eliezerpMS
eliezerpMS previously approved these changes Jun 25, 2021

@eliezerpMS eliezerpMS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@eliezerpMS eliezerpMS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@aborziak-ms
aborziak-ms merged commit 96eeab4 into master Jun 25, 2021
@delete-merged-branch
delete-merged-branch Bot deleted the user/aborziak-ms/round-corners-support branch June 25, 2021 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants