コード例 #1
0
    def apply(self):
        print(I18n.get('# From left to right, from top to bottom,'))
        near_color = 0

        for y in xrange(self.bot.image.height):
            for x in xrange(self.bot.image.width):
                color = EnumColor.rgb(self.bot.image.pix[x, y])
                old_color = self.bot.canvas.get_color(self.bot.start_x + x,
                                                      self.bot.start_y + y)
                if color != near_color and old_color != color and not color in self.colors_ignored and old_color not in self.colors_not_overwrite:
                    self.bot.paint(self.bot.start_x + x, self.bot.start_y + y,
                                   color)
                near_color = color
            near_color = 0

        print(I18n.get('# From right to left, from top to bottom,'))

        near_color = 0

        for y in xrange(self.bot.image.height):
            for x in reversed(xrange(self.bot.image.width)):
                color = EnumColor.rgb(self.bot.image.pix[x, y])
                old_color = self.bot.canvas.get_color(self.bot.start_x + x,
                                                      self.bot.start_y + y)
                if color != near_color and old_color != color and not color in self.colors_ignored and old_color not in self.colors_not_overwrite:
                    self.bot.paint(self.bot.start_x + x, self.bot.start_y + y,
                                   color)
                near_color = color
            near_color = 0

        print(I18n.get('# From top to bottom, from left to right,'))

        near_color = 0

        for x in xrange(self.bot.image.width):
            for y in xrange(self.bot.image.height):
                color = EnumColor.rgb(self.bot.image.pix[x, y])
                old_color = self.bot.canvas.get_color(self.bot.start_x + x,
                                                      self.bot.start_y + y)
                if color != near_color and old_color != color and not color in self.colors_ignored and old_color not in self.colors_not_overwrite:
                    self.bot.paint(self.bot.start_x + x, self.bot.start_y + y,
                                   color)
                near_color = color
            near_color = 0

        print(I18n.get('# From bottom to top, from left to right,'))

        near_color = 0

        for x in xrange(self.bot.image.width):
            for y in reversed(xrange(self.bot.image.height)):
                color = EnumColor.rgb(self.bot.image.pix[x, y])
                old_color = self.bot.canvas.get_color(self.bot.start_x + x,
                                                      self.bot.start_y + y)
                if color != near_color and old_color != color and not color in self.colors_ignored and old_color not in self.colors_not_overwrite:
                    self.bot.paint(self.bot.start_x + x, self.bot.start_y + y,
                                   color)
                near_color = color
            near_color = 0
コード例 #2
0
 def roll_dice(self, canvas):
     rnd_x = rnd_y = color = None
     while all(v is None
               for v in [rnd_x, rnd_y, color]) or canvas.get_color(
                   rnd_x, rnd_y) == color:
         rnd_x = self.random(self.bot.start_x,
                             self.bot.start_x + self.bot.image.width - 1)
         rnd_y = self.random(self.bot.start_y,
                             self.bot.start_y + self.bot.image.height - 1)
         color = EnumColor.rgb(
             self.bot.image.pix[rnd_x - self.bot.start_x,
                                rnd_y - self.bot.start_y], True)
     color = EnumColor.rgb(self.bot.image.pix[rnd_x - self.bot.start_x,
                                              rnd_y - self.bot.start_y])
     return rnd_x, rnd_y, color
コード例 #3
0
 def roll_dice(self, canvas):
     rnd_x = self.random(self.bot.start_x, self.bot.start_x + self.bot.image.width  - 1)
     rnd_y = self.random(self.bot.start_y, self.bot.start_y + self.bot.image.height - 1)
     color = EnumColor.rgb(self.bot.image.pix[rnd_x - self.bot.start_x, rnd_y - self.bot.start_y])
     if canvas.get_color(rnd_x, rnd_y) == color:
         return self.roll_dice(canvas)
     return rnd_x, rnd_y, color
コード例 #4
0
    def apply(self):
        _startX = int(math.floor((self.bot.image.width - 1) / 2))
        _startY = int(math.floor((self.bot.image.height - 1) / 2))

        _currentX = _startX
        _currentY = _startY

        while True:

            color = EnumColor.rgb(self.bot.image.pix[_currentX, _currentY],
                                  True)
            if self.bot.canvas.get_color(
                    self.bot.start_x + _currentX, self.bot.start_y + _currentY
            ) != color and not color in self.colors_ignored and self.bot.canvas.get_color(
                    self.bot.start_x + _currentX, self.bot.start_y +
                    _currentY) not in self.colors_not_overwrite:
                self.bot.paint(self.bot.start_x + _currentX,
                               self.bot.start_y + _currentY, color)
                _currentX = _startX
                _currentY = _startY

            if (random.random() < 0.5):
                if (random.random() < 0.5):
                    _currentX += 1
                else:
                    _currentX += -1
            else:
                if (random.random() < 0.5):
                    _currentY += 1
                else:
                    _currentY += -1

            if _currentX >= self.bot.image.width or _currentY >= self.bot.image.height or _currentX < 0 or _currentY < 0:
                _currentX = _startX
                _currentY = _startY
コード例 #5
0
 def match(self, canvas, image):
     for x in xrange(0, image.width):
         for y in xrange(0, image.height):
             if canvas.get_color(x + self.bot.start_x,
                                 y + self.bot.start_y) != EnumColor.rgb(
                                     self.bot.image.pix[x, y]):
                 return False
     return True
コード例 #6
0
 def apply(self):
     for y in xrange(self.bot.image.height):
         for x in xrange(self.bot.image.width):
             color = EnumColor.rgb(self.bot.image.pix[x, y])
             if self.bot.canvas.get_color(
                     self.bot.start_x + x, self.bot.start_y +
                     y) != color and not color in self.colors_ignored:
                 self.bot.paint(self.bot.start_x + x, self.bot.start_y + y,
                                color)
コード例 #7
0
 def apply(self):
     px_total = self.bot.image.height * self.bot.image.width
     px_ok = 0
     px_not_yet = 0
     for y in xrange(self.bot.image.height):
         for x in xrange(self.bot.image.width):
             color = EnumColor.rgb(self.bot.image.pix[x,y])
             px_ok = px_ok + 1
             if self.bot.canvas.get_color(self.bot.start_x + x, self.bot.start_y + y) != color and not color in self.colors_ignored:
                 px_not_yet = px_not_yet + 1
                 px_ok = px_ok - 1
     print(I18n.get('Total: %s painted: %s Not painted %s') % (str(px_total), str(px_ok), str(px_not_yet)))
     time.sleep(60)
コード例 #8
0
 def apply(self):
     for y in xrange(self.bot.image.height):
         for x in xrange(self.bot.image.width):
             color = EnumColor.rgb(self.bot.image.pix[x, y], True)
             if self.bot.canvas.get_color(
                     self.bot.start_x + x, self.bot.start_y + y
             ) != color and not color in self.colors_ignored and self.bot.canvas.get_color(
                     self.bot.start_x + x,
                     self.bot.start_y + y) not in self.colors_not_overwrite:
                 if (x % 2 == self.b):
                     self.bot.paint(self.bot.start_x + x,
                                    self.bot.start_y + y, color)
         self.b = not self.b
     self.b = False
コード例 #9
0
    def convert_pixels(self, image):
        width, height = image.size

        new = self.create_image(width, height)
        pixels = new.load()

        for i in range(width):
            for j in range(height):
                pixel = self.get_pixel(image, i, j)
                new_color = EnumColor.rgb(pixel, True, self.sensitive,
                                          self.brightness)
                pixels[i, j] = (int(new_color.rgb[0]), int(new_color.rgb[1]),
                                int(new_color.rgb[2]))

        return new