def test_set_pixel(self): img = image_factory([ [Black, Black], [Black, Black], ]) img.set_color(0, 0, White) self.assertImage(img, [ [White, Black], [Black, Black], ])
def test_draw_pixel(self): img = image_factory([ [Black, Black], [Black, Black], ]) pixel = Pixel(0, 0) img.draw(pixel, White) self.assertImage(img, [ [White, Black], [Black, Black], ])
def test_blit_partial(self): main = image_factory([ [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], ]) other = image_factory([ [White, White, White], [White, White, White], [White, White, White], ]) main.blit(3, 3, other) self.assertImage(main, [ [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, White, White], [Black, Black, Black, White, White], ])
def test_blit_simple(self): main = image_factory([ [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], ]) other = image_factory([ [White, White, White], [White, White, White], [White, White, White], ]) main.blit(1, 1, other) self.assertImage(main, [ [Black, Black, Black, Black, Black], [Black, White, White, White, Black], [Black, White, White, White, Black], [Black, White, White, White, Black], [Black, Black, Black, Black, Black], ])
def test_blit_partial(self): main = image_factory([ [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], ]) other =image_factory([ [White, White, White], [White, White, White], [White, White, White], ]) main.blit(3, 3, other) self.assertImage(main, [ [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, White, White], [Black, Black, Black, White, White], ])
def test_blit_simple(self): main = image_factory([ [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], ]) other =image_factory([ [White, White, White], [White, White, White], [White, White, White], ]) main.blit(1, 1, other) self.assertImage(main, [ [Black, Black, Black, Black, Black], [Black, White, White, White, Black], [Black, White, White, White, Black], [Black, White, White, White, Black], [Black, Black, Black, Black, Black], ])
def test_draw_line_steep(self): img = image_factory([ [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], ]) line = Line(0, 0, 1, 4) img.draw(line, White) self.assertImage(img, [ [White, Black, Black, Black, Black], [White, Black, Black, Black, Black], [Black, White, Black, Black, Black], [Black, White, Black, Black, Black], [Black, White, Black, Black, Black], ])
def test_draw_line_topright_bottomleft(self): img = image_factory([ [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], [Black, Black, Black, Black, Black], ]) line = Line(4, 0, 0, 4) img.draw(line, White) self.assertImage(img, [ [Black, Black, Black, Black, White], [Black, Black, Black, White, Black], [Black, Black, White, Black, Black], [Black, White, Black, Black, Black], [White, Black, Black, Black, Black], ])
def create_canvas(): column = [Black for i in range(1000)] blacks = [column for i in range(1000)] img = image_factory(blacks) return img
def _get_fake_image(self): return image_factory([ [Red, Green, Blue], [Green, Blue, Red], [Blue, Red, Green], ])
def test_alpha_mixing(self): img = image_factory([[Red]]) semi_transparent_green = Lime.get_for_brightness(0.5) img.draw(Pixel(0, 0), semi_transparent_green) result = img.get_color(0, 0) self.assertEqual(result, Color(128, 127, 0, 255))