예제 #1
0
 def zoom_in(self):
     if self._zoom <= 0.33:
         self._zoom += 0.33
     elif self._zoom <= 0.5:
         self._zoom += 0.5
     else:
         self._zoom += 1
     self.set_transform()
     self.strokeWidth = 1 / self._zoom
     self.cursorSize = 2 / self._zoom
     self.move_cursor(self._last_cursor_pos)
     if not self._do_drawing:
         window.requestAnimationFrame(self.draw)
예제 #2
0
 def zoom_out(self):
     if self._zoom > 1:
         self._zoom -= 1
     elif self._zoom > 0.5:
         self._zoom -= 0.5
     elif self._zoom > 0.33:
         self._zoom -= 0.33
     self.set_transform()
     #self.strokeWidth = 0.25 if self._zoom > 1 else 1
     self.strokeWidth = 1 / self._zoom
     self.cursorSize = 2 / self._zoom
     self.move_cursor(self._last_cursor_pos)
     if not self._do_drawing:
         window.requestAnimationFrame(self.draw)
예제 #3
0
 def draw(self):
     if self._do_drawing:
         window.requestAnimationFrame(self.draw)
     self.ctx.setTransform(1, 0, 0, 1, 0, 0)
     self.ctx.clearRect(0, 0, self.ctx.canvas.width, self.ctx.canvas.height)
     self.set_transform()
     self.ctx.lineWidth = self.strokeWidth
     self.ctx.lineCap = self.lineCap
     self.ctx.strokeStyle = self.strokeColor
     if self._line_paths:
         self.ctx.stroke(self._line_paths)
     self.ctx.fillStyle = self.cursorColor
     if self._cursor_paths:
         self.ctx.fill(self._cursor_paths)
예제 #4
0
 def move(self, x, y):
     self._position = (self._mouse_down_position[0] + x,
                       self._mouse_down_position[1] + y)
     self.set_transform()
     if not self._do_drawing:
         window.requestAnimationFrame(self.draw)
예제 #5
0
 def clear(self):
     self._line_paths = []
     self._cursor_paths = []
     if not self._do_drawing:
         window.requestAnimationFrame(self.draw)
예제 #6
0
 def start_drawing(self):
     if not self._do_drawing:
         self._do_drawing = True
         window.requestAnimationFrame(self.draw)
예제 #7
0
 def force_redraw(self):
     if not self._do_drawing:
         window.requestAnimationFrame(self.draw)