Beispiel #1
0
    def drawTwice(self,is_dirty,xsize):
        ysize = int(xsize * 3.0/4.0)
        im = image.T(xsize,ysize)
        siteobj = FractalSite()
        site = fract4dc.site_create(siteobj)

        file = self.compileColorMandel()
        handle = fract4dc.pf_load(file)
        pfunc = fract4dc.pf_create(handle)
        fract4dc.pf_init(pfunc,pos_params,self.color_mandel_params)

        cmap = fract4dc.cmap_create(
            [(1.0, 255, 255, 255, 255)])
        
        fract4dc.calc(
            params=[0.0, 0.0, 0.0, 0.0,
             4.0,
             0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            antialias=0,
            maxiter=100,
            yflip=0,
            nthreads=1,
            pfo=pfunc,
            cmap=cmap,
            auto_deepen=0,
            periodicity=1,
            render_type=0,
            image=im._img,
            site=site,
            dirty=is_dirty)

        #print "1st pass %s" % is_dirty
        #fract4dc.image_save(image, "/tmp/pass1%d.tga" % is_dirty)
        #self.print_fates(image,xsize,ysize)
        
        cmap = fract4dc.cmap_create(
            [(1.0, 76, 49, 189, 255)])

        fract4dc.calc(
            params=[0.0, 0.0, 0.0, 0.0,
             4.0,
             0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            antialias=0,
            maxiter=100,
            yflip=0,
            nthreads=1,
            pfo=pfunc,
            cmap=cmap,
            auto_deepen=0,
            periodicity=1,
            render_type=0,
            image=im._img,
            site=site,
            dirty=is_dirty)

        #print "2nd pass %s" % is_dirty
        #self.print_fates(image,xsize,ysize)
        im.save(os.path.join(Test.tmpdir.name, "pass2%d.tga" % is_dirty))
        
        return [] # fract4dc.image_buffer(image)
Beispiel #2
0
    def drawTwice(self, is_dirty, xsize):
        ysize = int(xsize * 3.0 / 4.0)
        im = image.T(xsize, ysize)
        siteobj = FractalSite()
        site = fract4dc.site_create(siteobj)

        file = self.compileColorMandel()
        handle = fract4dc.pf_load(file)
        pfunc = fract4dc.pf_create(handle)
        fract4dc.pf_init(pfunc, pos_params, self.color_mandel_params)

        cmap = fract4dc.cmap_create(
            [(1.0, 255, 255, 255, 255)])

        fract4dc.calc(
            params=[0.0, 0.0, 0.0, 0.0,
                    4.0,
                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            antialias=0,
            maxiter=100,
            yflip=0,
            nthreads=1,
            pfo=pfunc,
            cmap=cmap,
            auto_deepen=0,
            periodicity=1,
            render_type=0,
            image=im._img,
            site=site,
            dirty=is_dirty)

        # print "1st pass %s" % is_dirty
        #fract4dc.image_save(image, "/tmp/pass1%d.tga" % is_dirty)
        # self.print_fates(image,xsize,ysize)

        cmap = fract4dc.cmap_create(
            [(1.0, 76, 49, 189, 255)])

        fract4dc.calc(
            params=[0.0, 0.0, 0.0, 0.0,
                    4.0,
                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            antialias=0,
            maxiter=100,
            yflip=0,
            nthreads=1,
            pfo=pfunc,
            cmap=cmap,
            auto_deepen=0,
            periodicity=1,
            render_type=0,
            image=im._img,
            site=site,
            dirty=is_dirty)

        # print "2nd pass %s" % is_dirty
        # self.print_fates(image,xsize,ysize)
        im.save(os.path.join(Test.tmpdir.name, "pass2%d.tga" % is_dirty))

        return []  # fract4dc.image_buffer(image)
Beispiel #3
0
    def testCalc(self):
        xsize = 64
        ysize = int(xsize * 3.0 / 4.0)
        im = image.T(xsize, ysize)
        siteobj = FractalSite()
        site = fract4dc.site_create(siteobj)

        file = self.compileColorMandel()
        handle = fract4dc.pf_load(file)
        pfunc = fract4dc.pf_create(handle)
        fract4dc.pf_init(pfunc, pos_params, self.color_mandel_params)
        cmap = fract4dc.cmap_create([(0.0, 0, 0, 0, 255),
                                     (1 / 256.0, 255, 255, 255, 255),
                                     (1.0, 255, 255, 255, 255)])
        fract4dc.calc(
            params=[0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            antialias=0,
            maxiter=100,
            yflip=0,
            nthreads=1,
            pfo=pfunc,
            cmap=cmap,
            auto_deepen=0,
            periodicity=1,
            render_type=0,
            image=im._img,
            site=site)

        self.assertEqual(siteobj.progress_list[-1], 0.0)
        self.assertEqual(siteobj.progress_list[-2], 1.0)

        self.assertTrue(siteobj.image_list[-1] == (0, 0, xsize, ysize))

        self.assertTrue(siteobj.status_list[0] == 1
                        and siteobj.status_list[-1] == 0)

        test2_tga = os.path.join(Test.tmpdir.name, "test2.tga")
        self.assertTrue(not os.path.exists(test2_tga))
        im.save(test2_tga)
        self.assertTrue(os.path.exists(test2_tga))

        # fate of all non-aa pixels should be known, aa-pixels unknown
        fate_buf = im.fate_buffer()
        i = 0
        for byte in fate_buf:
            d = im.get_color_index(
                (i % (im.FATE_SIZE * xsize)) // im.FATE_SIZE,
                i // (im.FATE_SIZE * xsize), i % im.FATE_SIZE)

            if i % 4 == 0:
                # no-aa
                self.assertNotEqual(byte, 255, "pixel %d is %d" % (i, byte))
                self.assertNotEqual("%g" % d, "inf")
            else:
                self.assertEqual(byte, 255)
            i += 1

        self.assertPixelCount(xsize, ysize, siteobj)
Beispiel #4
0
 def testDraw(self):
     fract4dc.calc(
         params=self.f.params,
         antialias=self.f.antialias,
         maxiter=self.f.maxiter,
         yflip=self.f.yflip,
         periodicity=self.f.periodicity,
         pfo=self.pfunc,
         cmap=self.cmap,
         auto_deepen=self.f.auto_deepen,
         nthreads=1,
         render_type=2,  # 3D
         image=self.im._img,
         site=self.f.site)
Beispiel #5
0
 def testDraw(self):
     fract4dc.calc(
         params = self.f.params,
         antialias = self.f.antialias,
         maxiter=self.f.maxiter,
         yflip=self.f.yflip,
         periodicity=self.f.periodicity,
         pfo=self.pfunc,
         cmap=self.cmap,
         auto_deepen=self.f.auto_deepen,
         nthreads=1,
         render_type=2, # 3D
         image=self.im._img,
         site=self.f.site)
Beispiel #6
0
    def testAACalc(self):
        xsize = 64
        ysize = int(xsize * 3.0 / 4.0)
        im = image.T(xsize, ysize)
        siteobj = FractalSite()
        site = fract4dc.site_create(siteobj)

        file = self.compileColorMandel()
        handle = fract4dc.pf_load(file)
        pfunc = fract4dc.pf_create(handle)
        fract4dc.pf_init(pfunc, pos_params, self.color_mandel_params)
        cmap = fract4dc.cmap_create(
            [(0.0, 0, 0, 0, 255),
             (1 / 256.0, 255, 255, 255, 255),
             (1.0, 255, 255, 255, 255)])
        fract4dc.calc(
            params=[0.0, 0.0, 0.0, 0.0,
                    4.0,
                    0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            antialias=1,
            maxiter=100,
            yflip=0,
            nthreads=1,
            pfo=pfunc,
            cmap=cmap,
            auto_deepen=0,
            periodicity=1,
            render_type=0,
            image=im._img,
            site=site)

        # fate of all pixels should be known
        fate_buf = im.fate_buffer()
        i = 0
        for byte in fate_buf:
            d = im.get_color_index(
                (i % (im.FATE_SIZE * xsize)) // im.FATE_SIZE,
                i // (im.FATE_SIZE * xsize),
                i % im.FATE_SIZE)

            self.assertNotEqual("%g" % d, "inf", "index %d is %g" % (i, d))
            self.assertNotEqual(byte, 255,
                                "pixel %d is %d" % (i, byte))
            i += 1
Beispiel #7
0
    def testAACalc(self):
        xsize = 64
        ysize = int(xsize * 3.0/4.0)
        im = image.T(xsize,ysize)
        siteobj = FractalSite()
        site = fract4dc.site_create(siteobj)

        file = self.compileColorMandel()
        handle = fract4dc.pf_load(file)
        pfunc = fract4dc.pf_create(handle)
        fract4dc.pf_init(pfunc,pos_params,self.color_mandel_params)
        cmap = fract4dc.cmap_create(
            [(0.0,0,0,0,255),
             (1/256.0,255,255,255,255),
             (1.0, 255, 255, 255, 255)])
        fract4dc.calc(
            params=[0.0, 0.0, 0.0, 0.0,
             4.0,
             0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            antialias=1,
            maxiter=100,
            yflip=0,
            nthreads=1,
            pfo=pfunc,
            cmap=cmap,
            auto_deepen=0,
            periodicity=1,
            render_type=0,
            image=im._img,
            site=site)

        # fate of all pixels should be known
        fate_buf = im.fate_buffer()
        i = 0
        for byte in fate_buf:
            d = im.get_color_index(
                    (i % (im.FATE_SIZE * xsize)) // im.FATE_SIZE,
                    i // (im.FATE_SIZE * xsize),
                    i % im.FATE_SIZE)

            self.assertNotEqual("%g" % d,"inf", "index %d is %g" % (i,d))
            self.assertNotEqual(byte, 255,
                                "pixel %d is %d" % (i, byte))
            i+= 1
Beispiel #8
0
    def testFDSite(self):
        xsize = 64
        ysize = int(xsize * 3.0 / 4.0)
        im = image.T(xsize, ysize)
        (rfd, wfd) = os.pipe()
        site = fract4dc.fdsite_create(wfd)

        file = self.compileColorMandel()

        handle = fract4dc.pf_load(file)
        pfunc = fract4dc.pf_create(handle)

        for x in range(2):
            fract4dc.pf_init(pfunc, pos_params, self.color_mandel_params)
            cmap = fract4dc.cmap_create(
                [(0.0, 0, 0, 0, 255),
                 (1 / 256.0, 255, 255, 255, 255),
                 (1.0, 255, 255, 255, 255)])

            fract4dc.calc(
                params=[0.0, 0.0, 0.0, 0.0,
                        4.0,
                        0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                antialias=0,
                maxiter=100,
                yflip=0,
                nthreads=1,
                pfo=pfunc,
                cmap=cmap,
                auto_deepen=0,
                periodicity=1,
                render_type=0,
                image=im._img,
                site=site,
                asynchronous=True)

            while True:
                # read message type and size
                # we use a buffer here like in gtkfractal.py "onData"
                nb = 2 * 4
                bytes = b""
                while True:
                    # wait up to 1 sec until we can read, otherwise we assume the counterpart is gone (an error ocurred on the C++ layer)
                    r, w, e = select.select([rfd], [], [], 1)
                    if rfd in r:
                        temp = os.read(rfd, nb - len(bytes))
                    else:
                        self.fail("no one on the other side")
                    bytes = bytes + temp
                    if (len(bytes) == nb):
                        break
                    elif temp == '':
                        self.fail(
                            "bad message with length %s, value %s" %
                            (len(bytes), bytes))
                (t, size) = struct.unpack("2i", bytes)

                # read the actual message
                bytes = os.read(rfd, size)
                if len(bytes) < size:
                    self.fail("bad message")
                    break
                msg = messages.parse(t, bytes)
                # if the fractal is done
                if msg.name == "Status" and msg.status == 0:
                    # fract4dc.interrupt(site)
                    break
Beispiel #9
0
    def testFDSite(self):
        xsize = 64
        ysize = int(xsize * 3.0/4.0)
        im = image.T(xsize,ysize)
        (rfd,wfd) = os.pipe()
        site = fract4dc.fdsite_create(wfd)

        file = self.compileColorMandel()

        for x in range(2):
            handle = fract4dc.pf_load(file)
            pfunc = fract4dc.pf_create(handle)
            fract4dc.pf_init(pfunc,pos_params,self.color_mandel_params)
            cmap = fract4dc.cmap_create(
                [(0.0,0,0,0,255),
                 (1/256.0,255,255,255,255),
                 (1.0, 255, 255, 255, 255)])

            fract4dc.calc(
                params=[0.0, 0.0, 0.0, 0.0,
                 4.0,
                 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                antialias=0,
                maxiter=100,
                yflip=0,
                nthreads=1,
                pfo=pfunc,
                cmap=cmap,
                auto_deepen=0,
                periodicity=1,
                render_type=0,
                image=im._img,
                site=site,
                asynchronous=True)

            nrecved = 0
            while True:
                if nrecved == x:
                    #print "hit message count"
                    fract4dc.interrupt(site)
                
                nb = 2*4
                bytes = os.read(rfd,nb)
                if len(bytes) < nb:
                    self.fail("bad message with length %s, value %s" % (len(bytes), bytes))
                    break

                (t,size) = struct.unpack("2i",bytes)
                #print "read %d, len %d" % (t,size)

                # read the rest of the message
                bytes = os.read(rfd,size)
                if len(bytes) < size:
                    self.fail("bad message")
                    break
                
                msg = messages.parse(t, bytes)
                #print "msg: %s" % msg.show()
                if msg.name == "Status" and msg.status == 0:
                    #done
                    #print "done"
                    break
                
                nrecved += 1
Beispiel #10
0
    def testCalc(self):
        xsize = 64
        ysize = int(xsize * 3.0/4.0)
        im = image.T(xsize,ysize)
        siteobj = FractalSite()
        site = fract4dc.site_create(siteobj)

        file = self.compileColorMandel()
        handle = fract4dc.pf_load(file)
        pfunc = fract4dc.pf_create(handle)
        fract4dc.pf_init(pfunc,pos_params,self.color_mandel_params)
        cmap = fract4dc.cmap_create(
            [(0.0,0,0,0,255),
             (1/256.0,255,255,255,255),
             (1.0, 255, 255, 255, 255)])
        fract4dc.calc(
            params=[0.0, 0.0, 0.0, 0.0,
             4.0,
             0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            antialias=0,
            maxiter=100,
            yflip=0,
            nthreads=1,
            pfo=pfunc,
            cmap=cmap,
            auto_deepen=0,
            periodicity=1,
            render_type=0,
            image=im._img,
            site=site)

        self.assertEqual(siteobj.progress_list[-1], 0.0)
        self.assertEqual(siteobj.progress_list[-2], 1.0)                        

        self.assertTrue(siteobj.image_list[-1]==(0,0,xsize,ysize))

        self.assertTrue(siteobj.status_list[0]== 1 and \
                         siteobj.status_list[-1]== 0)

        test2_tga = os.path.join(Test.tmpdir.name, "test2.tga")
        self.assertTrue(not os.path.exists(test2_tga))
        im.save(test2_tga)
        self.assertTrue(os.path.exists(test2_tga))

        # fate of all non-aa pixels should be known, aa-pixels unknown
        fate_buf = im.fate_buffer()
        i = 0
        for byte in fate_buf:
            d = im.get_color_index(
                    (i % (im.FATE_SIZE * xsize)) // im.FATE_SIZE,
                    i // (im.FATE_SIZE * xsize),
                    i % im.FATE_SIZE)
            
            if i % 4 == 0:
                # no-aa
                self.assertNotEqual(byte, 255,
                                    "pixel %d is %d" % (i,byte))
                self.assertNotEqual("%g" % d,"inf")
            else:
                self.assertEqual(byte, 255)
            i+= 1

        self.assertPixelCount(xsize,ysize,siteobj)
Beispiel #11
0
    def testFDSite(self):
        xsize = 64
        ysize = int(xsize * 3.0 / 4.0)
        im = image.T(xsize, ysize)
        (rfd, wfd) = os.pipe()
        site = fract4dc.fdsite_create(wfd)

        file = self.compileColorMandel()

        for x in range(2):
            handle = fract4dc.pf_load(file)
            pfunc = fract4dc.pf_create(handle)
            fract4dc.pf_init(pfunc, pos_params, self.color_mandel_params)
            cmap = fract4dc.cmap_create([(0.0, 0, 0, 0, 255),
                                         (1 / 256.0, 255, 255, 255, 255),
                                         (1.0, 255, 255, 255, 255)])

            fract4dc.calc(
                params=[0.0, 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
                antialias=0,
                maxiter=100,
                yflip=0,
                nthreads=1,
                pfo=pfunc,
                cmap=cmap,
                auto_deepen=0,
                periodicity=1,
                render_type=0,
                image=im._img,
                site=site,
                asynchronous=True)

            nrecved = 0
            while True:
                if nrecved == x:
                    # print "hit message count"
                    fract4dc.interrupt(site)

                nb = 2 * 4
                bytes = os.read(rfd, nb)
                if len(bytes) < nb:
                    self.fail("bad message with length %s, value %s" %
                              (len(bytes), bytes))
                    break

                (t, size) = struct.unpack("2i", bytes)
                # print "read %d, len %d" % (t,size)

                # read the rest of the message
                bytes = os.read(rfd, size)
                if len(bytes) < size:
                    self.fail("bad message")
                    break

                msg = messages.parse(t, bytes)
                # print "msg: %s" % msg.show()
                if msg.name == "Status" and msg.status == 0:
                    # done
                    # print "done"
                    break

                nrecved += 1