pixelarray_test.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:Projects 作者: it2school 项目源码 文件源码
def test_shape (self):
        for shape in [[4, 16], [5, 13]]:
            w, h = shape
            sf = pygame.Surface (shape, 0, 32)
            ar = pygame.PixelArray (sf)
            ai = arrinter.ArrayInterface (ar)
            ai_shape = [ai.shape[i] for i in range(ai.nd)]
            self.assertEqual (ai_shape, shape)
            ar2 = ar[::2,:]
            ai2 = arrinter.ArrayInterface (ar2)
            w2 = len(([0] * w)[::2])
            ai_shape = [ai2.shape[i] for i in range(ai2.nd)]
            self.assertEqual (ai_shape, [w2, h])
            ar2 = ar[:,::2]
            ai2 = arrinter.ArrayInterface (ar2)
            h2 = len(([0] * h)[::2])
            ai_shape = [ai2.shape[i] for i in range(ai2.nd)]
            self.assertEqual (ai_shape, [w, h2])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号