Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def drawLine(self, x1, y1, x2, y2, aamode = 0):
- ''' Draws a line between the points *(x1, y1)* and *(x2, y2)* in the
- current pen-color. *aamode* defines the use of anti-aliasing.
- .. note:: Anti-aliasing is not implemented yet. '''
- if x2 < x1:
- x1, x2 = x2, x1
- # 1. we need to calculate the slope of the line, remember the good old
- # linear-function formula from maths: f(x) = mx + t
- slope = (y2 - y1) / (x2 - x1)
- # 2. we will now iterate over the full length of the line in x-direction
- # and calculate the corresponding y-value
- for x in xrange(x2 - x1):
- y = slope * x + y1
- x = x + x1
- self.setPixel(x, y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement