def split(self, file): text = open(file).read() t = self.translateGradient(text) for grad in t.children: t = translate.GradientFunc(grad) g = gradient.Gradient() g.load_ugr(t) out_name = g.name + ".ggr" f = open("gradients/" + out_name, "w") print(g.serialize(), file=f) f.close()
def testFromUgr(self): pt = fractparser.parser.parse('''blatte10 { gradient: title="blatte10" smooth=no index=0 color=3085069 index=25 color=3216141 index=56 color=10761236 index=83 color=1408165 index=92 color=4050153 index=110 color=18018 index=134 color=0 index=213 color=5183243 index=284 color=11494485 index=358 color=0 index=384 color=144 opacity: smooth=no index=0 opacity=255 } ''') t = translate.GradientFunc(pt.children[0], "f") g = gradient.Gradient() g.load_ugr(t) self.assertWellFormedGradient(g) self.assertEqual(len(g.segments), 12)
def translateGradient(self,s,dump=None): fractlexer.lexer.lineno = 1 pt = self.parser.parse(s) return translate.GradientFunc(pt.children[0], dump)