Skip to content

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

Open
iok144 wants to merge 2 commits into
trpomoais2017:masterfrom
iok144:master
Open

Криницын Игорь#5
iok144 wants to merge 2 commits into
trpomoais2017:masterfrom
iok144:master

Conversation

@iok144

@iok144 iok144 commented Mar 2, 2017

Copy link
Copy Markdown

No description provided.

Comment thread snowflake.js

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

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

Copy link
Copy Markdown

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