Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pict = makeEmptyPicture(500,500,white)
- color = makeColor(pickAColor())
- def drawStairs(pict,a,b,c,d,color):
- #@param:
- # pict: picture;
- # a: initial width;
- # b: initial height;
- # c: horizontal component lenth;
- # d: vertical component lenth;
- # color: stairs color;
- width = getWidth(pict)
- height = getHeight(pict)
- for i in range(a,width,c):
- drawHorizontalLineGen(pict,a,b,c,color)
- a = a+c
- drawVerticalLineGen(pict,a,b,d,color)
- b = b+d
- repaint(pict)
- def drawHorizontalLineGen(pict,x,y,w,color):
- # @param:
- # x: int, starting point on x axis;
- # y: int, starting point on y axis;
- # w: int, lenght of the line
- for x in range(x,min(x+w,getWidth(pict))):
- setColor(getPixel(pict,x,min(-1+getHeight(pict),y)),color)
- def drawVerticalLineGen(pict,x,y,w,color):
- # @param:
- # x: int, starting point on x axis;
- # y: int, starting point on y axis;
- # w: int, lenght of the line
- for y in range(y,min(y+w,getHeight(pict))):
- setColor(getPixel(pict,min(x,(-1+getWidth(pict))),y),color)
- #------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement