Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DrawOurLine(View& view,
- const unsigned short& x1, const unsigned short& y1,
- const unsigned short& x2, const unsigned short& y2)
- {
- SymmetricDda(view, x1, y1, x2, y2);
- float xf1;
- float yf1;
- float xf2;
- float yf2;
- if (x1 > x2) {
- xf1 = x2;
- yf1 = y2;
- xf2 = x1;
- yf2 = y1;
- }
- else
- {
- xf1 = x1;
- yf1 = y1;
- xf2 = x2;
- yf2 = y2;
- }
- float m;
- m = (yf2 - yf1) / (xf2 - xf1);
- view(xf1, (int)yf1) = Pixel(0, 0, 0);
- if (m > 1)
- {
- while (xf1 < xf2)
- {
- yf1 = yf1 + 1;
- xf1 = xf1 + 1/m;
- view((int)xf1, (int)yf1) = Pixel(0, 0, 0);
- }
- }
- else
- {
- while (xf1 < xf2) {
- xf1 = xf1 + 1;
- yf1 = yf1 + m;
- view((int)xf1, (int)yf1) = Pixel(0, 0, 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement