Skip to content

Commit

Permalink
Call painter.prepare() only when doublesize is engaged/disengaged
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5066 committed Dec 23, 2024
1 parent df27490 commit 66079ed
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/webamp/js/components/Vis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,12 @@ export default function Vis({ analyser }: Props) {
isMWOpen,
]);

// reacts to changes in doublesize mode
useEffect(() => {
if (canvas && painter) {
const canvasCtx = canvas.getContext("2d");
if (canvasCtx) {
painter.prepare();
// wipes the canvas clean if playback is paused and doubled is changing
if (audioStatus === MEDIA_STATUS.PAUSED) {
canvasCtx.clearRect(0, 0, canvas.width, canvas.height);
Expand All @@ -163,7 +165,6 @@ export default function Vis({ analyser }: Props) {

const loop = () => {
canvasCtx.drawImage(bgCanvas, 0, 0);
painter.prepare();
painter.paintFrame();
animationRequest = window.requestAnimationFrame(loop);
};
Expand Down

0 comments on commit 66079ed

Please sign in to comment.