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

Криницын Игорь #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

iok144
Copy link

@iok144 iok144 commented Mar 2, 2017

No description provided.


var context = canvas.getContext("2d");

canvas.width = canvas.width;//Очистка канваса
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Делаешь хак - не пиши комментарий, а выдели метод/функцию. Удачная функция: function clearCanvas(canvas);

Кстати, на StackOverflow по поводу этого хака.
Заметь, что context.clearRect понятен без комментария и отдельного метода.

Use: context.clearRect(0, 0, canvas.width, canvas.height);

This is the fastest and most descriptive way to clear the entire canvas.

Do not use: canvas.width = canvas.width;

Resetting canvas.width resets all canvas state (e.g. transformations, lineWidth, strokeStyle, etc.), it is very slow (compared to clearRect), it doesn't work in all browsers, and it doesn't describe what you are actually trying to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants