def draw( self, surface, interpol, time_sec ): Component.draw( self, surface, interpol, time_sec ) draw.rect( surface, (255,255,255), self.place.get_tuple(), 2 ) val = (self.place.get_right() - self.place.pos.x) * self._value slide = Rectangle( self.place.pos.x + val - 1, self.place.pos.y, 3, self.place.size.y ) draw.rect( surface, (255,255,255), slide.get_tuple(), 2 )
def draw(self, surface, interpol, time_sec): Component.draw(self, surface, interpol, time_sec) draw.rect(surface, (255, 255, 255), self.place.get_tuple(), 2) val = (self.place.get_right() - self.place.pos.x) * self._value slide = Rectangle(self.place.pos.x + val - 1, self.place.pos.y, 3, self.place.size.y) draw.rect(surface, (255, 255, 255), slide.get_tuple(), 2)
def draw(self, surface, interpol, time_sec): val = (self.place.right - self.place.left) * self._value if self.button is not None: self.button.pos = Vec2D(self.place.left + val, self.place.top + self.place.height / 2) rect = Rectangle(0, 0, val, self.place.height) self.sprite.nr = 1 self.sprite.draw(surface, self.place.pos, rect) rect = Rectangle(val, 0, self.place.width - val, self.place.height) self.sprite.nr = 0 pos = self.place.pos + Vec2D(val, 0) self.sprite.draw(surface, pos, rect) Component.draw(self, surface, interpol, time_sec)
def __init__( self, pos, sprite, button = None): size = sprite.get_size() Slider.__init__( self, Rectangle.from_pos_size(pos, Vec2D(size[0], size[1]) ) ) self.sprite = sprite self.button = button if button is not None: self.add_subcomponent( button ) self.delegate_active = self.button
def __init__(self, pos, sprite, button=None): size = sprite.get_size() Slider.__init__(self, Rectangle.from_pos_size(pos, Vec2D(size[0], size[1]))) self.sprite = sprite self.button = button if button is not None: self.add_subcomponent(button) self.delegate_active = self.button
def __init__(self, sprite, pos=Vec2D(0, 0)): """Create a new instance sprite is a gfx.Sprite with 5 frames: normal, selected, normal-active, selected-active, disabled """ Checkbox.__init__(self, Rectangle(pos.x, pos.y, sprite.width, sprite.height)) self.sprite = sprite self.sprite.nr = 1 self.animTimer = PingPongTimer(20, 1, 3)
def draw( self, surface, pos, rect = None ): """Draw the sprite on the surface at pos pos is a Vec2D """ sp_x = (self.nr % self.max_x) * self.width sp_y = (self.nr / self.max_x) * self.height sprite_rect = [sp_x, sp_y, self.width, self.height] if rect is not None: r = copy.copy(rect) r.pos = r.pos + Vec2D(sp_x, sp_y) sprite_rect = (Rectangle.from_tuple(sprite_rect) & r).get_tuple() self.surface.draw( surface, pos - self.center, sprite_rect)
def __init__(self, sprite, pos=Vec2D(0, 0)): """Create a new instance sprite is a gfx.Sprite with 3 frames: normal, active, disabled """ Button.__init__( self, Rectangle( pos.x, # - sprite.center.x, pos.y, # - sprite.center.y, sprite.width, sprite.height)) self.sprite = sprite self.sprite.nr = 0 self.label = None
def draw(self, surface, pos, rect=None): """Draw the sprite on the surface at pos pos is a Vec2D """ sp_x = (self.nr % self.max_x) * self.width sp_y = (self.nr / self.max_x) * self.height sprite_rect = [sp_x, sp_y, self.width, self.height] if rect is not None: r = copy.copy(rect) r.pos = r.pos + Vec2D(sp_x, sp_y) sprite_rect = (Rectangle.from_tuple(sprite_rect) & r).get_tuple() self.surface.draw(surface, pos - self.center, sprite_rect)
def __init__(self): """Creates new instance""" self.subs = [] self.is_enabled = True self.is_visible = True self.place = Rectangle(0, 0, 0, 0)
def __init__(self, place=Rectangle(0, 0, 0, 0)): InteractiveComponent.__init__(self, place) self._value = 0.5 self._old_value = self._value self._is_sliding = False
def __init__(self, place=Rectangle(0, 0, 0, 0), selected=False): Button.__init__(self, place) self.selected = selected
def __init__(self, place=Rectangle(0, 0, 0, 0)): InteractiveComponent.__init__(self, place) self.label = None self._went_down = False self.is_down = False self.active = False
return pdf from PIL import Image if __name__ == "__main__": files = list( get_files_in_dir("C:/Users/andris/Desktop/00066_stabilized_adjusted")) step = int(len(files) / 20) files = files[::step] n = len(files) print("create pdf...") pdf = PDF(orientation='P', unit='in', format='A4') pdf.line_width = 0 print("create rectangles...") image = Image.open(files[0]) image_rect = Rectangle(0, 0, image.height, image.width) page_rect = Rectangle(0, 0, pdf.h, pdf.w) print_rect = page_rect.shrink(0.5) rect = image_rect.fitIn(print_rect) rectangles = [persp(rect, k=400, distance=i * step) for i in range(n)] print("put images on pdf...") compose_pdf(files, rectangles, pdf) pdf.output("platasorok.pdf", 'F') import os os.startfile("platasorok.pdf")
def persp(rect: tuple, k: float, distance: float) -> tuple: top, left, bottom, right = rect center = ((left + right) / 2, (top + bottom) / 2) factor = 1 / (1 + distance / k) return Rectangle.scale(rect, factor, center)