Exemple #1
0
 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],
     ])
Exemple #2
0
 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],
     ])
Exemple #3
0
 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],
     ])
Exemple #4
0
 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],
     ])
Exemple #5
0
 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],
     ])
Exemple #6
0
 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],
     ])
Exemple #7
0
 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],
     ])
Exemple #8
0
 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],
     ])
Exemple #9
0
 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],
     ])
Exemple #10
0
 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],
     ])
Exemple #11
0
 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],
     ])
Exemple #12
0
 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],
     ])
Exemple #13
0
def create_canvas():
    column = [Black for i in range(1000)]
    blacks = [column for i in range(1000)]
    img = image_factory(blacks)
    return img
Exemple #14
0
 def _get_fake_image(self):
     return image_factory([
         [Red, Green, Blue],
         [Green, Blue, Red],
         [Blue, Red, Green],
     ])
Exemple #15
0
 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))
Exemple #16
0
def create_canvas():
    column = [Black for i in range(1000)]
    blacks = [column for i in range(1000)]
    img = image_factory(blacks)
    return img
Exemple #17
0
 def _get_fake_image(self):
     return image_factory([
         [Red, Green, Blue],
         [Green, Blue, Red],
         [Blue, Red, Green],
     ])
Exemple #18
0
 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))