# Path: ui/render/gl/colors.py
# def productPairsColor(i):
# def exponentialColor(isAlways):
# 
# Path: ui/render/gl/distances.py
# def capLengthOfDividerByLength(length):
# 
# Path: ui/stack/gl.py
# def newGLStack(widths, render):
#   return stack.Stack(widths, GLBackend(render))
# 
# def newTextualGLStack(color, string):
#   widths = [0 for i in range(3)]
#   for x in string:
#     widths[0] += glutStrokeWidth(GLUT_STROKE_ROMAN, ord(x))
#   widths[1] = max_GLUT_STROKE_ROMAN_height
#   def render():
#     color.render()
#     glPushMatrix()
#     for c in string:
#       glutStrokeCharacter(GLUT_STROKE_ROMAN, ord(c))
#     glPopMatrix()
#   return newGLStack(widths, render)
# 
# Path: ui/stack/point.py
# class Point:
#   def __init__(self, x, y, z = 0.0):
#     self._x = x
#     self._y = y
#     self._z = z
# 
#   def transpose(self):
#     return Point(x = self._y, y = self._x, z = self._z)
# 
#   def translate(self, dimension, amount):
#     if dimension == 0:
#       return Point(x = self._x + amount, y = self._y, z = self._z)
#     else:
#       assert(dimension == 1)
#       return Point(x = self._x, y = self._y + amount, z = self._z)
# 
#   def render(self):
#     glVertex(self._x, self._y, self._z)


from OpenGL.GL import *
from ui.render.gl import colors, distances
from ui.stack.gl import newGLStack, newTextualGLStack
from ui.stack.point import Point

# always: a boolean, True for always, false for Maybe.
# widths: a list of the widths of the box.
# return: a gl stack representing the background for an exponential.
#
# c----------------b
# |                |
# d----------------a
#
def empty():
  return newGLStack([0.0, 0.0, 0.0], lambda: None)

def solidSquare(color, widths):
  d = Point(0.0, 0.0, 0.0)
  a = d.translate(0, widths[0])
  c = d.translate(1, widths[1])
  b = a.translate(1, widths[1])
  def render():
    color.render()
    glBegin(GL_TRIANGLE_FAN)
    for point in [a, b, c, d]:
      point.render()
    glEnd()
  return newGLStack(widths, render)

def divider(color, dimension, length, width, capLength):
  widths = [0 for i in range(3)]
  tDimension = _dual_dimension(dimension)
  widths[dimension] = width
  widths[tDimension] = length

# Path: ui/render/gl/colors.py
# def productPairsColor(i):
# def exponentialColor(isAlways):
# 
# Path: ui/render/gl/distances.py
# def capLengthOfDividerByLength(length):
# 
# Path: ui/stack/gl.py
# def newGLStack(widths, render):
#   return stack.Stack(widths, GLBackend(render))
# 
# def newTextualGLStack(color, string):
#   widths = [0 for i in range(3)]
#   for x in string:
#     widths[0] += glutStrokeWidth(GLUT_STROKE_ROMAN, ord(x))
#   widths[1] = max_GLUT_STROKE_ROMAN_height
#   def render():
#     color.render()
#     glPushMatrix()
#     for c in string:
#       glutStrokeCharacter(GLUT_STROKE_ROMAN, ord(c))
#     glPopMatrix()
#   return newGLStack(widths, render)
# 
# Path: ui/stack/point.py
# class Point:
#   def __init__(self, x, y, z = 0.0):
#     self._x = x
#     self._y = y
#     self._z = z
# 
#   def transpose(self):
#     return Point(x = self._y, y = self._x, z = self._z)
# 
#   def translate(self, dimension, amount):
#     if dimension == 0:
#       return Point(x = self._x + amount, y = self._y, z = self._z)
#     else:
#       assert(dimension == 1)
#       return Point(x = self._x, y = self._y + amount, z = self._z)
# 
#   def render(self):
#     glVertex(self._x, self._y, self._z)


# Path: ui/render/gl/primitives.py
from OpenGL.GL import *
from ui.render.gl import colors, distances
from ui.stack.gl import newGLStack, newTextualGLStack
from ui.stack.point import Point


# always: a boolean, True for always, false for Maybe.
# widths: a list of the widths of the box.
# return: a gl stack representing the background for an exponential.
#
# c----------------b
# |                |
# d----------------a
#
def empty():
  return newGLStack([0.0, 0.0, 0.0], lambda: None)

def solidSquare(color, widths):
  d = Point(0.0, 0.0, 0.0)
  a = d.translate(0, widths[0])
  c = d.translate(1, widths[1])
  b = a.translate(1, widths[1])
  def render():
    color.render()
    glBegin(GL_TRIANGLE_FAN)
    for point in [a, b, c, d]:
      point.render()
    glEnd()
  return newGLStack(widths, render)

def divider(color, dimension, length, width, capLength):
  widths = [0 for i in range(3)]
  tDimension = _dual_dimension(dimension)
  widths[dimension] = width
  widths[tDimension] = length

  z = Point(0.0, 0.0)