def do_effect(self, painting):
        """Process an image so that it is made up of circles.

        This method processes an image so that it is made up of circles
        of a supplied radius, on top of a given background colour.
        The color of the circles correspond to the pixel that would have
        been at its centre.

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

        distance_between_centres = self.diameter + self.gap
        # Half of distance so that circles fully visible on top and left edges
        first_centre = distance_between_centres/2
        canvas = painting.copy()
        canvas.clear_image(self.background)

        for x in range(first_centre, painting.width, distance_between_centres):
            for y in range(first_centre, painting.height, distance_between_centres):
                centre = point.Point(x, y)
                centre_color = painting.get_pixel_color(centre)
                circle = shape.Circle(centre, self.radius, centre_color)
                circle.draw(canvas)

        painting.img = canvas
    def do_effect(self, painting):
        """Process an image so that it is made up of circles.

        This method processes an image so that it is made up of circles
        of a supplied radius, on top of a given background colour.
        The color of the circles correspond to the pixel that would have
        been at its centre.

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

        distance_between_centres = self.diameter + self.gap
        # Half of distance so that circles fully visible on top and left edges
        first_centre = distance_between_centres / 2
        canvas = painting.copy()
        canvas.clear_image(self.background)

        for x in range(first_centre, painting.width, distance_between_centres):
            for y in range(first_centre, painting.height,
                           distance_between_centres):
                centre = point.Point(x, y)
                centre_color = painting.get_pixel_color(centre)
                circle = shape.Circle(centre, self.radius, centre_color)
                circle.draw(canvas)

        painting.img = canvas
    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])