Пример #1
0
 def _calculateCapData(self, scale=400.0):
     """Calculate the tessellated data-sets for this glyph"""
     vertices = [[
         vertex.Vertex(point=(x / scale, y / scale, 0.0))
         for (x, y) in outline
     ] for outline in self.outlines]
     gluTessNormal(self.tess.controller, 0, 0, 1.0)
     contours = self.tess.tessContours(vertices, forceTriangles=0)
     return [(t, asarray([v.point for v in vertices], 'd'))
             for t, vertices in contours]
Пример #2
0
 def renderCap(self, scale=400.0):
     """The cap is generated with GLU tessellation routines...
     """
     vertices = [
         vertex.Vertex((x / scale, y / scale, 0)) for (x, y) in outline[::2]
     ]
     vertices.reverse()
     for type, vertices in self.tess.tessellate(vertices, forceTriangles=0):
         glNormal(0, 0, -1)
         glColor3f(1, 0, 0)
         glBegin(type)
         for v in vertices:
             glVertex2dv(v.point[:2])
         glEnd()
Пример #3
0
    def polygons(self, sources=None):
        """Yield each polygon in the IFS

        The polygon object is a sub-class of list holding
        Vertex objects.
        """
        if sources is None:
            sources = self.buildIndexedSources()
        current = []
        metaIndex = -1
        polygonIndex = 0
        coordIndices = self.target.coordIndex
        points = getXNull(self.target.coord, 'point')
        for metaIndex in xrange(len(coordIndices)):
            point = coordIndices[metaIndex]
            if point >= 0:
                if point >= len(coordIndices):
                    log.info(
                        """Coordindex of node %s declares index %s at meta-index %s, beyond end of coordinate set (len %s), ignoring""",
                        self.target, point, metaIndex, len(coordIndices))
                    continue
                set = dict([(s.vertexAttribute, s(metaIndex, polygonIndex)[0])
                            for s in sources[1:]])
                set['indexKey'] = tuple(
                    [s.vertexIndex(metaIndex, polygonIndex) for s in sources])
                current.append(
                    vertex.Vertex(point=points[point],
                                  metaIndex=metaIndex,
                                  coordIndex=point,
                                  **set))
            else:
                yield polygon.Polygon(
                    polygonIndex,
                    self.target,
                    current,
                    ccw=self.target.ccw,
                )
                polygonIndex += 1
                current = []
        if current:
            yield polygon.Polygon(polygonIndex,
                                  self.target,
                                  current,
                                  ccw=self.target.ccw)