def area(self, chord_length=1e-4):
        """Find area enclosed by path.
        
        Approximates any Arc segments in the Path with lines
        approximately `chord_length` long, and returns the area enclosed
        by the approximated Path.  Default chord length is 0.01.  If Arc
        segments are included in path, to ensure accurate results, make
        sure this `chord_length` is set to a reasonable value (e.g. by
        checking curvature).
                
        Notes
        -----
        * Negative area results from clockwise (as opposed to
        counter-clockwise) parameterization of the input Path.
        
        To Contributors
        ---------------
        This is one of many parts of `svgpathtools` that could be 
        improved by a noble soul implementing a piecewise-linear 
        approximation scheme for paths (one with controls to guarantee a
        desired accuracy).
        """

        def area_without_arcs(path):
            area_enclosed = 0
            for seg in path:
                x = real(seg.poly())
                dy = imag(seg.poly()).deriv()
                integrand = x*dy
                integral = integrand.integ()
                area_enclosed += integral(1) - integral(0)
            return area_enclosed

        def seg2lines(seg):
            """Find piecewise-linear approximation of `seg`."""
            num_lines = int(ceil(seg.length() / chord_length))
            pts = [seg.point(t) for t in np.linspace(0, 1, num_lines+1)]
            return [Line(pts[i], pts[i+1]) for i in range(num_lines)]

        assert self.isclosed()

        bezier_path_approximation = []
        for seg in self:
            if isinstance(seg, Arc):
                bezier_path_approximation += seg2lines(seg)
            else:
                bezier_path_approximation.append(seg)
        return area_without_arcs(Path(*bezier_path_approximation))
def area ( self , chord_length = 1e-4 ) : def area_without_arcs ( path ) : area_enclosed = 0 for seg in path : x = real ( seg . poly ( ) ) dy = imag ( seg . poly ( ) ) . deriv ( ) integrand = x * dy integral = integrand . integ ( ) area_enclosed += integral ( 1 ) - integral ( 0 ) return area_enclosed def seg2lines ( seg ) : num_lines = int ( ceil ( seg . length ( ) / chord_length ) ) pts = [ seg . point ( t ) for t in np . linspace ( 0 , 1 , num_lines + 1 ) ] return [ Line ( pts [ i ] , pts [ i + 1 ] ) for i in range ( num_lines ) ] assert self . isclosed ( ) bezier_path_approximation = [ ] for seg in self : if isinstance ( seg , Arc ) : bezier_path_approximation += seg2lines ( seg ) else : bezier_path_approximation . append ( seg ) return area_without_arcs ( Path ( * bezier_path_approximation ) )
Find area enclosed by path.
        
        Approximates any Arc segments in the Path with lines
        approximately `chord_length` long, and returns the area enclosed
        by the approximated Path.  Default chord length is 0.01.  If Arc
        segments are included in path, to ensure accurate results, make
        sure this `chord_length` is set to a reasonable value (e.g. by
        checking curvature).
                
        Notes
        -----
        * Negative area results from clockwise (as opposed to
        counter-clockwise) parameterization of the input Path.
        
        To Contributors
        ---------------
        This is one of many parts of `svgpathtools` that could be 
        improved by a noble soul implementing a piecewise-linear 
        approximation scheme for paths (one with controls to guarantee a
        desired accuracy).