        def _change_colours(self, colour, attr, bg):
            """
            Change current colour if required.

            :param colour: New colour to use.
            :param attr: New attributes to use.
            :param bg: New background colour to use.
            """
            # Change attribute first as this will reset colours when swapping
            # modes.
            if attr != self._attr:
                self._safe_write(self._a_normal)
                if attr != 0:
                    self._safe_write(self._ATTRIBUTES[attr])
                self._attr = attr
                self._colour = None
                self._bg = None

            # next check for default colours - which reset both fg and bg.
            if Screen.COLOUR_DEFAULT in (colour, bg):
                if self._default_colours:
                    self._safe_write(self._default_colours)
                    self._colour = colour if colour == Screen.COLOUR_DEFAULT else None
                    self._bg = bg if bg == Screen.COLOUR_DEFAULT else None
                else:
                    colour = Screen.COLOUR_WHITE if colour == Screen.COLOUR_DEFAULT else colour
                    bg = Screen.COLOUR_BLACK if bg == Screen.COLOUR_DEFAULT else bg

            # Now swap colours if required.
            if colour != self._colour:
                self._safe_write(curses.tparm(
                    self._fg_color, colour).decode("utf-8"))
                self._colour = colour
            if bg != self._bg:
                self._safe_write(curses.tparm(
                    self._bg_color, bg).decode("utf-8"))
                self._bg = bg
Change current colour if required.

:param colour: New colour to use.
:param attr: New attributes to use.
:param bg: New background colour to use.
asciimatics/screen.py