#NEWLINE# def draw( self , x , y , char = None , colour = 7 , bg = 0 , thin = False ) : #NEWLINE# #INDENT# '\n        Draw a line from drawing cursor to the specified position.  This uses a\n        modified Bressenham algorithm, interpolating twice as many points to\n        render down to anti-aliased characters when no character is specified,\n        or uses standard algorithm plotting with the specified character.\n\n        :param x: The column (x coord) for the location to check.\n        :param y: The line (y coord) for the location to check.\n        :param char: Optional character to use to draw the line.\n        :param colour: Optional colour for plotting the line.\n        :param bg: Optional background colour for plotting the line.\n        :param thin: Optional width of anti-aliased line.\n        ' #NEWLINE# x0 = self . _x #NEWLINE# y0 = self . _y #NEWLINE# x1 = ( int ( round ( x , 1 ) ) * 2 ) #NEWLINE# y1 = ( int ( round ( y , 1 ) ) * 2 ) #NEWLINE# self . _x = x1 #NEWLINE# self . _y = y1 #NEWLINE# dx = abs ( ( x1 - x0 ) ) #NEWLINE# dy = abs ( ( y1 - y0 ) ) #NEWLINE# sx = ( ( - 1 ) if ( x0 > x1 ) else 1 ) #NEWLINE# sy = ( ( - 1 ) if ( y0 > y1 ) else 1 ) #NEWLINE# x_range = ( range ( 0 , 2 ) if ( sx > 0 ) else range ( 1 , ( - 1 ) , ( - 1 ) ) ) #NEWLINE# y_range = ( range ( 0 , 2 ) if ( sy > 0 ) else range ( 1 , ( - 1 ) , ( - 1 ) ) ) #NEWLINE# x = x0 #NEWLINE# y = y0 #NEWLINE# if ( dx > dy ) : #NEWLINE# #INDENT# err = dx #NEWLINE# while ( x != x1 ) : #NEWLINE# #INDENT# next_chars = [ 0 , 0 ] #NEWLINE# px = ( x & ( ~ 1 ) ) #NEWLINE# py = ( y & ( ~ 1 ) ) #NEWLINE# for ix in x_range : #NEWLINE# #INDENT# if ( ( y >= py ) and ( ( y - py ) < 2 ) ) : #NEWLINE# #INDENT# next_chars [ 0 ] |= ( ( 2 ** ix ) * ( 4 ** ( y % 2 ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# next_chars [ 1 ] |= ( ( 2 ** ix ) * ( 4 ** ( y % 2 ) ) ) #NEWLINE# #UNINDENT# if ( not thin ) : #NEWLINE# #INDENT# if ( ( ( y + sy ) >= py ) and ( ( ( y + sy ) - py ) < 2 ) ) : #NEWLINE# #INDENT# next_chars [ 0 ] |= ( ( 2 ** ix ) * ( 4 ** ( ( y + sy ) % 2 ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# next_chars [ 1 ] |= ( ( 2 ** ix ) * ( 4 ** ( ( y + sy ) % 2 ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# err -= ( 2 * dy ) #NEWLINE# if ( err < 0 ) : #NEWLINE# #INDENT# y += sy #NEWLINE# err += ( 2 * dx ) #NEWLINE# #UNINDENT# x += sx #NEWLINE# #UNINDENT# if ( char is None ) : #NEWLINE# #INDENT# self . print_at ( self . _line_chars [ next_chars [ 0 ] ] , ( px // 2 ) , ( py // 2 ) , colour , bg = bg ) #NEWLINE# if ( next_chars [ 1 ] != 0 ) : #NEWLINE# #INDENT# self . print_at ( self . _line_chars [ next_chars [ 1 ] ] , ( px // 2 ) , ( ( py // 2 ) + sy ) , colour , bg = bg ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( char == ' ' ) : #NEWLINE# #INDENT# self . print_at ( char , ( px // 2 ) , ( py // 2 ) , bg = bg ) #NEWLINE# self . print_at ( char , ( px // 2 ) , ( ( py // 2 ) + sy ) , bg = bg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . print_at ( char , ( px // 2 ) , ( py // 2 ) , colour , bg = bg ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# err = dy #NEWLINE# while ( y != y1 ) : #NEWLINE# #INDENT# next_chars = [ 0 , 0 ] #NEWLINE# px = ( x & ( ~ 1 ) ) #NEWLINE# py = ( y & ( ~ 1 ) ) #NEWLINE# for iy in y_range : #NEWLINE# #INDENT# if ( ( x >= px ) and ( ( x - px ) < 2 ) ) : #NEWLINE# #INDENT# next_chars [ 0 ] |= ( ( 2 ** ( x % 2 ) ) * ( 4 ** iy ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# next_chars [ 1 ] |= ( ( 2 ** ( x % 2 ) ) * ( 4 ** iy ) ) #NEWLINE# #UNINDENT# if ( not thin ) : #NEWLINE# #INDENT# if ( ( ( x + sx ) >= px ) and ( ( ( x + sx ) - px ) < 2 ) ) : #NEWLINE# #INDENT# next_chars [ 0 ] |= ( ( 2 ** ( ( x + sx ) % 2 ) ) * ( 4 ** self ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# next_chars [ 1 ] |= ( ( 2 ** ( ( x + sx ) % 2 ) ) * ( 4 ** iy ) ) #NEWLINE# #UNINDENT# #UNINDENT# err -= ( 2 * dx ) #NEWLINE# if ( err < 0 ) : #NEWLINE# #INDENT# x += sx #NEWLINE# err += ( 2 * dy ) #NEWLINE# #UNINDENT# y += sy #NEWLINE# #UNINDENT# if ( char is None ) : #NEWLINE# #INDENT# self . print_at ( self . _line_chars [ next_chars [ 0 ] ] , ( px // 2 ) , ( py // 2 ) , colour , bg = bg ) #NEWLINE# if ( next_chars [ 1 ] != 0 ) : #NEWLINE# #INDENT# self . print_at ( self . _line_chars [ next_chars [ 1 ] ] , ( ( px // 2 ) + sx ) , ( py // 2 ) , colour , bg = bg ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( char == ' ' ) : #NEWLINE# #INDENT# self . print_at ( char , ( px // 2 ) , ( py // 2 ) , bg = bg ) #NEWLINE# self . print_at ( char , ( ( px // 2 ) + sx ) , ( py // 2 ) , bg = bg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . print_at ( char , ( px // 2 ) , ( py // 2 ) , colour , bg = bg )