# Path: beampy/utils.py
# def bounding_box(element):
#     """
#     Function to add a bounding-box (border + anchors) to the given element.
# 
#     Parameters
#     ----------
# 
#     element : Beampy Module
#         The Beampy module class of the element to add the bounding box
# 
#     """
# 
#     # Add the border
#     element.add_border()
# 
#     # Create rectangles to show anchors of the text box
#     rw, rh = 10, 10
# 
#     anchor_selected = element.positionner.x['anchor'] + element.positionner.y['anchor']
# 
#     corners = [('lefttop', element.left, element.top),
#                ('righttop', element.right, element.top),
#                ('leftbottom', element.left, element.bottom),
#                ('rightbottom', element.right, element.bottom),
#                ('leftmiddle', element.left, element.center),
#                ('middletop', element.center, element.top),
#                ('rightmiddle', element.right, element.center),
#                ('middlebottom', element.center, element.bottom),
#                ('middlemiddle', element.center, element.center)]
# 
#     for args in corners:
#         label, ex, ey = args
#         rc = 'gray'
#         if anchor_selected == label:
#             rc = 'red'
# 
#         rectangle(x=ex + center(0), y=ey + center(0), width=rw, height=rh,
#                   color=rc, edgecolor=None)
# 
# def draw_axes(dx=100, dy=100, show_ticks=False, grid_color='lightgray'):
#     """
#     Function to draw Beampy axis with a grid
#     """
#     
#     grid(dx=dx, dy=dy, color=grid_color)
#     ax=arrow(5, 5, document._width-35, 0)
#     ay=arrow(5, 5, 0, document._height-35)
#     text('$x$', x=ax.right+5, y=ax.top+0)
#     text('$y$', x=ay.left+0, y=ay.bottom+5)
# 
#     if show_ticks:
#         # add the positions in pixels
#         for xt in range(0, document._width, dx):
#             text('$x=%ipx$' % xt, x=xt, y=15, size=10)
# 
#         for yt in range(0, document._height, dx):
#             text('$y=%ipx$' % yt, x=15, y=yt, size=10)


from beampy import *
from beampy.utils import bounding_box, draw_axes
        text('text x=-0, y=+0.5cm', x='-0', y='+0.5cm')

    text('text x=25, y=0.3', x='25', y=0.3)
    for i in range(2):
        text('text x=+0, y=+0.5cm', x='+0', y='+0.5cm')

    text('text x=25, y=0.5', x='25', y=0.5)
    text('text x=+10, y=+0', x='+10', y='+0')
    text('text x=+10, y=-0', x='+10', y='-0')

display_matplotlib(gcs())

#######################################################
#
#Coordinate as dictionary
#------------------------
#
#Coordinate could also be given as dictionary. The dictionary keys are the
#following:
#
#* unit: ('px', 'pt', 'cm', 'width', 'height'), the width of the shift value.
#* shift: float value, the amount of shifting.
#* reference: ('slide' or 'relative') 'relative' is used to make relative
#  positioning.
#* anchor: (top, bottom, left, right, middle) define the anchor position on the
#  module bounding-box.
#* align: (left, right or center for x) and (top, bottom or center for y) is used
#  to set the origin of slide axes.

with slide():

# Path: beampy/utils.py
# def bounding_box(element):
#     """
#     Function to add a bounding-box (border + anchors) to the given element.
# 
#     Parameters
#     ----------
# 
#     element : Beampy Module
#         The Beampy module class of the element to add the bounding box
# 
#     """
# 
#     # Add the border
#     element.add_border()
# 
#     # Create rectangles to show anchors of the text box
#     rw, rh = 10, 10
# 
#     anchor_selected = element.positionner.x['anchor'] + element.positionner.y['anchor']
# 
#     corners = [('lefttop', element.left, element.top),
#                ('righttop', element.right, element.top),
#                ('leftbottom', element.left, element.bottom),
#                ('rightbottom', element.right, element.bottom),
#                ('leftmiddle', element.left, element.center),
#                ('middletop', element.center, element.top),
#                ('rightmiddle', element.right, element.center),
#                ('middlebottom', element.center, element.bottom),
#                ('middlemiddle', element.center, element.center)]
# 
#     for args in corners:
#         label, ex, ey = args
#         rc = 'gray'
#         if anchor_selected == label:
#             rc = 'red'
# 
#         rectangle(x=ex + center(0), y=ey + center(0), width=rw, height=rh,
#                   color=rc, edgecolor=None)
# 
# def draw_axes(dx=100, dy=100, show_ticks=False, grid_color='lightgray'):
#     """
#     Function to draw Beampy axis with a grid
#     """
#     
#     grid(dx=dx, dy=dy, color=grid_color)
#     ax=arrow(5, 5, document._width-35, 0)
#     ay=arrow(5, 5, 0, document._height-35)
#     text('$x$', x=ax.right+5, y=ax.top+0)
#     text('$y$', x=ay.left+0, y=ay.bottom+5)
# 
#     if show_ticks:
#         # add the positions in pixels
#         for xt in range(0, document._width, dx):
#             text('$x=%ipx$' % xt, x=xt, y=15, size=10)
# 
#         for yt in range(0, document._height, dx):
#             text('$y=%ipx$' % yt, x=15, y=yt, size=10)


# Path: doc-src/tutorials/positioning_system.py
from beampy import *
from beampy.utils import bounding_box, draw_axes

        text('text x=-0, y=+0.5cm', x='-0', y='+0.5cm')

    text('text x=25, y=0.3', x='25', y=0.3)
    for i in range(2):
        text('text x=+0, y=+0.5cm', x='+0', y='+0.5cm')

    text('text x=25, y=0.5', x='25', y=0.5)
    text('text x=+10, y=+0', x='+10', y='+0')
    text('text x=+10, y=-0', x='+10', y='-0')

display_matplotlib(gcs())

#######################################################
#
#Coordinate as dictionary
#------------------------
#
#Coordinate could also be given as dictionary. The dictionary keys are the
#following:
#
#* unit: ('px', 'pt', 'cm', 'width', 'height'), the width of the shift value.
#* shift: float value, the amount of shifting.
#* reference: ('slide' or 'relative') 'relative' is used to make relative
#  positioning.
#* anchor: (top, bottom, left, right, middle) define the anchor position on the
#  module bounding-box.
#* align: (left, right or center for x) and (top, bottom or center for y) is used
#  to set the origin of slide axes.

with slide():

    draw_axes()