def do_effect(self, painting):
        """Process an image so that its pixels are shuffled.

        This method processes an image so that the pixels of the
        image are shuffled with nearby pixels.

        Arguments:
        painting -- the painting.Painting that the effect should be applied to
        """

        original_painting = painting.copy()
        for x in range(0, painting.width, self.shuffle_step):
            for y in range(0, painting.height, self.shuffle_step):
                current_coordinate = point.Point(x, y)
                squaresize = self.__get_random_squaresize()
                pixel_square = original_painting.get_square(
                    current_coordinate, squaresize, squaresize)
                shuffled_pixel_square = pixel_square
                random.shuffle(shuffled_pixel_square)

                for pixel in pixel_square:
                    new_pixel_color = original_painting.get_pixel_color(pixel)
                    pixel_to_be_replaced = shuffled_pixel_square.pop()
                    painting.set_pixel_color(pixel_to_be_replaced,
                                             new_pixel_color)
    def __change_rest_to_black(self, painting):
        """Change the remaining pixels to black.

        This method changes the colour of any pixel that
        isn't one of the replacement_colors to black.

        Arguments:
        painting -- the painting.Painting to be processed
        """

        for x in range(painting.width):
            for y in range(painting.height):
                current_coordinate = point.Point(x, y)
                current_pixel_color = painting.get_pixel_color(current_coordinate)
                if current_pixel_color not in self.replacement_colors:
                    painting.set_pixel_color(current_coordinate, color.Color(*color.BLACK))
    def __change_rest_to_black(self, painting):
        """Change the remaining pixels to black.

        This method changes the colour of any pixel that
        isn't one of the replacement_colors to black.

        Arguments:
        painting -- the painting.Painting to be processed
        """

        for x in range(painting.width):
            for y in range(painting.height):
                current_coordinate = point.Point(x, y)
                current_pixel_color = painting.get_pixel_color(
                    current_coordinate)
                if current_pixel_color not in self.replacement_colors:
                    painting.set_pixel_color(current_coordinate,
                                             color.Color(*color.BLACK))
    def __change_dominant_color(self, current_component_index, painting):
        """Change the pixel to the appropriate replacement colour.

        This method changes the colour of the pixel to the replacement
        colour corresponding to the dominant colour component of the pixel.

        Arguments:
        current_component_index -- the index of the RGB colour component to be checked
        painting -- the Painting to be processed
        """

        for x in range(painting.width):
            for y in range(painting.height):
                current_coordinate = point.Point(x, y)
                current_pixel_color = painting.get_pixel_color(current_coordinate)
                can_change = self.__check_dominant_color(current_pixel_color, current_component_index)

                if can_change:
                    painting.set_pixel_color(current_coordinate, self.replacement_colors[current_component_index])
    def __change_dominant_color(self, current_component_index, painting):
        """Change the pixel to the appropriate replacement colour.

        This method changes the colour of the pixel to the replacement
        colour corresponding to the dominant colour component of the pixel.

        Arguments:
        current_component_index -- the index of the RGB colour component to be checked
        painting -- the Painting to be processed
        """

        for x in range(painting.width):
            for y in range(painting.height):
                current_coordinate = point.Point(x, y)
                current_pixel_color = painting.get_pixel_color(
                    current_coordinate)
                can_change = self.__check_dominant_color(
                    current_pixel_color, current_component_index)

                if can_change:
                    painting.set_pixel_color(
                        current_coordinate,
                        self.replacement_colors[current_component_index])
    def do_effect(self, painting):
        """Process an image so that its pixels are shuffled.

        This method processes an image so that the pixels of the
        image are shuffled with nearby pixels.

        Arguments:
        painting -- the painting.Painting that the effect should be applied to
        """

        original_painting = painting.copy()
        for x in range(0, painting.width, self.shuffle_step):
            for y in range(0, painting.height, self.shuffle_step):
                current_coordinate = point.Point(x, y)
                squaresize = self.__get_random_squaresize()
                pixel_square = original_painting.get_square(current_coordinate,
                                                            squaresize, squaresize)
                shuffled_pixel_square = pixel_square
                random.shuffle(shuffled_pixel_square)

                for pixel in pixel_square:
                    new_pixel_color = original_painting.get_pixel_color(pixel)
                    pixel_to_be_replaced = shuffled_pixel_square.pop()
                    painting.set_pixel_color(pixel_to_be_replaced, new_pixel_color)