Ejemplo n.º 1
0
 def draw(self):
   ww, wh = 2000, 2000
   GL.glPushMatrix()
   self.transform()
   GL.glPushAttrib(GL.GL_CURRENT_BIT)
   GL.glBegin(GL.GL_QUADS)
   GL.glColor4ubv(self.fade_color)
   map(GL.glVertex2fv, [(-ww, -wh), (ww, -wh), (ww, wh), (-ww, wh)])
   GL.glEnd()
   GL.glPopAttrib()
   GL.glPopMatrix()
   super(ModalWindow, self).draw()
Ejemplo n.º 2
0
 def _Border__draw(self):
   if not self.__vertices:
     return
   
   GL.glPushAttrib(GL.GL_CURRENT_BIT | GL.GL_ENABLE_BIT)
   GL.glPushClientAttrib(GL.GL_CLIENT_ALL_ATTRIB_BITS)
   
   GL.glColor4ubv(self.__color)
   GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
   GL.glVertexPointer(2, GL.GL_FLOAT, 0, self.__vertices)
   GL.glDrawArrays(GL.GL_QUADS, 0, self.__vertices_count)
   
   GL.glPopClientAttrib()
   GL.glPopAttrib()
Ejemplo n.º 3
0
 def draw(self): # TODO move to `rendering.py`
   node = self.node
   # WARNING using background-origin here, but
   # it won't work for `initial` and `inherit`
   x, y, w, h = getattr(node, self.origin.replace('-', '_'))
   l, t, r, b = x, y, x + w, y + h
   color = Color(self.color)
   from OpenGL import GL
   if not color.is_transparent():
     GL.glPushAttrib(GL.GL_CURRENT_BIT)
     GL.glColor4ubv(color)
     GL.glBegin(GL.GL_QUADS)
     vertices = [(l, t), (l, b), (r, b), (r, t)]
     map(GL.glVertex2fv, vertices)
     GL.glEnd()
     GL.glPopAttrib()
   if self.image == 'none':
     return
   iw, ih = self.image.width, self.image.height
   size = self.size
   if size == 'auto':
     tile_size = iw, ih
   elif size == 'cover':
     scale = max(w / float(iw), h / float(ih))
     tile_size = int(iw * scale), int(ih * scale)
   elif size == 'contain':
     scale = min(w / float(iw), h / float(ih))
     tile_size = int(iw * scale), int(ih * scale)
   elif isinstance(size, (int, float, tuple)):
     if isinstance(size, (int, float)):
       mw = mh = size
     else:
       mw, mh = size
     if isinstance(mw, int) and isinstance(mh, int):
       pass
     elif isinstance(mw, float) and isinstance(mh, float): # TODO percent class
       mw = int(iw * (mw * 0.01))
       mh = int(ih * (mh * 0.01))
     else:
       raise ValueError(
         'Invalid value for background-size: %r' % size
       )
     tile_size = mw, mh
   
   repeat = self.repeat
   if repeat == 'repeat':
     bg_size = w, h
   elif repeat == 'repeat-x':
     bg_size = w, tile_size[1]
   elif repeat == 'repeat-y':
     bg_size = tile_size[0], h
   elif repeat == 'no-repeat':
     bg_size = tile_size
   else:
     raise ValueError(
       'Invalid value for background-repeat: %r' % repeat
     )
   
   # TODO: implement background-position, background-clip
   texture = self.image.get_texture()
   tilew, tileh = tile_size
   bgw, bgh = bg_size
   
   texturing.tile(texture, (l, t, bgw, bgh), tile_size)