Example #1
0
 def checkCGradientAndPyGradientEquivalent(self, grad):
     # We have 2 sets of gradient-drawing code, in C and Python
     # check they calculate the same answer
     self.assertWellFormedGradient(grad)
     cmap = fract4dc.cmap_create_gradient(grad.segments)
     for i in range(1000):
         fi = i / 1000.0
         (r, g, b, a) = grad.get_color_at(fi)
         # print "%d: %.17g, %.17g, %.17g, %.17g" % (i,r,g,b,a)
         cmap_color = fract4dc.cmap_lookup(cmap, fi)
         grad_color = (int(r * 255.0), int(g * 255.0), int(b * 255.0),
                       int(a * 255.0))
         self.assertNearlyEqual(
             grad_color, cmap_color,
             "colorlist(%s) = %s but gradient(%s) = %s" %
             (fi, cmap_color, fi, grad_color), 1.5)
Example #2
0
 def checkCGradientAndPyGradientEquivalent(self,grad):
     # We have 2 sets of gradient-drawing code, in C and Python
     # check they calculate the same answer
     self.assertWellFormedGradient(grad)
     cmap = fract4dc.cmap_create_gradient(grad.segments)
     for i in range(1000):
         fi = i / 1000.0
         (r,g,b,a) = grad.get_color_at(fi)
         #print "%d: %.17g, %.17g, %.17g, %.17g" % (i,r,g,b,a)
         cmap_color = fract4dc.cmap_lookup(cmap, fi)
         grad_color = (int(r*255.0), int(g*255.0),
                       int(b*255.0), int(a*255.0))
         self.assertNearlyEqual(
             grad_color,
             cmap_color,
             "colorlist(%s) = %s but gradient(%s) = %s" % \
             (fi, cmap_color, fi, grad_color), 1.5)
Example #3
0
    def setUp(self):
        self.f = fractal.T(Test.g_comp)
        self.f.render_type = 2
        self.f.set_formula("test.frm", "test_hypersphere")
        self.f.compile()

        handle = fract4dc.pf_load(self.f.outputfile)
        self.pfunc = fract4dc.pf_create(handle)
        self.cmap = fract4dc.cmap_create_gradient(self.f.get_gradient().segments)
        (r,g,b,a) = self.f.solids[0]
        fract4dc.cmap_set_solid(self.cmap,0,r,g,b,a)
        (r,g,b,a) = self.f.solids[1]
        fract4dc.cmap_set_solid(self.cmap,1,r,g,b,a)

        initparams = self.f.all_params()
        fract4dc.pf_init(self.pfunc,self.f.params,initparams)

        self.im = image.T(40,30)
        siteobj = FractalSite()
        
        self.fw = fract4dc.fw_create(
            1,self.pfunc,self.cmap,self.im._img,self.f.site)

        self.ff = fract4dc.ff_create(
            [0.0, 0.0, 0.0, 0.0,
             4.0,
             0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            2,
            100,
            0,
            1,
            self.pfunc,
            self.cmap,
            0,
            1,
            2, # 3D
            self.im._img,
            self.f.site,
            self.fw,
            False,
            1.0E-9)
Example #4
0
    def setUp(self):
        self.f = fractal.T(Test.g_comp)
        self.f.render_type = 2
        self.f.set_formula("test.frm", "test_hypersphere")
        self.f.compile()

        handle = fract4dc.pf_load(self.f.outputfile)
        self.pfunc = fract4dc.pf_create(handle)
        self.cmap = fract4dc.cmap_create_gradient(
            self.f.get_gradient().segments)
        (r, g, b, a) = self.f.solids[0]
        fract4dc.cmap_set_solid(self.cmap, 0, r, g, b, a)
        (r, g, b, a) = self.f.solids[1]
        fract4dc.cmap_set_solid(self.cmap, 1, r, g, b, a)

        initparams = self.f.all_params()
        fract4dc.pf_init(self.pfunc, self.f.params, initparams)

        self.im = image.T(40, 30)
        siteobj = FractalSite()

        self.fw = fract4dc.fw_create(1, self.pfunc, self.cmap, self.im._img,
                                     self.f.site)

        self.ff = fract4dc.ff_create(
            [0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            2,
            100,
            0,
            1,
            self.pfunc,
            self.cmap,
            0,
            1,
            2,  # 3D
            self.im._img,
            self.f.site,
            self.fw,
            False,
            1.0E-9)