def line(self, x0, y0, x1, y1):
<EOL>x0, y0, x1, y1 = int(x0), int(y0), int(x1), int(y1)<EOL>if y0 > y1:<EOL><INDENT>y0, y1, x0, x1 = y1, y0, x1, x0<EOL><DEDENT>dx = x1 - x0<EOL>if dx < <NUM_LIT:0>:<EOL><INDENT>sx = -<NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>sx = <NUM_LIT:1><EOL><DEDENT>dx *= sx<EOL>dy = y1 - y0<EOL>if dy == <NUM_LIT:0>:<EOL><INDENT>for x in range(x0, x1, sx):<EOL><INDENT>self.point(x, y0)<EOL><DEDENT>return<EOL><DEDENT>if dx == <NUM_LIT:0>:<EOL><INDENT>for y in range(y0, y1):<EOL><INDENT>self.point(x0, y)<EOL><DEDENT>self.point(x1, y1)<EOL>return<EOL><DEDENT>if dx == dy:<EOL><INDENT>for x in range(x0, x1, sx):<EOL><INDENT>self.point(x, y0)<EOL>y0 += <NUM_LIT:1><EOL><DEDENT>return<EOL><DEDENT>self.point(x0, y0)<EOL>e_acc = <NUM_LIT:0><EOL>if dy > dx:  <EOL><INDENT>e = (dx << <NUM_LIT:16>) // dy<EOL>for i in range(y0, y1 - <NUM_LIT:1>):<EOL><INDENT>e_acc_temp, e_acc = e_acc, (e_acc + e) & <NUM_LIT><EOL>if e_acc <= e_acc_temp:<EOL><INDENT>x0 += sx<EOL><DEDENT>w = <NUM_LIT>-(e_acc >> <NUM_LIT:8>)<EOL>self.point(x0, y0, intensity(self.color, w))<EOL>y0 += <NUM_LIT:1><EOL>self.point(x0 + sx, y0, intensity(self.color, (<NUM_LIT> - w)))<EOL><DEDENT>self.point(x1, y1)<EOL>return<EOL><DEDENT>e = (dy << <NUM_LIT:16>) // dx<EOL>for i in range(x0, x1 - sx, sx):<EOL><INDENT>e_acc_temp, e_acc = e_acc, (e_acc + e) & <NUM_LIT><EOL>if e_acc <= e_acc_temp:<EOL><INDENT>y0 += <NUM_LIT:1><EOL><DEDENT>w = <NUM_LIT>-(e_acc >> <NUM_LIT:8>)<EOL>self.point(x0, y0, intensity(self.color, w))<EOL>x0 += sx<EOL>self.point(x0, y0 + <NUM_LIT:1>, intensity(self.color, (<NUM_LIT>-w)))<EOL><DEDENT>self.point(x1, y1)<EOL>
Draw a line using Xiaolin Wu's antialiasing technique