def ensure_position(rect)
      # no place in current row -> go to next row
      if cur_x + rect.width > canvas.width
        @cur_x = 0
        @cur_y += row_height
        @row_height = 0
      end

      # no place in current canvas -> restart canvas
      restart_canvas! if cur_y + rect.height > canvas.height
    end
def ensure_position(rect)
      # no place in current row -> go to next row
      if cur_x + rect.width > canvas.width
        @cur_x = 0
        @cur_y += row_height
        @row_height = 0
      end

      # no place in current canvas -> restart canvas
      restart_canvas! if cur_y + rect.height > canvas.height
    end
ensure this rect can be drawn at current position
 or shift position of it can't