예제 #1
0
파일: gui.py 프로젝트: heinervdm/MysticMine
    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 )
예제 #2
0
파일: gui.py 프로젝트: undent/MysticMine
    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)
예제 #3
0
파일: gui.py 프로젝트: undent/MysticMine
    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)
예제 #4
0
파일: gui.py 프로젝트: heinervdm/MysticMine
    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
예제 #5
0
파일: gui.py 프로젝트: undent/MysticMine
    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
예제 #6
0
파일: gui.py 프로젝트: undent/MysticMine
    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)
예제 #7
0
파일: gfx.py 프로젝트: aither64/MysticMine
    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)
예제 #8
0
파일: gui.py 프로젝트: undent/MysticMine
    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
예제 #9
0
파일: gfx.py 프로젝트: undent/MysticMine
    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)
예제 #10
0
파일: gui.py 프로젝트: undent/MysticMine
 def __init__(self):
     """Creates new instance"""
     self.subs = []
     self.is_enabled = True
     self.is_visible = True
     self.place = Rectangle(0, 0, 0, 0)
예제 #11
0
파일: gui.py 프로젝트: undent/MysticMine
 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
예제 #12
0
파일: gui.py 프로젝트: undent/MysticMine
    def __init__(self, place=Rectangle(0, 0, 0, 0), selected=False):
        Button.__init__(self, place)

        self.selected = selected
예제 #13
0
파일: gui.py 프로젝트: undent/MysticMine
 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
예제 #14
0
    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")
예제 #15
0
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)