frame.py 495 B

12345678910111213141516171819
  1. import numpy
  2. import pygame
  3. class Frame:
  4. def __init__(self, image: pygame.Surface, cx, cy):
  5. self.image = image
  6. self.cx = cx
  7. self.cy = cy
  8. self.alpha = None
  9. def get_alpha(self):
  10. arr = pygame.surfarray.array_alpha(self.image).reshape((self.image.get_size()[0], self.image.get_size()[1], 1))
  11. self.alpha = numpy.tile(arr, (1, 1, 3)) / 255
  12. def duplicate(self):
  13. img = self.image.copy()
  14. return Frame(img, self.cx, self.cy)