[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] PATCH #147 - gfxdraw doesn't work with inherited surfaces
- To: pygame-users@xxxxxxxx
- Subject: [pygame] PATCH #147 - gfxdraw doesn't work with inherited surfaces
- From: Piotr Borkowski <borko84@xxxxxxxxx>
- Date: Sun, 20 Jan 2013 10:13:00 +0100
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sun, 20 Jan 2013 04:13:08 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:x-forwarded-message-id:content-type; bh=z/8zsvyy2gZjdXV9/4PzEIddiY0pJ+m6aZ4O2GQDA54=; b=R45GLblDv96iIKATofj88X2nldTQAxQdboXUiw9POfdtDwIwiVSofF/icqgwk1KLIM vk0D6Byybcgx4w65L1pBStvsewYSCbIGYOljpLga5qGb9gKm/khlH2SH/OXuicIRqGs0 Ah6bBy4ITncxuCSvr8e3FaE6PQ2/1YGh3ovxbV6LS8EwZR1fKpZHoIH2VTPKVIprE8aI OdBE0vukvz5QBSF6XQwj/9mVxFovxwQNiJZbFZJ0Wtg9XKYiOLtKQuaqbf3Y+Y787Yse GGYslfcFfzGec5DlG0ATaMkbOETTBQKg4EHuioQK52qyYJucDtYf6dMxPSOGEFW5tpxn Jf/g==
- In-reply-to: <50F327B0.5070507@xxxxxxxxx>
- References: <50F327B0.5070507@xxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0
diff -r 4a4611239021 src/gfxdraw.c
--- a/src/gfxdraw.c Thu Jan 10 14:18:39 2013 +0000
+++ b/src/gfxdraw.c Sun Jan 13 22:30:53 2013 +0100
@@ -237,6 +237,7 @@
PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
return NULL;
}
+
sdlrect = GameRect_FromObject (rect, &temprect);
if (sdlrect == NULL) {
return NULL;
@@ -274,9 +275,8 @@
if (!PyArg_ParseTuple (args, "OOO:box", &surface, &rect, &color)) {
return NULL;
}
-
- if (!PySurface_Check (surface)) {
- PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
+ if (!PyType_IsSubtype(surface->ob_type, &PySurface_Type)) {
+ PyErr_SetString (PyExc_TypeError, "surface must be a subclass
of Surface");
return NULL;
}
sdlrect = GameRect_FromObject (rect, &temprect);
diff -r 4a4611239021 test/gfxdraw_test.py
--- a/test/gfxdraw_test.py Thu Jan 10 14:18:39 2013 +0000
+++ b/test/gfxdraw_test.py Sun Jan 13 22:30:53 2013 +0100
@@ -21,6 +21,12 @@
import pygame.gfxdraw
from pygame.locals import *
+
+class Frame(pygame.Surface,object):
+ def __init__(self,x,y,w,h):
+ pygame.Surface.__init__(self,(w,h), SRCALPHA)
+
+
def intensity(c, i):
"""Return color c changed by intensity i
@@ -707,6 +713,11 @@
self.check_at(surf, posn, bg_adjusted)
+ def test_my(self):
+ """ """
+ pygame.display.set_mode((500,500))
+ fr = Frame(50,50,300,300)
+ pygame.gfxdraw.box(fr,pygame.Rect(0,0,50,50),pygame.Color('red'))
if __name__ == '__main__':
unittest.main()
diff -r 4a4611239021 src/gfxdraw.c
--- a/src/gfxdraw.c Thu Jan 10 14:18:39 2013 +0000
+++ b/src/gfxdraw.c Sun Jan 13 22:30:53 2013 +0100
@@ -237,6 +237,7 @@
PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
return NULL;
}
+
sdlrect = GameRect_FromObject (rect, &temprect);
if (sdlrect == NULL) {
return NULL;
@@ -274,9 +275,8 @@
if (!PyArg_ParseTuple (args, "OOO:box", &surface, &rect, &color)) {
return NULL;
}
-
- if (!PySurface_Check (surface)) {
- PyErr_SetString (PyExc_TypeError, "surface must be a Surface");
+ if (!PyType_IsSubtype(surface->ob_type, &PySurface_Type)) {
+ PyErr_SetString (PyExc_TypeError, "surface must be a subclass of Surface");
return NULL;
}
sdlrect = GameRect_FromObject (rect, &temprect);
diff -r 4a4611239021 test/gfxdraw_test.py
--- a/test/gfxdraw_test.py Thu Jan 10 14:18:39 2013 +0000
+++ b/test/gfxdraw_test.py Sun Jan 13 22:30:53 2013 +0100
@@ -21,6 +21,12 @@
import pygame.gfxdraw
from pygame.locals import *
+
+class Frame(pygame.Surface,object):
+ def __init__(self,x,y,w,h):
+ pygame.Surface.__init__(self,(w,h), SRCALPHA)
+
+
def intensity(c, i):
"""Return color c changed by intensity i
@@ -707,6 +713,11 @@
self.check_at(surf, posn, bg_adjusted)
+ def test_my(self):
+ """ """
+ pygame.display.set_mode((500,500))
+ fr = Frame(50,50,300,300)
+ pygame.gfxdraw.box(fr,pygame.Rect(0,0,50,50),pygame.Color('red'))
if __name__ == '__main__':
unittest.main()