C
C
chegcheg2021-02-22 03:19:33
JavaScript
chegcheg, 2021-02-22 03:19:33

How to properly redraw the canvas when the window is resized?

There is an animated grid of dots .

When resizing a window, the canvas does not shrink to the size of the window, but simply shrinks, as a result of which the grid is distorted and the cursor position is incorrectly registered.
How can this be fixed?

Add. offhand question - how to change canvas background color to completely transparent?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2021-02-22
@rPman

You yourself set the size in vh / vw and they are, by definition, a percentage of the window size.
Make in px or at least in em
canvas the same element as the others, set the style to background:transparent; or opacity:XXX;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question