Advertisement
Guest User

Untitled

a guest
May 12th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. from __future__ import division
  2.  
  3. def setup():
  4.     size(400,400)
  5.     background(255)
  6.    
  7. def draw():
  8.     background(255)
  9.     cline([0,20],[100,21])
  10.  
  11. def cline(a,b):    
  12.     a = list(a)
  13.     b = list(b)
  14.     if a[0] > b[0]: a[0], b[0] = b[0], a[0]
  15.     if a[1] > b[1]: a[1], b[1] = b[1], a[1]
  16.    
  17.     if a == b: point(a[0], a[1])
  18.     elif a[0] == b[0]:
  19.         for y in range(a[1], b[1]+1): point(a[0], y)
  20.     elif a[1] == b[1]:
  21.         for x in range(a[0], b[0]+1): point(x, a[1])
  22.     else:
  23.         vdif = (b[1]-a[1])/(b[0]-a[0])
  24.         y = a[0]
  25.         for x in range(a[0], b[0]+1):
  26.             point(x,y)
  27.             y += vdif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement