Skip to content
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
14 changes: 5 additions & 9 deletions src/website/hooks/BR/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ const drawSquare = (
const size = dot.radius * 2 * scale;
const x = dot.centerX * scale - size / 2;
const y = dot.centerY * scale - size / 2;
const borderRadius = size * 0.2;

context.fillStyle = color;
context.beginPath();
context.roundRect(x, y, size, size, borderRadius);
context.fill();
context.fillRect(x, y, size, size);
};

export const draw = (
Expand Down Expand Up @@ -51,13 +48,13 @@ export const draw = (
if (result.progress > 0) {
visibleCount++;

drawSquare(context, dotState.dot, result.progress, scale);

const isStableVisible = result.visible && result.disappearAt === null;
if (isStableVisible) {
visibleIndices.push(dotIndex);
}
}

drawSquare(context, dotState.dot, result.progress, scale);
}

processRemovals(state, visibleIndices, visibleCount, elapsed);
Expand All @@ -71,9 +68,8 @@ export const updateCanvasSize = (
const rect = canvas.getBoundingClientRect();
if (rect.width === 0 || rect.height === 0) return;

const devicePixelRatio = window.devicePixelRatio || 1;
canvas.width = rect.width * devicePixelRatio;
canvas.height = rect.height * devicePixelRatio;
canvas.width = rect.width;
canvas.height = rect.height;

const context = canvas.getContext('2d');
if (context) {
Expand Down