Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import division
- def setup():
- size(400,400)
- background(255)
- def draw():
- background(255)
- cline([0,20],[100,21])
- def cline(a,b):
- a = list(a)
- b = list(b)
- if a[0] > b[0]: a[0], b[0] = b[0], a[0]
- if a[1] > b[1]: a[1], b[1] = b[1], a[1]
- if a == b: point(a[0], a[1])
- elif a[0] == b[0]:
- for y in range(a[1], b[1]+1): point(a[0], y)
- elif a[1] == b[1]:
- for x in range(a[0], b[0]+1): point(x, a[1])
- else:
- vdif = (b[1]-a[1])/(b[0]-a[0])
- y = a[0]
- for x in range(a[0], b[0]+1):
- point(x,y)
- y += vdif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement