Repository: ManimCommunity/manim
File: manim/mobject/svg/svg_mobject.py (Python)

Code before:
            # defs shouldn't be part of the result tree, only the id dictionary.
            return []

        return result

    def path_string_to_mobject(self, path_string: str, style: dict):
        """Converts a SVG path element's ``d`` attribute to a mobject.

        Parameters
        ----------
        path_string : :class:`str`
            A path with potentially multiple path commands to create a shape.

        style : :class:`dict`
            Style specification, using the SVG names for properties.

        Returns
        -------
        VMobjectFromSVGPathstring
            A VMobject from the given path string, or d attribute.
        """
        if config.renderer == "opengl":
            return SVGPathMobject(
                path_string, **self.path_string_config, **parse_style(style)
            )
        return SVGPathMobject(path_string, **parse_style(style))

    def attribute_to_float(self, attr):
        """A helper method which converts the attribute to float.

        Parameters
        ----------
        attr : str
            An SVG path attribute.

        Returns
        -------
        float
            A float representing the attribute string value.
        """
        stripped_attr = "".join(
            [char for char in attr if char in string.digits + ".-e"]
        )
        return float(stripped_attr)

    def use_to_mobjects(
        self, use_element: MinidomElement, local_style: Dict
    ) -> List[VMobject]:
        """Converts a SVG <use> element to a collection of VMobjects.

        Parameters

Review comment (suggestion):
I'd prefer for `should_subdivide_sharp_curves` etc. would only be put in `self.path_string_config` if the renderer is opengl, instead of only using `self.path_string_config` if the renderer is opengl.

Code after:
            result = [group_cls(*result)]

        if within_defs and element.hasAttribute("id"):
            # it seems wasteful to throw away the actual element,
            # but I'd like the parsing to be as similar as possible
            self.def_map[element.getAttribute("id")] = (style, element)
        if is_defs:
            # defs shouldn't be part of the result tree, only the id dictionary.
            return []

        return result

    def generate_style(self):
        style = {
            "fill-opacity": self.fill_opacity,
            "stroke-opacity": self.stroke_opacity,
        }
        if self.color:
            style["fill"] = style["stroke"] = self.color.get_hex_l()
        if self.fill_color:
            style["fill"] = self.fill_color
        if self.stroke_color:
            style["stroke"] = self.stroke_color
        return style

    def path_string_to_mobject(self, path_string: str, style: dict):
        """Converts a SVG path element's ``d`` attribute to a mobject.

        Parameters
        ----------
        path_string : :class:`str`
            A path with potentially multiple path commands to create a shape.

        style : :class:`dict`
            Style specification, using the SVG names for properties.

        Returns
        -------
        VMobjectFromSVGPathstring
            A VMobject from the given path string, or d attribute.
        """
        return SVGPathMobject(
            path_string, **self.path_string_config, **parse_style(style)
        )

    def attribute_to_float(self, attr):
        """A helper method which converts the attribute to float.

        Parameters
        ----------
        attr : str