Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mgrudzinska
Copy link
Collaborator

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.

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.
@mgrudzinska mgrudzinska self-assigned this Jun 24, 2025
@mgrudzinska mgrudzinska added the lottie Lottie animation label Jun 24, 2025
}


static void _close(RenderPath& path, const Point& p, bool round, bool rect = false)
Copy link
Member

@hermet hermet Jun 25, 2025

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.

@hermet hermet requested a review from Copilot June 25, 2025 06:45
Copy link

@Copilot Copilot AI left a 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 {
Copy link

Copilot AI Jun 25, 2025

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.

Suggested change
} 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lottie Lottie animation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants