Example #1
0
    def selection_del(self):
        x, y = self.get_selection_pos()
        w, h = self.get_selection_size()

        self.app.aPaint.fbo.bind()
        improc.texture_replace_color(tex=self.app.aPaint.fbo.texture, pos=(x, y), color=0, size=(w, h))
        self.app.aPaint.fbo.release()
        self.app.aPaint.fbo.clear()
        self.app.aPaint.fbo.draw()
        self.app.aPaint.canvas.ask_update()
Example #2
0
 def fbo_replace_color(self, touch, width):
     cx = int(touch.x / self.scale - self.fbo_rect.pos[0])
     cy = int(touch.y / self.scale - self.fbo_rect.pos[1])
     if self.px is None:
         self.px = cx
     if self.py is None:
         self.py = cy
     if (cx - self.px) > 0:
         tg_alpha = float((cy - self.py)) / (cx - self.px)
         step = int(math.copysign(1, tg_alpha))
         if abs(cx - self.px) > abs(cy - self.py):
             coords = [(x, self.py + (x - self.px) * tg_alpha) for x in xrange(int(self.px), int(cx))]
         else:
             coords = [(self.px + (y - self.py) / tg_alpha, y) for y in xrange(int(self.py), int(cy), step)]
     elif (cx - self.px) < 0:
         tg_alpha = float((cy - self.py)) / (cx - self.px)
         step = int(math.copysign(1, tg_alpha))
         if abs(cx - self.px) > abs(cy - self.py):
             coords = [(x, self.py + (x - self.px) * tg_alpha) for x in xrange(int(cx), int(self.px))]
         else:
             coords = [(self.px + (y - self.py) / tg_alpha, y) for y in xrange(int(cy), int(self.py), step)]
     elif (cx - self.px) == 0:
         if (cy - self.py) > 0:
             coords = [(cx, y) for y in xrange(int(self.py), int(cy))]
         elif (cy - self.py) < 0:
             coords = [(cx, y) for y in xrange(int(cy), int(self.py))]
         else:
             coords = [(cx, cy), ]
     self.fbo.bind()
     for (x, y) in coords:
         improc.texture_replace_color(tex=self.fbo.texture, pos=(x, y), color=0, size=(width, width))
     self.fbo.release()
     self.fbo.clear()
     self.fbo.draw()
     self.canvas.ask_update()
     self.px = cx
     self.py = cy