Finish the current drawing segment.

        Notes:
            Apply stroke and fill colors, dashes, line style and width, or
            morphing. Also determines whether any open path should be closed
            by a connecting line to its start point.

def finish(
            self,
            width=1,
            color=None,
            fill=None,
            roundCap=False,
            dashes=None,
            even_odd=False,
            morph=None,
            closePath=True
        ):
        """Finish the current drawing segment.

        Notes:
            Apply stroke and fill colors, dashes, line style and width, or
            morphing. Also determines whether any open path should be closed
            by a connecting line to its start point.
        """
        if self.draw_cont == "":            # treat empty contents as no-op
            return

        color_str = ColorCode(color, "c")  # ensure proper color string
        fill_str = ColorCode(fill, "f")  # ensure proper fill string

        if width != 1:
            self.draw_cont += "%g w\n" % width

        if roundCap:
            self.draw_cont += "%i J %i j\n" % (roundCap, roundCap)

        if dashes is not None and len(dashes) > 0:
            self.draw_cont += "%s d\n" % dashes

        if closePath:
            self.draw_cont += "h\n"
            self.lastPoint = None

        if color is not None:
            self.draw_cont += color_str

        if fill is not None:
            self.draw_cont += fill_str
            if not even_odd:
                self.draw_cont += "B\n"
            else:
                self.draw_cont += "B*\n"
        else:
            self.draw_cont += "S\n"

        if CheckMorph(morph):
            m1 = Matrix(1, 0, 0, 1, morph[0].x + self.x,
                             self.height - morph[0].y - self.y)
            mat = ~m1 * morph[1] * m1
            self.draw_cont = "%g %g %g %g %g %g cm\n" % JM_TUPLE(mat) + self.draw_cont

        self.totalcont += "\nq\n" + self.draw_cont + "Q\n"
        self.draw_cont = ""
        self.lastPoint = None
        return