Ejemplo n.º 1
0
    def filter(self, img):
        try:
            return core.radian_warp(img, self.formula, self.antialias, self.empty_color)
        except:
            pass

        def radian_formula(x, y):
            '''transform formula
            func is a function that like f(r, phi) => (r, phi)
            '''
            r = sqrt(x ** 2 + y ** 2)
            phi = atan2(y, x)

            r, phi = self.formula(r, phi)

            xnew = r * cos(phi)
            ynew = r * sin(phi)

            return xnew, ynew

        warp = LensWarpEffect(radian_formula, self.antialias)
        return warp(img)