コード例 #1
0
    def generate_images(self, iteration):
        global running
        # sum of all frames, needed for padding output files
        sumN = sum(self.durations)
        # number of images already generated
        sumBefore = sum(self.durations[0:iteration])
        # current duration
        N = self.durations[iteration]

        f_prev = fractal.T(self.compiler)
        fh = open(self.anim.get_keyframe_filename(iteration))
        try:
            f_prev.loadFctFile(fh)
        finally:
            fh.close()

        f_next = fractal.T(self.compiler)
        fh = open(self.anim.get_keyframe_filename(iteration + 1))
        try:
            f_next.loadFctFile(fh)
        finally:
            fh.close()

        # ------------------------------------------------------------
        # loop to generate images between current (iteration-th) and previous keyframe
        for i in range(1, N + 1):
            # but, first, wait for previous image to finish rendering
            self.next_image.acquire()
            # check if user canceled us
            if running is False:
                return
            # update progress bar
            percent = float((sumBefore + i)) / (sumN + 1)
            self.pbar_overall.set_fraction(percent)
            self.pbar_overall.set_text(
                str(sumBefore + i) + "/" + str(sumN + 1))

            # create a blended fractal partway between prev and next keyframe
            int_type = self.anim.get_keyframe_int(iteration)
            mu = self.anim.get_mu(int_type, float(i) / float(N))
            f_frame = f_prev.blend(f_next, mu)

            # writes .fct file if user wanted that
            if self.anim.get_fct_enabled():
                f_frame.save(
                    open(self.anim.get_fractal_filename(sumBefore + i), "w"))

            # check if image already exist and user wants to leave it or not
            if not (os.path.exists(self.anim.get_image_filename(sumBefore + i))
                    and self.create_all_images is False
                    ):  # check if image already exist
                self.current.set_fractal(f_frame)
                self.current.reset_render()
                self.current.draw_image(
                    self.anim.get_image_filename(sumBefore + i))
            else:
                # just release semaphore
                self.next_image.release()
        return
コード例 #2
0
    def testDirectorDialog(self):
        f = fractal.T(Test.g_comp)
        parent = Gtk.Window()
        dd = director.DirectorDialog(parent, f, Test.userConfig)
        dd.show()
        dd.animation.set_png_dir(Test.tmpdir.name)
        dd.animation.set_fct_enabled(False)
        dd.animation.add_keyframe(
            "testdata/director1.fct", 1, 10, animation.INT_LOG)
        dd.animation.add_keyframe(
            "testdata/director2.fct", 1, 10, animation.INT_LOG)

        video_file = os.path.join(Test.tmpdir.name, "video.webm")
        dd.animation.set_avi_file(video_file)
        dd.animation.set_width(320)
        dd.animation.set_height(240)
        dd.generate(dd.converterpath is not None)

        self.assertEqual(
            True,
            os.path.exists(
                os.path.join(
                    Test.tmpdir.name,
                    "image_0000000.png")))
        self.assertEqual(
            True,
            os.path.exists(
                os.path.join(
                    Test.tmpdir.name,
                    "image_0000001.png")))
        if dd.converterpath:
            # only check for video if video converter is installed
            self.assertEqual(True, os.path.exists(video_file))

        dd.destroy()
コード例 #3
0
    def testRQ(self):
        rq = renderqueue.T()
        self.assertEqual(0, len(rq.queue))

        # should be a no-op
        rq.start()

        # add a fractal to generate
        f = fractal.T(g_comp)
        rq.add(f, "rq1.png", 100, 1536)

        # check it got added
        self.assertEqual(1, len(rq.queue))
        entry = rq.queue[0]
        self.assertEqual("rq1.png", entry.name)
        self.assertEqual(100, entry.w)
        self.assertEqual(1536, entry.h)

        # run
        rq.connect('done', self.quitloop)
        rq.start()
        self.wait()

        self.assertEqual(0, len(rq.queue))
        os.remove("rq1.png")
コード例 #4
0
    def testRQ(self):
        rq = renderqueue.T(Test.userPrefs)
        self.assertEqual(0, len(rq.queue))

        # should be a no-op
        rq.start()

        # add a fractal to generate
        f = fractal.T(Test.g_comp)
        png_file1 = os.path.join(Test.tmpdir.name, "rq1.png")
        rq.add(f, png_file1, 100, 1536)

        # check it got added
        self.assertEqual(1, len(rq.queue))
        entry = rq.queue[0]
        self.assertEqual(png_file1, entry.name)
        self.assertEqual(100, entry.w)
        self.assertEqual(1536, entry.h)

        # run
        rq.connect('done', self.quitloop)
        rq.start()
        self.wait()

        self.assertEqual(0, len(rq.queue))
コード例 #5
0
def main(args):
    pc = PC()
    pc.add_func_path("../formulas")
    pc.load_formula_file("gf4d.frm")
    pc.load_formula_file("gf4d.cfrm")
    pc.compiler_name = "g++"
    pc.leave_dirty = True
    f = fractal.T(pc)
    f.loadFctFile(open(args[0]))
    outfile = f.compile()
    cfile = outfile[:-2] + "c"

    # compile the stub and the c file to create a program to profile
    files = " ".join(pc.cfiles + [cfile])
    
    cmd = "%s %s %s -o %s %s" % \
          (pc.compiler_name, files, "-g -pg -O3 -Ic -lpthread", "proftest", "")

    print(cmd)
    (status,output) = subprocess.getstatusoutput(cmd)
    if status != 0:
        raise Exception(
            "Error reported by C compiler:%s" % output)

    print(output)
    # compiled - hurrah! run it
    (status,output) = subprocess.getstatusoutput("./proftest")
    if status != 0:
        raise Exception(
            "Error reported by program:%s" % output)

    print(output)
コード例 #6
0
 def testPNGGen(self):
     f = fractal.T(Test.g_comp)
     dd = director.DirectorDialog(None,f,Test.userConfig)
     pg = PNGGen.PNGGeneration(dd.animation,Test.g_comp,dd)
     pg.generate_png()
     
     dd.destroy()
コード例 #7
0
ファイル: test_director.py プロジェクト: YuiiraX/gnofract4d
    def setUp(self):
        # ensure any dialog boxes are dismissed without human interaction
        hig.timeout = 250

        application = Window()
        application.userConfig = Test.userConfig
        self.parent = Gtk.Window()
        self.parent.f = fractal.T(Test.g_comp)
        self.parent.application = application
コード例 #8
0
    def load_keyframes(self, transition):
        self.keyframe = transition
        # current image
        if self.image_counter == 0:
            self.transition_counter = 0
        else:
            # keyframe already output by end of previous transition
            self.transition_counter = 1
        # current transition
        self.transition_length = self.durations[transition] + 1

        self.f_prev = fractal.T(self.compiler)
        with open(self.anim.get_keyframe_filename(transition)) as fh:
            self.f_prev.loadFctFile(fh)

        self.f_next = fractal.T(self.compiler)
        with open(self.anim.get_keyframe_filename(transition + 1)) as fh:
            self.f_next.loadFctFile(fh)
コード例 #9
0
    def testParseParams(self):
        f = fractal.T(g_comp)        
        parfile.parse_maxiter("72000",f)
        self.assertEqual(f.maxiter,72000)
        parfile.parse_colors('0000qJ0mP0iX0eb0di0`o0Xu0Tz2Pz2NzRTzoZqzbRzdTzdTzeTzeTzeTzgVzgVzgVziVziVzkXzkXzkXzmXzmXzmXzgVzdTu`RkXP`TNRNNGJL6GJ0CH08K04U0GcAWdPdkehvpmuxrzzxzzzuzzqzzmzzizzezzbzzZzzVzzTzzRzzRxzPozPexNZvNPsLGqL8oLEkNJiNNgNTeNXdN``PbXPeTPgPPkLPmHPqEPsARv6Rx2Rz0Rz0Rz0Rz0RzzLzzPzgTzLXz0`z0Xz0Vz0Rz0Pz0Lz0Jz0Gz0Ez0Az08z04z02z00z00z00s2GNV`0uu0so6qiCodJo`PmVXkPdkLiiGqgAvg6Lzb0zz2zgJzJ`z0Tz2Nz8HzECxJ6vP0sV0q`0me0kk0io0os0su0xx4zzCzzHzzPzzVzzXzzXzzXzzXzzXzzXzxXxvXvuXssXqqXmoXkmbizVdzPZyHTsCNh6HZ0CS06Q00S00U00W00Y00_00a40cC4eJ6hR8kZAneEqmGtuHwzJzzLzz0Hz0Gz0Gz0Ez0Ez0Ez0Cz0Cz0Cz0Ax0Av08u08q08o06m06k06s0Cgz0TZzz0zz0zz2zq6ziAz`GzRJxHNvARuLGko0CV4de0Vo0NgVzkHzo6ss0ev0TmCbq2Xs0Tu0Nv0J0z02z0Cs0Lb0XL2e46o0CiZpoRmqGec4`h0Tc0LGzzRdxbHim0VPJob2bm0R60AP0Cg0EzzzzzzzdqxHdx0RzzLzmJzNHx0G0z00v60uE',f)
        self.assertEqual(len(f.get_gradient().segments),255)

        parfile.parse_center_mag("-0.74999655467724592903865/0.01712692163034049041486/5.51789e+018",f)
        self.assertEqual(f.params[f.XCENTER],-0.74999655467724592903865)
        self.assertEqual(f.params[f.YCENTER],-0.01712692163034049041486)
        self.assertEqual(f.params[f.MAGNITUDE],2.0/5.51789e+018 * 1.33)
コード例 #10
0
    def testPNGGen(self):
        f = fractal.T(Test.g_comp)
        dd = director.DirectorDialog(None, f, Test.userConfig)
        dd.animation.add_keyframe(
            "testdata/director1.fct", 1, 10, animation.INT_LOG)
        dd.animation.add_keyframe(
            "testdata/director2.fct", 1, 10, animation.INT_LOG)
        pg = PNGGen.PNGGeneration(dd.animation, Test.g_comp, dd)
        pg.generate_png()

        dd.destroy()
コード例 #11
0
    def testKeyframeClash(self):
        f = fractal.T(Test.g_comp)
        dd = director.DirectorDialog(None, f, Test.userConfig)

        dd.check_for_keyframe_clash("/a", "/b")

        self.assertRaises(
            director.SanityCheckError,
            dd.check_for_keyframe_clash, os.path.join(Test.tmpdir.name, "foo.fct"), Test.tmpdir.name)
        self.assertRaises(
            director.SanityCheckError,
            dd.check_for_keyframe_clash, os.path.join(Test.tmpdir.name, "foo.fct"), Test.tmpdir.name)
コード例 #12
0
    def testKeyframeClash(self):
        f = fractal.T(Test.g_comp)
        dd = director.DirectorDialog(None,f,Test.userConfig)

        dd.check_for_keyframe_clash("/a","/b")
        
        self.assertRaises(
            director.SanityCheckError,
            dd.check_for_keyframe_clash, "/tmp/foo.fct", "/tmp")
        self.assertRaises(
            director.SanityCheckError,
            dd.check_for_keyframe_clash, "/tmp/foo.fct", "/tmp/")
コード例 #13
0
 def testQueueDialog(self):
     f = fractal.T(Test.g_comp)
     rq = renderqueue.T(Test.userPrefs)
     png_file2 = os.path.join(Test.tmpdir.name, "foo2.png")
     png_file3 = os.path.join(Test.tmpdir.name, "foo3.png")
     rq.add(f, png_file2, 204, 153)
     rq.add(f, png_file3, 80, 40)
     rq.connect('done', self.quitloop)
     rq.start()
     parent = Gtk.Window()
     d = renderqueue.QueueDialog(parent, f, rq)
     d.show()
     self.wait()
コード例 #14
0
 def testQueueDialog(self):
     f = fractal.T(g_comp)
     renderqueue.show(None, None, f)
     rq = renderqueue.instance
     rq.add(f, "foo.png", 124, 276)
     rq.add(f, "foo2.png", 204, 153)
     rq.add(f, "foo3.png", 80, 40)
     rq.connect('done', self.quitloop)
     rq.start()
     self.wait()
     os.remove("foo.png")
     os.remove("foo2.png")
     os.remove("foo3.png")
コード例 #15
0
    def generate_base_keyframe(self):
        f=fractal.T(self.compiler)
        f.loadFctFile(open(self.anim.get_keyframe_filename(0)))

        self.next_image.acquire()
        #writes .fct file if user wanted that
        if self.anim.get_fct_enabled():
            f.save(open(self.anim.get_fractal_filename(0),"w"))
        #check if image already exist and user wants to leave it or not
        if not(os.path.exists(self.anim.get_image_filename(0)) and self.create_all_images==False): #check if image already exist
            self.current.set_fractal(f)
	    self.current.reset_render()
            self.current.draw_image(self.anim.get_image_filename(0))
        else:
            #just release semaphore
            self.next_image.release()
        return
コード例 #16
0
    def testOwnSanity(self):
        # exercise each of the checks in the check_sanity function
        f = fractal.T(Test.g_comp)
        dd = director.DirectorDialog(None, f, Test.userConfig)

        dd.animation.add_keyframe(
            "/foo/director1.fct", 1, 10, animation.INT_LOG)
        self.assertRaisesMessage(
            director.SanityCheckError, "There must be at least two keyframes",
            dd.check_sanity)

        dd.animation.add_keyframe(os.path.join(Test.tmpdir.name, "director2.fct"),
                                  1, 10, animation.INT_LOG)
        dd.animation.set_png_dir("")
        self.assertRaisesMessage(
            director.SanityCheckError,
            "Directory for temporary .png files not set",
            dd.check_sanity)

        dd.animation.set_png_dir("fishy")
        self.assertRaisesMessage(
            director.SanityCheckError,
            "Path for temporary .png files is not a directory",
            dd.check_sanity)

        dd.animation.set_png_dir(Test.tmpdir.name)

        self.assertRaisesMessage(
            director.SanityCheckError,
            "Output AVI file name not set",
            dd.check_sanity)

        dd.animation.set_avi_file(os.path.join(Test.tmpdir.name, "foo.avi"))

        dd.animation.set_fct_enabled(True)
        dd.animation.set_fct_dir(Test.tmpdir.name)

        self.assertRaisesMessage(
            director.SanityCheckError,
            "Keyframe {} is in the temporary .fct directory and could be overwritten. Please change temp directory.".format(
                os.path.join(Test.tmpdir.name, "director2.fct")),
            dd.check_sanity)
コード例 #17
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)
コード例 #18
0
 def setUp(self):
     self.mainWindow = MockMainWindow(Test.g_comp)
     self.f = fractal.T(self.mainWindow.compiler, self)
コード例 #19
0
ファイル: director.py プロジェクト: asa-Q/HL
    def onResponse(self, widget, id):
        if id == Gtk.ResponseType.CLOSE or \
                id == Gtk.ResponseType.NONE or \
                id == Gtk.ResponseType.DELETE_EVENT:
            self.hide()
        elif id == DirectorDialog.RESPONSE_RENDER:
            self.animation.set_avi_file(self.txt_temp_avi.get_text())
            try:
                self.generate(self.converterpath is not None)
            except (SanityCheckError, UserCancelledError):
                # prevent dialog closing if being run
                GObject.signal_stop_emission_by_name(self, "response")
            else:
                self.hide()

    def main(self):
        Gtk.main()


if __name__ == "__main__":
    GObject.threads_init()
    Gtk.threads_init()

    main_window = Gtk.Window()
    userConfig = fractconfig.userConfig()
    compiler = fc.Compiler(userConfig)
    f = fractal.T(compiler)
    fracwin = DirectorDialog(main_window, f, userConfig)

    fracwin.main()
コード例 #20
0
 def try_init_fractal(self):
     f = fractal.T(self.compiler,self.site)
     self.set_fractal(f)
     self.f.compile()
コード例 #21
0
 def loadFctFile(self,file):
     new_f = fractal.T(self.compiler,self.site)
     new_f.warn = self.warn
     new_f.loadFctFile(file)
     self.set_fractal(new_f)
     self.set_saved(True)
コード例 #22
0
    def setUp(self):
        self.compiler = fc.instance
        self.compiler.add_func_path("../formulas")
        self.compiler.add_func_path("../fract4d")

        self.f = fractal.T(self.compiler, self)
コード例 #23
0
 def testLoadFOTD1(self):
     fotd_file = io.StringIO(fotd)
     f = fractal.T(g_comp)        
     parfile.parse(fotd_file, f)
     self.assertEqual(f.maxiter, 72000)
コード例 #24
0
                    col = [
                        int(x_y[0] * nratio + x_y[1] * ratio) for x_y in pairs
                    ]
                    colors.append(col)

            colors.append(rgb)
            i += 3
            runlength = 0

    return colors


if __name__ == "__main__":
    import sys
    from fract4d import fractal
    from fract4d_compiler import fc

    g_comp = fc.Compiler(fractconfig.userConfig())
    g_comp.add_func_path("../formulas")
    g_comp.add_func_path("../testdata/formulas")
    g_comp.load_formula_file("gf4d.frm")
    g_comp.load_formula_file("test.frm")
    g_comp.load_formula_file("gf4d.cfrm")

    f = fractal.T(g_comp)
    file = open(sys.argv[1])

    parse(file, f)

    f.save(open("parfile.fct", "w"))
コード例 #25
0
 def setUp(self):
     self.f = fractal.T(Test.g_comp, self)
コード例 #26
0
 def setUp(self):
     f = fractal.T(Test.g_comp)
     self.test_animation = animation.T(f.compiler, Test.userConfig)