Anonymous user
Bitmap/Bresenham's line algorithm: Difference between revisions
m
→Maple: Cleaned up a bit, and changed a few variable names.
m (→Maple: Cleaned up a bit, and changed a few variable names.) |
|||
Line 669:
<lang maple>SegmentBresenham := proc (img, x0, y0, x1, y1)
local deltax, deltay, x, y, ystep,
img2 := copy(img);
if
end if; ▼
if x12 < x02 then ▼
swap := x02; x02 := x12; x12 := swap; ▼
end if; ▼
deltax := x12-x02; ▼
deltay := abs(y12-y02); ▼
y := y02; ▼
if y02 < y12 then ▼
ystep := 1 else ystep := -1; end if; ▼
if bool then ▼
img2[y, x] := 0 ▼
else ▼
img2[x, y] := 0;▼
end if;
e := e+deltax;▼
end if;
▲ deltax := x12 - x02;
end do; ▼
▲ deltay := abs(y12 - y02);
err := deltax / 2;
▲ y := y02;
ystep := 1
▲ end if;
else
▲ end if;
err := err - deltay;
y := y + ystep;
end if;
▲ end do;
return img2;
end proc:</lang>
=={{header|MAXScript}}==
|