def test_negative_offset(self): sub_img = create_image((150, 150), color=[100, 120, 130, 140]) img = SubImageSource(sub_img, size=(100, 100), offset=(-50, 0), image_opts=ImageOptions()).as_image() eq_(img.getcolors(), [(100 * 100, (100, 120, 130, 140))])
def test_larger(self): sub_img = create_image((150, 150), color=[100, 120, 130, 140]) img = SubImageSource(sub_img, size=(100, 100), offset=(0, 0), image_opts=ImageOptions()).as_image() assert img.getcolors() == [(100 * 100, (100, 120, 130, 140))]
def test_outside(self): sub_img = create_image((50, 50), color=[100, 120, 130, 140]) img = SubImageSource( sub_img, size=(100, 100), offset=(200, 0), image_opts=ImageOptions(transparent=True)).as_image() eq_(img.getcolors(), [(100 * 100, (255, 255, 255, 0))])
def test_overlap_right(self): sub_img = create_image((50, 50), color=[100, 120, 130, 140]) img = SubImageSource( sub_img, size=(100, 100), offset=(75, 25), image_opts=ImageOptions(transparent=True)).as_image() eq_(sorted(img.getcolors()), [(25 * 50, (100, 120, 130, 140)), (100 * 100 - 25 * 50, (255, 255, 255, 0))])
def test_outside(self): sub_img = create_image((50, 50), color=[100, 120, 130, 140]) img = SubImageSource(sub_img, size=(100, 100), offset=(200, 0), image_opts=ImageOptions(transparent=True)).as_image() eq_(img.getcolors(), [(100*100, (255, 255, 255, 0))])
def test_overlap_right(self): sub_img = create_image((50, 50), color=[100, 120, 130, 140]) img = SubImageSource(sub_img, size=(100, 100), offset=(75, 25), image_opts=ImageOptions(transparent=True)).as_image() eq_(sorted(img.getcolors()), [(25*50, (100, 120, 130, 140)), (100*100-25*50, (255, 255, 255, 0))])
def test_negative_offset(self): sub_img = create_image((150, 150), color=[100, 120, 130, 140]) img = SubImageSource(sub_img, size=(100, 100), offset=(-50, 0), image_opts=ImageOptions()).as_image() eq_(img.getcolors(), [(100*100, (100, 120, 130, 140))])