Add support for double-sided confetti colors (enableDoubleSided) #251
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.
Description:
This PR addresses Issue #183 by adding support for double-sided confetti rendering. The key addition is the enableDoubleSided option, which allows the front and back sides of confetti pieces to be rendered in different colors based on their tilt.
Changes Made:
enableDoubleSided
(boolean): when true, the confetti will render with different front and back colors depending on the tilt direction.frontColors
(array): RGB color options for the front face of confetti.backColors
(array): RGB color options for the back face of confetti.Rendering Update:
In the draw loop, the
fillStyle
is conditionally set tocolorFront
orcolorBack
based on the value oftiltCos
whenenableDoubleSided
is true.Example Configuration:
Backward Compatibility:
enableDoubleSided
is not specified, the confetti will render using the existing colors option as before, ensuring backward compatibility.disableForReducedMotion
remains false by default to preserve the current behavior.Added Unit Tests Under test/index.test.js (All Passing):
Recording.2025-05-02.074406.mp4
@catdad