{"action":"opened","issue":{"url":"https://api.github.com/repos/skylurker/tinyrenderer/issues/7","labels_url":"https://api.github.com/repos/skylurker/tinyrenderer/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/skylurker/tinyrenderer/issues/7/comments","events_url":"https://api.github.com/repos/skylurker/tinyrenderer/issues/7/events","html_url":"https://github.com/skylurker/tinyrenderer/issues/7","id":60641789,"number":7,"title":"Explanations on the Bresenham","user":{"login":"skylurker","id":6448764,"avatar_url":"https://avatars.githubusercontent.com/u/6448764?v=3","gravatar_id":"","url":"https://api.github.com/users/skylurker","html_url":"https://github.com/skylurker","followers_url":"https://api.github.com/users/skylurker/followers","following_url":"https://api.github.com/users/skylurker/following{/other_user}","gists_url":"https://api.github.com/users/skylurker/gists{/gist_id}","starred_url":"https://api.github.com/users/skylurker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skylurker/subscriptions","organizations_url":"https://api.github.com/users/skylurker/orgs","repos_url":"https://api.github.com/users/skylurker/repos","events_url":"https://api.github.com/users/skylurker/events{/privacy}","received_events_url":"https://api.github.com/users/skylurker/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-11T11:02:21Z","updated_at":"2015-03-11T11:02:21Z","closed_at":null,"body":"Расписать для себя (может, просто протрассировать):\r\n Переменная error даёт нам дистанцию до идеальной прямой от нашего текущего пикселя (x, y). Каждый раз, как error превышает один пиксель, мы увеличиваем (уменьшаем) y на единицу, и на единицу же уменьшаем ошибку.\r\nint dx = x1-x0;\r\nint dy = y1-y0;\r\nfloat derror = std::abs(dy/float(dx));\r\nfloat error = 0;\r\nint y = y0;\r\nfor (int x=x0; x<=x1; x++) {\r\nif (steep) {\r\nimage.set(y, x, color);\r\n} else {\r\nimage.set(x, y, color);\r\n}\r\nerror += derror;\r\nif (error>.5) {\r\ny += (y1>y0?1:-1);\r\nerror -= 1.;\r\n}\r\n}"}}