コード例 #1
0
 def draw_background(self, notification):
     s = notification['scale']
     g1 = notification['glyph']
     # get colors
     _mark_color = self.w.mark_color.get()
     _mark_color = (
         _mark_color.redComponent(),
         _mark_color.greenComponent(),
         _mark_color.blueComponent(),
         _mark_color.alphaComponent(),
     )
     _mark_color_2 = self.w.mark_color_2.get()
     _mark_color_2 = (
         _mark_color_2.redComponent(),
         _mark_color_2.greenComponent(),
         _mark_color_2.blueComponent(),
         _mark_color_2.alphaComponent(),
     )
     # get fonts
     f1 = CurrentFont()
     i = self.w.f2.get()
     f2 = self.all_fonts[sorted(self.all_fonts.keys())[i]]
     r = 2
     # interpolate steps
     if f1 != f2:
         # check if f2 has this glyph
         if f2.has_key(g1.name):
             g2 = f2[g1.name]
             # check if glyph in f2 is compatible
             if g1.isCompatible(g2):
                 # create colors
                 c1 = Color.NewFromRgb(*_mark_color)
                 c2 = Color.NewFromRgb(*_mark_color_2)
                 colors = c1.Gradient(c2, self.steps)
                 # create steps and draw
                 for i in range(self.steps):
                     factor = i * (1.0 / (self.steps - 1))
                     g3 = RGlyph()
                     g3.interpolate(factor, g1, g2)
                     save()
                     fill(None)
                     stroke(*colors[i])
                     strokeWidth(s)
                     if g3.width != g1.width:
                         diff = g3.width - g1.width
                         translate(-diff * 0.5, 0)
                     drawGlyph(g3)
                     for c in g3.contours:
                         for pt in c.points:
                             rect(pt.x - r, pt.y - r, r * 2, r * 2)
                     restore()
                 # done
                 # restore()
         else:
             if self.verbose:
                 print '%s not in font 2' % g1.name
コード例 #2
0
 def draw_background(self, notification):
     s  = notification['scale']
     g1 = notification['glyph']
     # get colors
     _mark_color = self.w.mark_color.get()
     _mark_color = (
         _mark_color.redComponent(),
         _mark_color.greenComponent(),
         _mark_color.blueComponent(),
         _mark_color.alphaComponent(),
     )
     _mark_color_2 = self.w.mark_color_2.get()
     _mark_color_2 = (
         _mark_color_2.redComponent(),
         _mark_color_2.greenComponent(),
         _mark_color_2.blueComponent(),
         _mark_color_2.alphaComponent(),
     )
     # get fonts
     f1 = CurrentFont()
     i  = self.w.f2.get()
     f2 = self.all_fonts[sorted(self.all_fonts.keys())[i]]
     r = 2
     # interpolate steps
     if f1 != f2:
         # check if f2 has this glyph
         if f2.has_key(g1.name):
             g2 = f2[g1.name]
             # check if glyph in f2 is compatible
             if g1.isCompatible(g2):
                 # create colors
                 c1 = Color.NewFromRgb(*_mark_color)
                 c2 = Color.NewFromRgb(*_mark_color_2)
                 colors = c1.Gradient(c2, self.steps)
                 # create steps and draw
                 for i in range(self.steps):
                     factor = i * (1.0 / (self.steps-1))
                     g3 = RGlyph()
                     g3.interpolate(factor, g1, g2)
                     save()
                     fill(None)
                     stroke(*colors[i])
                     strokeWidth(s)
                     if g3.width != g1.width:
                         diff = g3.width - g1.width
                         translate(-diff*0.5, 0)
                     drawGlyph(g3)
                     for c in g3.contours:
                         for pt in c.points:
                             rect(pt.x-r, pt.y-r, r*2, r*2)
                     restore()
                 # done
                 # restore()
         else:
             if self.verbose:
                 print '%s not in font 2' % g1.name