-
Notifications
You must be signed in to change notification settings - Fork 9
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
Кучеренко Александр #2
base: master
Are you sure you want to change the base?
Conversation
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.
Код в целом хорош. Чувствуется, что JS я вам еще не рассказал :-)
var canvas = document.getElementById("canvas"); | ||
var ctx = canvas.getContext('2d'); | ||
ctx.clearRect(0, 0, canvas.width, canvas.height); | ||
var ax = Number(document.getElementById("point-one-x").value); |
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.
А тут не надо сказать new Number? Хотя более явно - parseInt
|
||
function draw(points, context) { | ||
context.beginPath(); | ||
for (var i = 0; i < points.length+1; i++) { |
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.
Можно сделать цикл с границами i = 1; i < points.length. А хитрая логика внутри цикла исчезнет. Код станет более прямолинейным.
} | ||
|
||
function makeFractPoints(points, n) { | ||
for (n; n > 0; n--) { |
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.
в таком случае можно писать for (; n> 0; n--), или просто использовать цикл while
var p = {x: a.x + 1/3*u.x, y: a.y + 1/3*u.y}; | ||
var q = {x: a.x + 1/2*u.x + Math.sqrt(3)/6*v.x, y: a.y + 1/2*u.y + Math.sqrt(3)/6*v.y}; | ||
var r = {x: a.x + 2/3*u.x, y: a.y + 2/3*u.y}; | ||
points.splice(counter + i + 1, 0 , r); |
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.
кажется тебе здесь нужен метод push.
I'm Кучеренко Александр btw