/[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.2 by mudyc, Thu Mar 13 14:50:35 2003 UTC revision 1.3 by mudyc, Thu Mar 13 15:31:04 2003 UTC
# Line 26  from gzz.view import View Line 26  from gzz.view import View
26  from test.tools import tools  from test.tools import tools
27  from gzz.vob.vobs import *  from gzz.vob.vobs import *
28    
 style = GraphicsAPI.getInstance().getTextStyle("serif", 0, 14)  
29    
30  dbg = 1  dbg = 1
31    
32  class ViewScene:  class ViewScene:
33      def __init__(self):      def __init__(self):
34          self.passes = 0          self.passes = 0
35          self.time = System.currentTimeMillis()          self.time = 0
36          self.diff = 0          self.diff = 0
37            
38      def scene(self, vs):      def scene(self, vs):
39          size = vs.getSize()          size = vs.getSize()
40          w = size.width*2/5          w = size.width*2/4
41          h = size.height*2/5          h = size.height*2/4
42          r = java.util.Random()          r = java.util.Random()
43    
44          # moves          # moves
# Line 49  class ViewScene: Line 48  class ViewScene:
48          bgcolor = (0.6, 0.7, 0.8)          bgcolor = (0.6, 0.7, 0.8)
49          putnoc(vs, background(bgcolor))          putnoc(vs, background(bgcolor))
50    
51    
52            # clipping area
53            clip = vs.orthoCS(0,"CLIP",0, #0,0, size.width, size.height)
54                              size.width*1/20, size.height*1/20,
55                              size.width*9/10, size.height*9/10)
56    
57          tr = vs.translateCS(0, 'tr', movx,movy)          tr = vs.translateCS(0, 'tr', movx,movy)
58    
59          for i in range(0,self.passes):          for i in range(0,self.passes):
# Line 61  class ViewScene: Line 66  class ViewScene:
66              else:              else:
67                  tr = vs.translateCS(tr, 'trd'+str(i), movx,0)                  tr = vs.translateCS(tr, 'trd'+str(i), movx,0)
68    
69          for i in range(0,1000):          for i in range(0,800):
70              cs = vs.translateCS(tr, 'TEXT'+str(i),              cs = vs.translateCS(tr, 'TEXT'+str(i),
71                                  r.nextFloat()*w, r.nextFloat()*h)                                  r.nextFloat()*w, r.nextFloat()*h)
72                cs = vs.cullCS(cs, 'CULL'+str(i), clip)
73              putText(vs, cs, str(i), color=(0,0,0), h=14, y=10)              putText(vs, cs, str(i), color=(0,0,0), h=14, y=10)
74          self.passes += 1          self.passes += 1
75    
76            # count time
77          time = System.currentTimeMillis()          time = System.currentTimeMillis()
78            real = time - self.time
79            if real > 15*1000:
80                real = 0
81                
82          if dbg:          if dbg:
83              print 'Passes: ', self.passes, \              print 'Passes: ', self.passes, \
84                    ' time: ', time - self.time, \                    ' time: ', time - self.time, \
85                    ' diff: ', time - self.time - self.diff                    ' diff: ', time - self.time - self.diff
86          self.diff = time - self.time          self.diff = time - self.time
87          self.time = time          self.time = time
88          AbstractUpdateManager.chg()              
89            if real < 1500:
90                AbstractUpdateManager.chg()
91            else:
92                print 'Stop! - passes:', self.passes ,' time:', real
93                print 'press r to rerun'
94    
95    
96  currentScene = ViewScene()  currentScene = ViewScene()

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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