def interpolate(self, stroke, n=10, method='linear'): colors = self.color.interpolate(stroke.color, n, method) w1 = self.width.literal() w2 = stroke.width.literal() if w1 != None and w2 != None: widths = interpolate(w1, w2, n, method) else: widths = [self.width] * n return map(lambda x: Stroke(x[0], x[1]), zip(colors, widths))
def interpolate(self, stroke, n=10): colors = self.color.interpolate(stroke.color, n) w1 = self.width.literal() w2 = stroke.width.literal() if w1 != None and w2 != None: widths = interpolate(w1, w2, n, 'linear') else: widths = [self.width] * n return map(lambda x: Stroke(x[0], x[1]), zip(colors, widths))
def interpolate(self, color, n=10, method='linear'): """ Interpolates a set of color values beteen this color and the specified *color*. The *n* parameter specifies how many values to interpolate, specifically the number of classes resulting from the interpolation. The interpolation is inclusive of this and the specified color and returns a list of *n*+1 values. """ color = Color(color) hsl1,hsl2 = self.hsl, color.hsl dhsl = map(lambda x: x[1]-x[0], zip(hsl1,hsl2)) colors = [Color.fromHSL(map(lambda x,y: x + (r/float(n))*y,hsl1,dhsl)) for r in util.interpolate(0, n, n, method)] if self._color.alpha != color._color.alpha: alphas = util.interpolate(self._color.alpha,color._color.alpha,n,method) colors = map(lambda (c,a): c.alpha(int(a)), zip(colors, alphas)) return colors
def interpolate(self, att, classes=10, method='linear'): """ Generates a set of interpolated values for an attribute of the layer. *att* specifies the attribute. *classes* specifies the number of values to generate. The *method* parameter specifies the interpolation method. By default a linear method is used. The values 'exp' (exponential) and 'log' (logarithmic) methods are also supported. """ min, max = self.minmax(att) return util.interpolate(min, max, classes, method)