def test_SDL_RenderDrawPoint(self): points = ((-4, -3), (-4, 3), (4, -3), (0, 0), (1, 1), (10, 10), (99, 99), (4, 22), (57, 88), (45, 15), (100, 100)) r, g, b, a = 0xAA, 0xBB, 0xCC, 0xDD w, h = 100, 100 sf = surface.SDL_CreateRGBSurface(0, w, h, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF) color = pixels.SDL_MapRGBA(sf.contents.format, r, g, b, a) renderer = render.SDL_CreateSoftwareRenderer(sf) self.assertIsInstance(renderer.contents, render.SDL_Renderer) ret = render.SDL_SetRenderDrawColor(renderer, r, g, b, a) self.assertEqual(ret, 0) for x, y in points: ret = render.SDL_RenderDrawPoint(renderer, x, y) self.assertEqual(ret, 0) render.SDL_RenderPresent(renderer) view = PixelView(sf.contents) for x, y in points: npx = max(x + 1, w) npy = max(y + 1, h) ppx = max(x - 1, 0) ppy = max(y - 1, 0) if x < 0 or x >= w or y < 0 or y >= h: continue self.assertEqual(hex(view[y][x]), hex(color)) if (npx, npy) not in points: self.assertNotEqual(hex(view[npy][npx]), hex(color)) if (ppx, ppy) not in points: self.assertNotEqual(hex(view[ppy][ppx]), hex(color)) render.SDL_DestroyRenderer(renderer) del view surface.SDL_FreeSurface(sf)
def draw_magenta_pixel(x, y): ret = render.SDL_SetRenderDrawColor(renderer, magenta[0], magenta[1], magenta[2], magenta[3]) self.assertEqual(ret, 0) ret = render.SDL_RenderDrawPoint(renderer, x, y) self.assertEqual(ret, 0)
def draw_magenta_pixel(x, y): ret = render.SDL_SetRenderDrawColor(renderer, magenta[0], magenta[1], magenta[2], magenta[3]) assert ret == 0 ret = render.SDL_RenderDrawPoint(renderer, x, y) assert ret == 0