/[gzz]/gzz/gfx/demo/coords_benchmark.py
ViewVC logotype

Diff of /gzz/gfx/demo/coords_benchmark.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by mudyc, Tue Mar 18 00:42:17 2003 UTC revision 1.5 by mudyc, Tue Mar 18 15:13:55 2003 UTC
# Line 27  from test.tools import tools Line 27  from test.tools import tools
27  from gzz.vob.vobs import *  from gzz.vob.vobs import *
28    
29    
 dbg = 1  
   
30  class ViewScene:  class ViewScene:
31      def __init__(self):      def __init__(self):
32            self.cs = 0
33          self.nested = 0          self.nested = 0
34          self.count = 500          self.count = 500
         self.letters = 0  
35            
36      def scene(self, vs):      def scene(self, vs):
37          size = vs.getSize()          size = vs.getSize()
38          w = size.width*2/4          w = size.width
39          h = size.height*2/4          h = size.height
40          r = java.util.Random()          r = java.util.Random()
41    
         # moves  
         movx = size.width/2  
         movy = size.height/2  
   
42          bgcolor = (0.6, 0.7, 0.8)          bgcolor = (0.6, 0.7, 0.8)
43          putnoc(vs, background(bgcolor))          putnoc(vs, background(bgcolor))
44    
45          alph = 'abcdefghijklmnopqrstuvwxyz'          tr = vs.translateCS(0, 'tr', w*1/5, h*1/5)
   
         # clipping area  
         clip = vs.orthoCS(0,"CLIP",0, 0,0, size.width, size.height)  
         tr = vs.translateCS(0, 'tr', movx,movy)  
   
         if not hasattr(self, "letters"):  
             return  
           
         for nested in range(0, self.nested):  
             if nested%4 == 0:  
                 tr = vs.translateCS(tr, 'tra'+str(nested), 0, -movy)  
             elif nested%4 == 1:  
                 tr = vs.translateCS(tr, 'trb'+str(nested), -movx,0)  
             elif nested%4 == 2:  
                 tr = vs.translateCS(tr, 'trc'+str(nested), 0, movy)  
             else:  
                 tr = vs.translateCS(tr, 'trd'+str(nested), movx,0)  
   
         for count in range(0, self.count):  
             cs = vs.translateCS(tr, 'TEXT'+str(count),  
                                 r.nextFloat()*w, r.nextFloat()*h)  
             cs = vs.cullCS(cs, 'CULL'+str(count), clip)  
             a = count % len(alph)  
             b = (count + self.letters) % len(alph)  
             string = ''  
             if a > b:  
                 tmp = 2*alph[:len(alph)]  
                 string = tmp[a:(b+len(alph))]  
             else:  
                 string = alph[a:b]  
             putText(vs, cs, string, color=(0,0,0), h=14, y=10)  
46    
47            # translate cs
48            if self.cs:
49                for count in range(0, self.count):
50                    cs = vs.translateCS(0, 'TR'+str(count),0,0)
51                    for nested in range(0,self.nested):
52                        cs = vs.translateCS(cs, 'AF'+str(count)+'TEX'+str(nested),
53                                            r.nextFloat()*w*3/5,
54                                            r.nextFloat()*h*3/5)
55                    
56            # affine cs
57            else:
58                for count in range(0, self.count):
59                    cs = vs.coords.affineCoordsys(0,0,0,0 ,1,0,0,1)
60                    for nested in range(0,self.nested):
61                        cs = vs.coords.affineCoordsys(cs,0,0,0, 1,0,0,1)
62                        
63      def benchmark(self):      def benchmark(self):
64          for self.nested in range(0,13,3):          for self.cs in range(0,2):
65              for self.count in range(100,701,200):              for self.nested in range(0,50,5):
66                  for self.letters in range(1,20,4):                  for self.count in range(0,501,100):
67                      vs = w.createVobScene()                      vs = w.createVobScene()
68                      self.scene(vs)                      self.scene(vs)
69                      AbstractUpdateManager.chg()                      time =  w.timeRender(vs, 1000)
70                        print self.cs, self.nested, self.count, time
71            print 'Done!'
72    
                     print self.nested,' nested CS, ',\  
                           self.count, ' text vobs, ',\  
                           self.letters, ' letters ',\  
                           'time: ', w.timeRender(vs, 100)  
                   
73      def key(self, k):      def key(self, k):
74          if k == "Ctrl-B":          if k == "Ctrl-B":
75              self.benchmark()              self.benchmark()
76    
   
77    
78  currentScene = ViewScene()  currentScene = ViewScene()
79    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26