Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def drawRectangle(canvas, rectangle)
- x = rectangle[1]
- y = rectangle[0]
- # draw top
- canvas[rectangle[1]][rectangle[0]] = '*'
- y = y + 1
- while (y <= rectangle[2] - 1)
- canvas[x][y] = '-'
- y = y + 1
- end
- canvas[x][y] = '*'
- y = rectangle[1]
- x = x + 1
- # draw left side
- if rectangle[3] - rectangle[1] != 1 then
- while (x <= rectangle[3] - 1)
- canvas[x][y] = '|'
- x = x + 1
- end
- # draw right side
- x = rectangle[0] + 1
- y = rectangle[2]
- while (x <= rectangle[3] - 1)
- canvas[x][y] = '|'
- x = x + 1
- end
- end
- # draw bottom
- canvas[rectangle[3]][rectangle[0]] = '*'
- x = rectangle[3]
- y = rectangle[0]
- y = y + 1
- while (y <= rectangle[2] - 1)
- canvas[x][y] = '-'
- y = y + 1
- end
- canvas[x][y] = '*'
- return canvas
- end
Advertisement
Add Comment
Please, Sign In to add comment