Skip to content
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

Fix: Clear ripple effect marking #928

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ rippleEffect.start = (x = 0, y = 0) => {
const elapsed = timestamp - startTime;

if (elapsed > duration) {
clearArea(x, y);
resolve();
return;
}
Expand All @@ -89,23 +90,26 @@ rippleEffect.start = (x = 0, y = 0) => {
});
};

rippleEffect.create = (rippleX, rippleY, speed) => {
// Calculate the area to clear
const { ripples, numRipples, maxRadius } = config.rippleEffect;
const clearArea = (x, y) => {
const { numRipples, maxRadius } = config.rippleEffect;
const clearWidth = maxRadius * 2 + (numRipples - 1) * 40;
const clearHeight = maxRadius * 1.5;

app.p.push();
app.p.fill(config.canvas.background);
app.p.noStroke();
app.p.rect(x - 1, y - clearHeight / 2 - 200, clearWidth, clearHeight + 400);
app.p.pop();
};

rippleEffect.create = (rippleX, rippleY, speed) => {
// Calculate the area to clear
const { ripples, maxRadius } = config.rippleEffect;
const p = app.p;

p.push();
// Clear only the area used by the ripples
p.fill(config.canvas.background);
p.noStroke();
p.rect(
rippleX - 1,
rippleY - clearHeight / 2 - 200,
clearWidth,
clearHeight + 400
);
clearArea(rippleX, rippleY);
let allComplete = true;
p.translate(rippleX, rippleY);

Expand Down
Loading