-
Notifications
You must be signed in to change notification settings - Fork 13
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
Solution by Anosov Andrey #7
base: master
Are you sure you want to change the base?
Conversation
index.html
Outdated
} | ||
else { | ||
context.scale(1 / 3, 1 / 3); // Уменьшаем масштаб в 3 раза | ||
drawLine(count - 1, length); context.rotate(60 * deg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
несколько инструкций в одной строке - плохой стиль
index.html
Outdated
var fill = 'transparent'; | ||
var length = Math.sqrt(Math.pow((points[0].x - points[1].x), 2) + Math.pow((points[0].y - points[1].y), 2)); | ||
function drawLine(count, length) { | ||
context.save(); // Сохраняем текущую трансформацию |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
код должен быть понятен без комментариев
index.html
Outdated
var strokes = ["#6cf", "#9cf", "#99f", "#ccf", "#66f", "#3cf", "#ff33cc", "#ff3366", "#33ff66"]; | ||
var stroke = strokes[rand(strokes.length)]; | ||
var fill = 'transparent'; | ||
var length = Math.sqrt(Math.pow((points[0].x - points[1].x), 2) + Math.pow((points[0].y - points[1].y), 2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Math.pow(v, 2) - это медленный способ возведения в квадрат. Тут не критично, но уже пора запомнить и использовать умножение.
index.html
Outdated
|
||
|
||
} | ||
context.save(); context.strokeStyle = stroke; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь и ниже тоже не используй несколько команд в одной строке.
Чтобы было видно, что несколько команд относятся к чему-то одному — оставь пустую строчки после предыдущих инструкций и до последующих
doSomething();
doAction1();
doAction2();
doAction3();
doSomething();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
исправлено
No description provided.