Exemplo n.º 1
0
 def __on_ocr_rotation_anim_done_cb(self):
     self.rotation_done = True
     for angle in list(self.ocr_drawers.keys())[:]:
         if self.__used_angles and angle not in self.__used_angles:
             self._disable_angle(angle)
         else:
             img_drawer = self.ocr_drawers[angle][0]
             spinner_bg = RectangleDrawer(
                 img_drawer.position, img_drawer.size,
                 inside_color=(0.0, 0.0, 0.0, 0.1),
                 angle=angle,
             )
             spinner_bg.set_canvas(self.canvas)
             spinner_bg.redraw()
             spinner = SpinnerAnimation(
                 (
                     (img_drawer.position[0] + (img_drawer.size[0] / 2)) -
                     (SpinnerAnimation.ICON_SIZE / 2),
                     (img_drawer.position[1] + (img_drawer.size[1] / 2)) -
                     (SpinnerAnimation.ICON_SIZE / 2)
                 )
             )
             spinner.set_canvas(self.canvas)
             self.ocr_drawers[angle] = [img_drawer, spinner_bg, spinner]
             self.animators.append(spinner)
     # TODO(Jflesch): There are artefacts visible after the rotation
     # -> this is just the lazy way of getting rid of them.
     # there shouldn't be artefact in a first place
     self.canvas.redraw()
Exemplo n.º 2
0
 def __init__(self, position):
     Animation.__init__(self)
     self.position = position
     self.scan_animation = None
     self.size = self.DEFAULT_SIZE
     self.drawers = [
         RectangleDrawer(self.position, self.size,
                         inside_color=ScanAnimation.BACKGROUND_COLOR),
     ]
Exemplo n.º 3
0
 def __on_process_done(self, img):
     size = fit(img.size, self.size)
     img = img.resize(size)
     self.drawers = [
         RectangleDrawer(self.position, self.size,
                         inside_color=ScanAnimation.BACKGROUND_COLOR),
         PillowImageDrawer(self.position, img)
     ]
     self.set_canvas(self.canvas)  # reset canvas on all new drawers
     self.canvas.redraw()
Exemplo n.º 4
0
 def __on_scan_info(self, size):
     self.scan_animation = ScanAnimation(self.position, size, self.size)
     self.drawers = [
         RectangleDrawer(self.position, self.size,
                         inside_color=ScanAnimation.BACKGROUND_COLOR),
         self.scan_animation,
     ]
     assert(self.canvas)
     self.set_canvas(self.canvas)  # reset canvas on all new drawers
     for drawer in self.drawers:
         drawer.redraw()
Exemplo n.º 5
0
 def __on_ocr_rotation_anim_done_cb(self):
     self.rotation_done = True
     for angle in list(self.ocr_drawers.keys())[:]:
         if self.__used_angles and angle not in self.__used_angles:
             self._disable_angle(angle)
         else:
             img_drawer = self.ocr_drawers[angle][0]
             spinner_bg = RectangleDrawer(
                 img_drawer.position,
                 img_drawer.size,
                 inside_color=(0.0, 0.0, 0.0, 0.1),
                 angle=angle,
             )
             spinner_bg.set_canvas(self.canvas)
             spinner_bg.redraw()
             spinner = SpinnerAnimation(
                 ((img_drawer.position[0] + (img_drawer.size[0] / 2)) -
                  (SpinnerAnimation.ICON_SIZE / 2),
                  (img_drawer.position[1] + (img_drawer.size[1] / 2)) -
                  (SpinnerAnimation.ICON_SIZE / 2)))
             spinner.set_canvas(self.canvas)
             self.ocr_drawers[angle] = [img_drawer, spinner_bg, spinner]
             self.animators.append(spinner)
     # TODO(Jflesch): There are artefacts visible after the rotation
     # -> this is just the lazy way of getting rid of them.
     # there shouldn't be artefact in a first place
     self.canvas.redraw()
Exemplo n.º 6
0
 def __on_scan_done(self, img):
     size = fit(img.size, self.size)
     img = img.resize(size)
     self.scan_animation = None
     self.drawers = [
         RectangleDrawer(self.position, self.size,
                         inside_color=ScanAnimation.BACKGROUND_COLOR),
         PillowImageDrawer(self.position, img),
         SpinnerAnimation(((self.position[0] + (self.size[0] / 2) -
                            SpinnerAnimation.ICON_SIZE / 2),
                           (self.position[1] + (self.size[1] / 2) -
                            SpinnerAnimation.ICON_SIZE / 2))),
     ]
     self.set_canvas(self.canvas)  # reset canvas on all new drawers
     self.canvas.redraw()