예제 #1
0
    def append(self,
               text,
               family='Sans',
               size=16,
               bold=False,
               italic=False,
               color=(0.0, 0.0, 0.0, 1.0),
               lineheight=1.25,
               translate=(0, 0),
               scale=1.0,
               rotate=0.0,
               tight_bbox=True,
               anchor_x='left',
               anchor_y='baseline',
               filename='./Vera.ttf'):

        font = self.font_manager.get(filename, size)
        n = len(text)
        V = self.bake(text,
                      font,
                      anchor_x,
                      anchor_y,
                      lineheight,
                      tight_bbox=True)
        I = np.resize(np.array([0, 1, 2, 0, 2, 3], dtype=np.uint32),
                      n * (2 * 3))
        I += np.repeat(4 * np.arange(n), 6)
        U = np.zeros(1, self.utype)
        U['color'] = color
        U['translate'] = translate
        U['scale'] = scale
        U['rotate'] = rotate
        Collection.append(self, V, I, U)
예제 #2
0
    def append( self, vertices, closed=False, color = (0,0,0,1),
                linewidth = 1.0, antialias = 1.0, linejoin = 'round', miter_limit = 4.0,
                translate = (0,0), scale = 1.0, rotate = 0.0, linecaps = ('round','round'),
                dash_pattern='solid', dash_phase = 0.0, dash_caps = ('round','round') ):
        V,I,length = self.bake( vertices, closed=closed )
        U = np.zeros(1, self.utype)

        if closed:
            U['closed']  = 1.0
        U['linewidth']   = linewidth
        U['antialias']   = antialias
        U['color']       = color
        U['translate']   = translate
        U['scale']       = scale
        U['rotate']      = rotate
        U['linejoin']    = self.join.get(linejoin, 'round')
        U['linecaps']    = ( self.caps.get(linecaps[0], 'round'),
                             self.caps.get(linecaps[1], 'round') )
        U['miter_limit'] = miter_limit
        U['length']      = length
        if self.dash_atlas:
            dash_index, dash_period = self.dash_atlas[dash_pattern]
            U['dash_phase']  = dash_phase
            U['dash_index']  = dash_index
            U['dash_period'] = dash_period
            U['dash_caps']   = ( self.caps.get(dash_caps[0], 'round'),
                                 self.caps.get(dash_caps[1], 'round') )
        Collection.append(self,V,I,U)
예제 #3
0
 def append(self,
            vertices,
            color=(0, 0, 0, 1),
            linewidth=1.0,
            antialias=1.0,
            translate=(0, 0),
            scale=1.0,
            rotate=0.0,
            linecaps=('round', 'round'),
            dash_pattern='solid',
            dash_phase=0.0,
            dash_caps=('round', 'round')):
     V, I = self.bake(vertices)
     U = np.zeros(1, self.utype)
     U['linewidth'] = linewidth
     U['antialias'] = antialias
     U['color'] = color
     U['translate'] = translate
     U['scale'] = scale
     U['rotate'] = rotate
     U['linecaps'] = (self.caps.get(linecaps[0], 'round'),
                      self.caps.get(linecaps[1], 'round'))
     if self.dash_atlas:
         dash_index, dash_period = self.dash_atlas[dash_pattern]
         U['dash_phase'] = dash_phase
         U['dash_index'] = dash_index
         U['dash_period'] = dash_period
         U['dash_caps'] = (self.caps.get(dash_caps[0], 'round'),
                           self.caps.get(dash_caps[1], 'round'))
     Collection.append(self, V, I, U)
예제 #4
0
    def append( self, text,
                family='Sans', size=16, bold=False, italic=False,
                color=(0.0, 0.0, 0.0, 1.0), lineheight = 1.25,
                translate=(0,0), scale = 1.0, rotate = 0.0, tight_bbox=True,
                anchor_x='left', anchor_y='baseline', filename='./Vera.ttf'):

        font = self.font_manager.get(filename, size)
        n = len(text)
        V = self.bake(text, font, anchor_x, anchor_y, lineheight, tight_bbox=True)
        I = np.resize( np.array([0,1,2,0,2,3], dtype=np.uint32), n*(2*3))
        I += np.repeat( 4*np.arange(n), 6)
        U = np.zeros(1, self.utype)
        U['color']       = color
        U['translate']   = translate
        U['scale']       = scale
        U['rotate']      = rotate
        Collection.append(self,V,I,U)
예제 #5
0
    def append(self,
               vertices,
               closed=False,
               color=(0, 0, 0, 1),
               linewidth=1.0,
               antialias=1.0,
               linejoin='round',
               miter_limit=4.0,
               translate=(0, 0),
               scale=1.0,
               rotate=0.0,
               linecaps=('round', 'round'),
               dash_pattern='solid',
               dash_phase=0.0,
               dash_caps=('round', 'round')):
        V, I, length = self.bake(vertices, closed=closed)
        U = np.zeros(1, self.utype)

        if closed:
            U['closed'] = 1.0
        U['linewidth'] = linewidth
        U['antialias'] = antialias
        U['color'] = color
        U['translate'] = translate
        U['scale'] = scale
        U['rotate'] = rotate
        U['linejoin'] = self.join.get(linejoin, 'round')
        U['linecaps'] = (self.caps.get(linecaps[0], 'round'),
                         self.caps.get(linecaps[1], 'round'))
        U['miter_limit'] = miter_limit
        U['length'] = length
        if self.dash_atlas:
            dash_index, dash_period = self.dash_atlas[dash_pattern]
            U['dash_phase'] = dash_phase
            U['dash_index'] = dash_index
            U['dash_period'] = dash_period
            U['dash_caps'] = (self.caps.get(dash_caps[0], 'round'),
                              self.caps.get(dash_caps[1], 'round'))
        Collection.append(self, V, I, U)
예제 #6
0
 def append( self, vertices, color = (0,0,0,1),
             linewidth = 1.0, antialias = 1.0,
             translate = (0,0), scale = 1.0, rotate = 0.0, linecaps = ('round','round'),
             dash_pattern='solid', dash_phase = 0.0, dash_caps = ('round','round') ):
     V,I = self.bake( vertices )
     U = np.zeros(1, self.utype)
     U['linewidth']   = linewidth
     U['antialias']   = antialias
     U['color']       = color
     U['translate']   = translate
     U['scale']       = scale
     U['rotate']      = rotate
     U['linecaps']    = ( self.caps.get(linecaps[0], 'round'),
                          self.caps.get(linecaps[1], 'round') )
     if self.dash_atlas:
         dash_index, dash_period = self.dash_atlas[dash_pattern]
         U['dash_phase']  = dash_phase
         U['dash_index']  = dash_index
         U['dash_period'] = dash_period
         U['dash_caps']   = ( self.caps.get(dash_caps[0], 'round'),
                              self.caps.get(dash_caps[1], 'round') )
     Collection.append(self,V,I,U)