parameters: (horizontal_offset, vertical_offset,
                         horizontal_justification, vertical_justification,
                         canvas_size, image_size)
return_statement: return horizontal_offset + horizontal_delta, \
          vertical_offset + vertical_delta
docstring: Calculate location based on offset and justification. Offsets
      can be positive and negative.
  
      :param horizontal_offset: horizontal offset
      :type horizontal_offset: int
      :param vertical_offset: vertical offset
      :type vertical_offset: int
      :param horizontal_justification: ``'Left'``, ``'Middle'``, ``'Right'``
      :type horizontal_justification: string
      :param vertical_justification: ``'Top'``, ``'Middle'``, ``'Bottom'``
      :type vertical_justification: string
      :param canvas_size: size of the total canvas
      :type canvas_size: tuple of int
      :param image_size: size of the image/text which needs to be placed
      :type image_size: tuple of int
      :returns: location
      :rtype: tuple of int
  
      .. see also:: :func:`generate layer`
  
      >>> calculate_location(50, 50, 'Left', 'Middle', (100,100), (10,10))
      (50, 45)
docstring_summary: Calculate location based on offset and justification. Offsets
      can be positive and negative.
docstring_tokens: Calculate location based on offset and justification . Offsets can be positive and negative .
function: def calculate_location(horizontal_offset, vertical_offset,
                         horizontal_justification, vertical_justification,
                         canvas_size, image_size):
      """Calculate location based on offset and justification. Offsets
      can be positive and negative.
  
      :param horizontal_offset: horizontal offset
      :type horizontal_offset: int
      :param vertical_offset: vertical offset
      :type vertical_offset: int
      :param horizontal_justification: ``'Left'``, ``'Middle'``, ``'Right'``
      :type horizontal_justification: string
      :param vertical_justification: ``'Top'``, ``'Middle'``, ``'Bottom'``
      :type vertical_justification: string
      :param canvas_size: size of the total canvas
      :type canvas_size: tuple of int
      :param image_size: size of the image/text which needs to be placed
      :type image_size: tuple of int
      :returns: location
      :rtype: tuple of int
  
      .. see also:: :func:`generate layer`
  
      >>> calculate_location(50, 50, 'Left', 'Middle', (100,100), (10,10))
      (50, 45)
      """
      canvas_width, canvas_height = canvas_size
      image_width, image_height = image_size
  
      # check offsets
      if horizontal_offset < 0:
          horizontal_offset += canvas_width
      if vertical_offset < 0:
          vertical_offset += canvas_height
  
      # check justifications
      if horizontal_justification == 'Left':
          horizontal_delta = 0
      elif horizontal_justification == 'Middle':
          horizontal_delta = -image_width / 2
      elif horizontal_justification == 'Right':
          horizontal_delta = -image_width
  
      if vertical_justification == 'Top':
          vertical_delta = 0
      elif vertical_justification == 'Middle':
          vertical_delta = -image_height / 2
      elif vertical_justification == 'Bottom':
          vertical_delta = -image_height
  
      return horizontal_offset + horizontal_delta, \
          vertical_offset + vertical_delta
function_tokens: def calculate_location ( horizontal_offset , vertical_offset , horizontal_justification , vertical_justification , canvas_size , image_size ) : canvas_width , canvas_height = canvas_size image_width , image_height = image_size # check offsets if horizontal_offset < 0 : horizontal_offset += canvas_width if vertical_offset < 0 : vertical_offset += canvas_height # check justifications if horizontal_justification == 'Left' : horizontal_delta = 0 elif horizontal_justification == 'Middle' : horizontal_delta = - image_width / 2 elif horizontal_justification == 'Right' : horizontal_delta = - image_width if vertical_justification == 'Top' : vertical_delta = 0 elif vertical_justification == 'Middle' : vertical_delta = - image_height / 2 elif vertical_justification == 'Bottom' : vertical_delta = - image_height return horizontal_offset + horizontal_delta , vertical_offset + vertical_delta