コード例 #1
0
 def compute_blend(self, start, end):
     steps = self.steps
     blended = []
     for step in range(1, steps):
         fraction = float(step) / steps
         blend = Blend(start, end, fraction)
         blend.SetDocument(self.document)
         blend.SetParent(None)
         blended.append(blend)
     blended.reverse()
     return blended
コード例 #2
0
 def Blend(self, other, frac1, frac2):
     if type(other) == type(self.colors[0][-1]):
         # blend a gradient with a single color
         sc = self.colors
         c = []
         for i in range(len(sc)):
             p1, c1 = sc[i]
             c.append((p1, c1.Blend(other, frac1, frac2)))
         return self.__class__(c)
     elif other.__class__ == self.__class__:
         # blend two MultiGradient instances
         # XXX: improve this...
         length = min(len(self.colors), len(other.colors))
         sc = self.colors[:length - 1]
         sc.append(self.colors[-1])
         oc = other.colors[:length - 1]
         oc.append(other.colors[-1])
         c = []
         for i in range(length):
             p1, c1 = sc[i]
             p2, c2 = oc[i]
             c.append((frac1 * p1 + frac2 * p2, Blend(c1, c2, frac1,
                                                      frac2)))
         return self.__class__(c)
     else:
         raise MismatchError
コード例 #3
0
 def Blend(self, other, frac1, frac2):
     try:
         objs = self.objects
         oobjs = other.objects
         blended = []
         for i in range(min(len(objs), len(oobjs))):
             blended.append(Blend(objs[i], oobjs[i], frac1, frac2))
         return Compound(blended)
     except:
         raise MismatchError
コード例 #4
0
 def Blend(self, other, frac1, frac2):
     if other.__class__ == self.__class__:
         fg = other.foreground
         bg = other.background
         dir = other.direction
         spacing = other.spacing
         width = other.width
     elif other.__class__ == SolidPattern:
         fg = bg = other.Color()
         dir = self.direction
         spacing = self.spacing
         width = self.width
     else:
         raise MismatchError
     return HatchingPattern(Blend(self.foreground, fg, frac1, frac2),
                            Blend(self.background, bg, frac1, frac2),
                            frac1 * self.direction + frac2 * dir,
                            frac1 * self.spacing + frac2 * spacing,
                            frac1 * self.width + frac2 * width)
コード例 #5
0
 def Blend(self, other, frac1, frac2):
     try:
         objs = self.objects
         oobjs = other.objects
         blended = []
         for i in range(min(len(objs), len(oobjs))):
             blended.append(Blend(objs[i], oobjs[i], frac1, frac2))
         return Group(blended)
     except:
         warn_tb(INTERNAL)
         raise MismatchError
コード例 #6
0
 def ColorAt(self, pos):
     colors = self.colors
     for i in range(len(colors) - 1):
         if colors[i][0] <= pos and colors[i + 1][0] >= pos:
             break
     else:
         return self.EndColor()
     start_pos, start_color = colors[i]
     if i < len(colors) - 1:
         end_pos, end_color = colors[i + 1]
     else:
         return start_color
     return Blend(end_color, start_color,
                  (pos - start_pos) / float(end_pos - start_pos))
コード例 #7
0
 def Blend(self, other, frac1, frac2):
     if other.__class__ == self.__class__:
         gradient = other.gradient
         dir = other.direction
         center = other.center
     elif other.__class__ == SolidPattern:
         gradient = other.Color()
         dir = self.direction
         center = self.center
     else:
         raise MismatchError
     return ConicalGradient(Blend(self.gradient, gradient, frac1, frac2),
                            frac1 * self.center + frac2 * center,
                            frac1 * self.direction + frac2 * dir)
コード例 #8
0
 def Blend(self, other, frac1, frac2):
     if other.__class__ == self.__class__:
         gradient = other.gradient
         center = other.center
         border = other.border
     elif other.__class__ == SolidPattern:
         gradient = other.Color()
         center = self.center
         border = self.border
     else:
         raise MismatchError
     return RadialGradient(Blend(self.gradient, gradient, frac1, frac2),
                           frac1 * self.center + frac2 * center,
                           frac1 * self.border + frac2 * border)
コード例 #9
0
 def Blend(self, other, frac1, frac2):
     if other.__class__ == self.__class__:
         gradient = other.gradient
         dir = other.direction
         border = other.border
     elif other.__class__ == SolidPattern:
         gradient = other.Color()
         dir = self.direction
         border = self.border
     else:
         raise MismatchError
     return LinearGradient(Blend(self.gradient, gradient, frac1, frac2),
                           frac1 * self.direction + frac2 * dir,
                           frac1 * self.border + frac2 * border)
コード例 #10
0
 def Blend(self, other, p, q):
     if self.__class__ != other.__class__:
         raise MismatchError
     return self.__class__(_blended_text=Blend(self.text, other.text, p, q),
                           path=Blend(self.path, other.path, p, q))
コード例 #11
0
	def set_blended_properties(self, blended, other, frac1, frac2):
		blended.set_property_stack(Blend(self.properties, other.properties, frac1, frac2))
コード例 #12
0
 def Blend(self, other, frac1, frac2):
     if other.__class__ == self.__class__:
         return SolidPattern(Blend(self.color, other.color, frac1, frac2))
     else:
         raise MismatchError