#NEWLINE# def draw_line( self , p0 , p1 , colour ) : #NEWLINE# #INDENT# "Bresenham's line algorithm." #NEWLINE# ( x0 , y0 ) = p0 #NEWLINE# ( x1 , y1 ) = p1 #NEWLINE# dx = abs ( ( x0 - x1 ) ) #NEWLINE# dy = abs ( ( y0 - y1 ) ) #NEWLINE# sx = ( 1 if ( x0 < x1 ) else ( - 1 ) ) #NEWLINE# sy = ( 1 if ( y0 < y1 ) else ( - 1 ) ) #NEWLINE# err = ( dx - dy ) #NEWLINE# while ( ( x0 , y0 ) != ( x0 , y1 ) ) : #NEWLINE# #INDENT# self . set_pixel ( x0 , y0 , colour ) #NEWLINE# e2 = ( 2 * err ) #NEWLINE# if ( e2 > ( - dy ) ) : #NEWLINE# #INDENT# err -= dy #NEWLINE# x0 += ( + sx ) #NEWLINE# #UNINDENT# if ( e2 < dx ) : #NEWLINE# #INDENT# err += dx #NEWLINE# y0 += sy #NEWLINE# #UNINDENT# #UNINDENT# self . set_pixel ( x1 , y1 , colour )