Advertisement
davide1409

diag45_V1

Dec 23rd, 2019
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. def diag45(pict,x,y,c):
  2. #@param pict: Picture
  3. #@param x: int
  4. #@param y: int
  5. #@param c: color
  6.  
  7.   w,h = getWidth(pict)-1, getHeight(pict)-1
  8.   if x<0 or x>=w or y<0 or y>=h:
  9.     return
  10.  
  11.   else:
  12.     diffx = w-x
  13.     diffy = h-y
  14.     x1 = w
  15.     y1 = h
  16.     if diffy>diffx:
  17.       y1 -= (diffy-diffx)
  18.  
  19.     elif diffx>diffy:
  20.       x1 -= (diffx-diffy)
  21.  
  22.     else:
  23.       pass
  24.    
  25.  
  26.   addLine(pict,x,y,x1,y1,c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement