def generate(self, data, width, height, padding=(0, 0, 0, 0), output_format="png", inverted=False):
        """
        Generates an identicon image with requested width, height, padding, and
        output format, optionally inverting the colours in the indeticon
        (swapping background and foreground colours) if requested.

        Arguments:

          data - Hashed or raw data that will be used for generating the
          identicon.

          width - Width of resulting identicon image in pixels.

          height - Height of resulting identicon image in pixels.

          padding - Tuple describing padding around the generated identicon. The
          tuple should consist out of four values, where each value is the
          number of pixels to use for padding. The order in tuple is: top,
          bottom, left, right.

          output_format - Output format of resulting identicon image. Supported
          formats are: "png", "ascii". Default is "png".

          inverted - Specifies whether the block colours should be inverted or
          not. Default is False.

        Returns:

          Byte representation of an identicon image.
        """

        # Calculate the digest, and get byte list.
        digest_byte_list = self._data_to_digest_byte_list(data)

        # Create the matrix describing which block should be filled-in.
        matrix = self._generate_matrix(digest_byte_list)

        # Determine the background and foreground colours.
        if output_format == "png":
            background = self.background
            foreground = self.foreground[digest_byte_list[0] % len(self.foreground)]
        elif output_format == "ascii":
            foreground = "+"
            background = "-"

        # Swtich the colours if inverted image was requested.
        if inverted:
            foreground, background = background, foreground

        # Generate the identicon in requested format.
        if output_format == "png":
            return self._generate_png(matrix, width, height, padding, foreground, background)
        if output_format == "ascii":
            return self._generate_ascii(matrix, foreground, background)
        else:
            raise ValueError("Unsupported format requested: %s" % output_format)
dataset/ETHPy150Open azaghal/pydenticon/pydenticon/__init__.py/Generator.generate/original