-
-
Notifications
You must be signed in to change notification settings - Fork 160
lottie: ensuring rectangle closure #3573
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
base: main
Are you sure you want to change the base?
Conversation
A rectangle with roundness = 0 is the only shape where one of its sides is created using a close command. This exceptional case requires additional handling of the close command for every modifier. By adding an extra lineTo command to the rectangle path, its becomes consistent with other shapes, eliminating the special case inside modifiers algorithms.
} | ||
|
||
|
||
static void _close(RenderPath& path, const Point& p, bool round, bool rect = false) |
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.
Rectangle itself doesn't need this logic. This kind of patchwork solution looks bad.
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.
Pull Request Overview
This PR standardizes the path closure behavior for rectangles with zero roundness, ensuring consistency with other shapes and simplifying modifier logic.
- Removes special-case handling in LottieOffsetModifier by eliminating an extra branch that performed a LineTo and corner operation.
- Introduces a new _close function in LottieBuilder to handle rectangle closure and updates its usage in rectangle, star, and polygon path updates.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/loaders/lottie/tvgLottieModifier.cpp | Simplifies the close command handling by removing extra logic for non-rectangle paths. |
src/loaders/lottie/tvgLottieBuilder.cpp | Adds a unified _close function with a rectangle flag and updates its usage across shape builders. |
Comments suppressed due to low confidence (3)
src/loaders/lottie/tvgLottieBuilder.cpp:417
- Using SHAPE(temp)->rs.path.pts[cnt] as the reference point for closure relies on appendRect appending points in a predictable manner. Ensure that 'cnt' is always valid or add a comment clarifying this assumption.
_close(SHAPE(temp)->rs.path, SHAPE(temp)->rs.path.pts[cnt], r > 0.0f, true);
src/loaders/lottie/tvgLottieBuilder.cpp:617
- Switching from using a points array to the full RenderPath in the _close call improves consistency. Confirm that this change preserves all edge-case behaviors from the original implementation.
_close(SHAPE(shape)->rs.path, in, hasRoundness);
src/loaders/lottie/tvgLottieBuilder.cpp:687
- Ensure that the modified _close call for polygons maintains the intended closure behavior compared to the previous approach that used the points array.
_close(SHAPE(shape)->rs.path, in, hasRoundness);
out.cmds.push(PathCommand::LineTo); | ||
corner(out, state.line, state.firstLine, state.movetoOutIndex, true); | ||
} | ||
} else { |
Copilot
AI
Jun 25, 2025
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.
The removal of additional handling logic in the else branch simplifies the path closure but may obscure the intent for non-rectangle shapes. Consider adding a comment to explain why this change is safe and how it aligns with the overall modifier behavior.
} else { | |
} else { | |
// The PathCommand::Close operation is sufficient for closing paths in the current implementation. | |
// This logic is safe and aligns with the overall behavior of the modifier, as it handles specific path types | |
// (e.g., rectangles, ellipses) that do not require additional closure handling for non-rectangle shapes. |
Copilot uses AI. Check for mistakes.
9ddde24
to
dac61de
Compare
30c82d7
to
0c3e8ff
Compare
7b0fe6f
to
811aac3
Compare
d471af2
to
0aaa738
Compare
A rectangle with roundness = 0 is the only shape where one of its sides is created using a close command. This exceptional case requires additional handling of the close command for every modifier. By adding an extra lineTo command to the rectangle path, its becomes consistent with other shapes, eliminating the special case inside modifiers algorithms.
Note: this change does not produce any visible effects.