1 |
|
import gzz |
2 |
|
|
3 |
needGL() |
needGL() |
4 |
|
|
5 |
win = getGraphicsWindow() |
win = getGraphicsWindow() |
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) |