X-Git-Url: https://scm.cri.mines-paristech.fr/git/minwii.git/blobdiff_plain/29dfa14e4419fb6ceb9350223f410e967e8cc4f6..5fd262589f4c98f0f37c7b9806c12446fd1f8e92:/src/kinect/pygamedisplay.py?ds=inline diff --git a/src/kinect/pygamedisplay.py b/src/kinect/pygamedisplay.py index 82621ea..7b646ad 100755 --- a/src/kinect/pygamedisplay.py +++ b/src/kinect/pygamedisplay.py @@ -38,6 +38,28 @@ class RGB : return self.context.wait_one_update_all(self.imgGene) +class RGBSprite(pygame.sprite.DirtySprite, RGB) : + + def __init__(self, alpha=255, size=SCREEN_SIZE) : + pygame.sprite.DirtySprite.__init__(self) + RGB.__init__(self) + self.dirty = 2 # toujours dirty ! + self.size = size + self.image = pygame.Surface(size) + self.workSur = pygame.Surface(SCREEN_SIZE) + self.image.set_alpha(alpha) + self.rect = pygame.Rect((0, 0), (0, 0)) + + def update(self) : + RGB.update(self) + img = self.capture() + self.workSur.blit(img, (0, 0)) + self.workSur = pygame.transform.flip(self.workSur, True, False) # miroir + if self.size != SCREEN_SIZE : + pygame.transform.scale(self.workSur, self.size, self.image) # étirement, blit implicite + else : + self.image.blit(self.workSur, (0, 0)) + def main() : pygame.init()