diff --git a/screensaver.py b/screensaver.py index b3358ff..a5ef5bc 100644 --- a/screensaver.py +++ b/screensaver.py @@ -41,10 +41,16 @@ class Wobbler: self.image_original = random.choice(images) - self.max_width, self.max_height = self.image_original.get_size() + self.divider = 1 - self.width = self.max_width * self.size / 100 - self.height = self.max_height * self.size / 100 + self.max_width, self.max_height = self.image_original.get_size() + while self.max_width > max_wobbler_size * 2 or self.max_height > max_wobbler_size * 2: + self.divider += 0.01 + self.max_width = self.image_original.get_width() / self.divider + self.max_height = self.image_original.get_height() / self.divider + + self.width = self.max_width * self.size / 100 / self.divider + self.height = self.max_height * self.size / 100 / self.divider self.image = self.image_original self.image = pygame.transform.scale(self.image, (self.width, self.height)) @@ -56,8 +62,8 @@ class Wobbler: screen.blit(self.image, self.image_rect) def update(self): - self.width = self.max_width * self.size / 100 - self.height = self.max_height * self.size / 100 + self.width = self.max_width * self.size / 100 / self.divider + self.height = self.max_height * self.size / 100 / self.divider self.image = self.image_original self.image = pygame.transform.scale(self.image, (self.width, self.height))