Advertisement
MaxDvc

drawStairs

Oct 23rd, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. pict = makeEmptyPicture(500,500,white)
  2. color = makeColor(pickAColor())
  3.  
  4. def drawStairs(pict,a,b,c,d,color):
  5. #@param:
  6. #  pict: picture;
  7. #  a: initial width;
  8. #  b: initial height;
  9. #  c: horizontal component lenth;
  10. #  d: vertical component lenth;
  11. #  color: stairs color;
  12.   width = getWidth(pict)
  13.   height = getHeight(pict)
  14.   for i in range(a,width,c):
  15.     drawHorizontalLineGen(pict,a,b,c,color)
  16.     a = a+c
  17.     drawVerticalLineGen(pict,a,b,d,color)
  18.     b = b+d
  19.     repaint(pict)
  20.  
  21. def drawHorizontalLineGen(pict,x,y,w,color):
  22. # @param:
  23. #  x: int, starting point on x axis;
  24. #  y: int, starting point on y axis;
  25. #  w: int, lenght of the line
  26.   for x in range(x,min(x+w,getWidth(pict))):
  27.     setColor(getPixel(pict,x,min(-1+getHeight(pict),y)),color)
  28.  
  29. def drawVerticalLineGen(pict,x,y,w,color):
  30. # @param:
  31. #  x: int, starting point on x axis;
  32. #  y: int, starting point on y axis;
  33. #  w: int, lenght of the line
  34.  
  35.   for y in range(y,min(y+w,getHeight(pict))):
  36.     setColor(getPixel(pict,min(x,(-1+getWidth(pict))),y),color)
  37. #------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement