This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 5177ae606db5d0f61c99540aeffb1d7b9114ebef (commit) from f83ed3f17db2867b1b7e0fa6cbeed18fcd7dbbc8 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/5177ae606db5d0f61c99540aeffb1d7b9114e...
commit 5177ae606db5d0f61c99540aeffb1d7b9114ebef Author: Cyril Hrubis metan@ucw.cz Date: Sun Mar 11 21:22:41 2012 +0100
pylib, demos: Another round of fixes for pyton 3.2
diff --git a/demos/py_simple/gravplots_AA.py b/demos/py_simple/gravplots_AA.py index 1b48453..284061e 100755 --- a/demos/py_simple/gravplots_AA.py +++ b/demos/py_simple/gravplots_AA.py @@ -69,35 +69,35 @@ class elem(object): def main(): bk = backends.BackendSDLInit(W, H, BPP, 0, "Gravplots AA") assert bk - print bk - print "Modify source for parameters," - print "Kill to terminate ;-)" + print(bk) + print("Modify source for parameters,") + print("Kill to terminate ;-)") black = bk.context.RGBToPixel(0, 0, 0)
es = [elem() for i in range(N)] while True: for e in es: for e2 in es: - if not (e is e2): - e.grav(e2, 1.0) + if not (e is e2): + e.grav(e2, 1.0) for e in es: e.move(1.0) if AA: - x = int((e.x % W) * 0x100) - y = int(e.y * 0x100) - if e.vx > 0.2: - gfx.VLineAA(bk.context, x + 0x100, y - 0x300, y + 0x300, black) - if e.vx < -0.2: - gfx.VLineAA(bk.context, x - 0x100, y - 0x300, y + 0x300, black) - gfx.PutPixelAA(bk.context, x, y, bk.context.RGBToPixel(e.r, e.g, e.b)) + x = int((e.x % W) * 0x100) + y = int(e.y * 0x100) + if e.vx > 0.2: + gfx.VLineAA(bk.context, x + 0x100, y - 0x300, y + 0x300, black) + if e.vx < -0.2: + gfx.VLineAA(bk.context, x - 0x100, y - 0x300, y + 0x300, black) + gfx.PutPixelAA(bk.context, x, y, bk.context.RGBToPixel(e.r, e.g, e.b)) else: - x = int(e.x % W) - y = int(e.y) - if e.vx > 0.2: - gfx.VLine(bk.context, x + 1, y - 2, y + 2, black) - if e.vx < -0.2: - gfx.VLine(bk.context, x - 1, y - 2, y + 2, black) - core.PutPixel(bk.context, x, y, bk.context.RGBToPixel(e.r, e.g, e.b)) + x = int(e.x % W) + y = int(e.y) + if e.vx > 0.2: + gfx.VLine(bk.context, x + 1, y - 2, y + 2, black) + if e.vx < -0.2: + gfx.VLine(bk.context, x - 1, y - 2, y + 2, black) + core.PutPixel(bk.context, x, y, bk.context.RGBToPixel(e.r, e.g, e.b)) bk.Flip() global TIMEOUT if TIMEOUT > 0: diff --git a/demos/py_simple/plot.py b/demos/py_simple/plot.py index 96ce3e3..d58e574 100755 --- a/demos/py_simple/plot.py +++ b/demos/py_simple/plot.py @@ -15,71 +15,71 @@ env['cos'] = cos env['sqrt'] = sqrt
def compute(func, x, y_min, y_max): - env['x'] = x - try: - ret = eval(func, env) - except ZeroDivisionError, d: - return -1 + env['x'] = x + try: + ret = eval(func, env) + except ZeroDivisionError: + return -1
- return - H * ret / (y_max - y_min) + (H * y_max) / (y_max - y_min) + return - H * ret / (y_max - y_min) + (H * y_max) / (y_max - y_min)
def x_to_x(x, x_min, x_max): - return (x_max - x_min) * x / W + x_min + return (x_max - x_min) * x / W + x_min
class plotter(object): - def __init__(self, func, x_min, x_max, y_min, y_max): - self.x = 0.0 - self.y = compute(func, x_to_x(self.x, x_min, x_max), y_min, y_max) - self.y_min = y_min - self.y_max = y_max - self.x_min = x_min - self.x_max = x_max - self.func = func - def next(self): - x = x_to_x(self.x + 1, self.x_min, self.x_max) - new_y = compute(self.func, x, self.y_min, self.y_max) - - inc = 1.0 - - while (abs(new_y - self.y) > 1 and inc > EPS): - x = x_to_x(self.x + inc, self.x_min, self.x_max) - new_y = compute(self.func, x, self.y_min, self.y_max) - inc /= 2 - - self.x += inc - self.y = new_y - - print self.x, self.y + def __init__(self, func, x_min, x_max, y_min, y_max): + self.x = 0.0 + self.y = compute(func, x_to_x(self.x, x_min, x_max), y_min, y_max) + self.y_min = y_min + self.y_max = y_max + self.x_min = x_min + self.x_max = x_max + self.func = func + def next(self): + x = x_to_x(self.x + 1, self.x_min, self.x_max) + new_y = compute(self.func, x, self.y_min, self.y_max) + + inc = 1.0 + + while (abs(new_y - self.y) > 1 and inc > EPS): + x = x_to_x(self.x + inc, self.x_min, self.x_max) + new_y = compute(self.func, x, self.y_min, self.y_max) + inc /= 2 + + self.x += inc + self.y = new_y + + print(self.x, self.y)
def main(): - bk = backends.BackendSDLInit(W, H, 0, 0, "Plot AA") - assert bk - print bk - print "Modify source for parameters," - print "Kill to terminate ;-)" - print "Usage: function x_min x_max y_min y_max" - black = bk.context.RGBToPixel(0, 0, 0) - - x_min = float(sys.argv[2]) - x_max = float(sys.argv[3]) - y_min = float(sys.argv[4]) - y_max = float(sys.argv[5]) - p = plotter(sys.argv[1], x_min, x_max, y_min, y_max) - - r = 255 - g = 0 - b = 0 - - while p.x < W: - x = int((p.x + 0.5) * 0x100) - y = int((p.y + 0.5) * 0x100) - gfx.PutPixelAA(bk.context, x, y, bk.context.RGBToPixel(int(r), int(g), int(b))) - bk.Flip() - p.next() - - while True: - pass + bk = backends.BackendSDLInit(W, H, 0, 0, "Plot AA") + assert bk + print(bk) + print("Modify source for parameters,") + print("Kill to terminate ;-)") + print("Usage: function x_min x_max y_min y_max") + black = bk.context.RGBToPixel(0, 0, 0) + + x_min = float(sys.argv[2]) + x_max = float(sys.argv[3]) + y_min = float(sys.argv[4]) + y_max = float(sys.argv[5]) + p = plotter(sys.argv[1], x_min, x_max, y_min, y_max) + + r = 255 + g = 0 + b = 0 + + while p.x < W: + x = int((p.x + 0.5) * 0x100) + y = int((p.y + 0.5) * 0x100) + gfx.PutPixelAA(bk.context, x, y, bk.context.RGBToPixel(int(r), int(g), int(b))) + bk.Flip() + p.next() + + while True: + pass
if __name__ == '__main__': - main() + main() diff --git a/demos/py_simple/sinplots_AA.py b/demos/py_simple/sinplots_AA.py index aa86bf9..1d29329 100755 --- a/demos/py_simple/sinplots_AA.py +++ b/demos/py_simple/sinplots_AA.py @@ -31,9 +31,9 @@ class plotter(object): def main(): bk = backends.BackendSDLInit(W, H, 16, 0, "Sinplots AA") assert bk - print bk - print "Modify source for parameters," - print "Kill to terminate ;-)" + print(bk) + print("Modify source for parameters,") + print("Kill to terminate ;-)") black = bk.context.RGBToPixel(0, 0, 0)
ps = [plotter() for i in range(N)] @@ -44,15 +44,15 @@ def main(): (x, y) = p.pos(t) (r, g, b) = p.color(t) if AA: - x = int(x * 0x100) - y = int(y * 0x100) - gfx.VLineAA(bk.context, x + 0x100, y - 0x200, y + 0x200, black) - gfx.PutPixelAA(bk.context, x, y, bk.context.RGBToPixel(int(r), int(g), int(b))) + x = int(x * 0x100) + y = int(y * 0x100) + gfx.VLineAA(bk.context, x + 0x100, y - 0x200, y + 0x200, black) + gfx.PutPixelAA(bk.context, x, y, bk.context.RGBToPixel(int(r), int(g), int(b))) else: - x = int(x) - y = int(y) - gfx.VLine(bk.context, x + 1, y - 2, y + 2, black) - core.PutPixel(bk.context, x, y, bk.context.RGBToPixel(int(r), int(g), int(b))) + x = int(x) + y = int(y) + gfx.VLine(bk.context, x + 1, y - 2, y + 2, black) + core.PutPixel(bk.context, x, y, bk.context.RGBToPixel(int(r), int(g), int(b))) bk.Flip()
if __name__ == '__main__': diff --git a/pylib/gfxprim/backends/__init__.py b/pylib/gfxprim/backends/__init__.py index 224e0e5..f0ebdae 100644 --- a/pylib/gfxprim/backends/__init__.py +++ b/pylib/gfxprim/backends/__init__.py @@ -22,7 +22,7 @@ def _init(module): extend_context(Context)
# Extend GP_Backend with convenience methods - from _extend_backend import extend_backend + from ._extend_backend import extend_backend extend_backend(Backend)
# Import some members from the SWIG module
-----------------------------------------------------------------------
Summary of changes: demos/py_simple/gravplots_AA.py | 38 ++++++------ demos/py_simple/plot.py | 116 ++++++++++++++++++------------------ demos/py_simple/sinplots_AA.py | 22 ++++---- pylib/gfxprim/backends/__init__.py | 2 +- 4 files changed, 89 insertions(+), 89 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.