/[gzz]/gzz/test/gzz/gfx/gl/checkColor.py
ViewVC logotype

Diff of /gzz/test/gzz/gfx/gl/checkColor.py

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

revision 1.3 by tjl, Sat Oct 12 10:18:09 2002 UTC revision 1.4 by tjl, Mon Oct 14 18:15:19 2002 UTC
# Line 1  Line 1 
1    import gzz
2    
3  needGL()  needGL()
4    
5  win = getGraphicsWindow()  win = getGraphicsWindow()
# Line 11  def render(vs): Line 13  def render(vs):
13      vs.coords.renderInterp(win, vs.map, None, None, 0, 1, 1)      vs.coords.renderInterp(win, vs.map, None, None, 0, 1, 1)
14    
15  def getAvgColor(x, y, w, h):  def getAvgColor(x, y, w, h):
16      bv = GL.createByteVector(10000)      
17      # We want to give the window coords differently, y = 0 is up.      colors = win.readPixels(x, y, w, h)
18      bounds = win.window.getBounds()      color = gzz.util.ColorUtil.avgColor(colors)
19      y = bounds.height - 1 - y      return [c*255 for c in color.getComponents(None)]
     bv.readFromBuffer_ubytes(win.window, "FRONT", x, y, w, h, "RGB")  
     r = 0.0  
     g = 0.0  
     b = 0.0  
     for i in range(0,w*h):  
         r += bv.get(3*i)  
         g += bv.get(3*i+1)  
         b += bv.get(3*i+2)  
     r /= w*h  
     g /= w*h  
     b /= w*h  
   
     return (r, g, b)  
20    
21  def checkAvgColor(x, y, w, h, color, delta=10):  def checkAvgColor(x, y, w, h, color, delta=10):
22      real = getAvgColor(x, y, w, h)      real = getAvgColor(x, y, w, h)

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

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