Ejemplo n.º 1
0
def set_scissor( rect ):
    """Calls glScissor with the size of the rectangle.

    .. note:: It is up to the user to call glEnable(GL_SCISSOR_TEST).

    .. note:: To undo this, call this function again with the window's size as a rectangle.

    .. seealso::
        Module :py:mod:`pygly.window`
          Documentation of the :py:mod:`pygly.window` module.

    This call can be undone by first calling
    glPushAttrib( GL_SCISSOR_BIT )
    and later calling glPopAttrib().

    Or using the attribute context:
    with attributes( GL_SCISSOR_BIT ):
        set_scissor( rect )
    """
    GL.glScissor(
        int(rectangle.left(rect)),
        int(rectangle.bottom(rect)),
        int(rectangle.abs_width(rect)),
        int(rectangle.abs_height(rect))
        )
Ejemplo n.º 2
0
def aspect_ratio(rect):
    """Calculates the aspect ratio of the rectangle.

    Aspect ratio is the ratio of width to height
    a value of 2.0 means width is 2*height

    The rectangle is in the format of Pyrr.rectangle.

    Returns:
        The aspect ratio of the rectangle.
    """
    width = float(rectangle.abs_width(rect))
    height = float(rectangle.abs_height(rect))
    return width / height
Ejemplo n.º 3
0
def aspect_ratio( rect ):
    """Calculates the aspect ratio of the rectangle.

    Aspect ratio is the ratio of width to height
    a value of 2.0 means width is 2*height

    The rectangle is in the format of Pyrr.rectangle.

    Returns:
        The aspect ratio of the rectangle.
    """
    width = float(rectangle.abs_width(rect))
    height = float(rectangle.abs_height(rect))
    return width / height
Ejemplo n.º 4
0
def set_viewport(rect):
    """Calls glViewport with the dimensions of
    the rectangle

    In the OpenGL Legacy profile (<=2.1),
    this call can be undone by first calling
    glPushAttrib( GL_VIEWPORT_BIT )
    and later calling glPopAttrib().
    Or: using the attribute context:
    with attributes( GL_VIEWPORT_BIT ):
        set_viewport( rect )

    The glPushAttrib / glPopAttrib functions are not available on the
    OpenGL Core profile (>=3.0)
    """
    GL.glViewport(int(rectangle.left(rect)), int(rectangle.bottom(rect)),
                  int(rectangle.abs_width(rect)),
                  int(rectangle.abs_height(rect)))
Ejemplo n.º 5
0
def set_viewport( rect ):
    """Calls glViewport with the dimensions of
    the rectangle

    In the OpenGL Legacy profile (<=2.1),
    this call can be undone by first calling
    glPushAttrib( GL_VIEWPORT_BIT )
    and later calling glPopAttrib().
    Or: using the attribute context:
    with attributes( GL_VIEWPORT_BIT ):
        set_viewport( rect )

    The glPushAttrib / glPopAttrib functions are not available on the
    OpenGL Core profile (>=3.0)
    """
    GL.glViewport(
        int(rectangle.left(rect)),
        int(rectangle.bottom(rect)),
        int(rectangle.abs_width(rect)),
        int(rectangle.abs_height(rect))
        )
Ejemplo n.º 6
0
def set_scissor(rect):
    """Calls glScissor with the size of the rectangle.

    .. note:: It is up to the user to call glEnable(GL_SCISSOR_TEST).

    .. note:: To undo this, call this function again with the window's size as a rectangle.

    .. seealso::
        Module :py:mod:`pygly.window`
          Documentation of the :py:mod:`pygly.window` module.

    This call can be undone by first calling
    glPushAttrib( GL_SCISSOR_BIT )
    and later calling glPopAttrib().

    Or using the attribute context:
    with attributes( GL_SCISSOR_BIT ):
        set_scissor( rect )
    """
    GL.glScissor(int(rectangle.left(rect)), int(rectangle.bottom(rect)),
                 int(rectangle.abs_width(rect)),
                 int(rectangle.abs_height(rect)))
Ejemplo n.º 7
0
 def test_abs_width_negative(self):
     result = rectangle.abs_width([[1.,2.],[-3.,-4.]])
     np.testing.assert_almost_equal(result, 3., decimal=5)
Ejemplo n.º 8
0
 def test_abs_width_negative(self):
     result = rectangle.abs_width([[1.,2.],[-3.,-4.]])
     np.testing.assert_almost_equal(result, 3., decimal=5)