class_docstr: A series of possibly disconnected, possibly closed, line and curve
  segments.
  
  The underlying storage is made up of two parallel numpy arrays:
  
  - *vertices*: an (N, 2) float array of vertices
  - *codes*: an N-length `numpy.uint8` array of path codes, or None
  
  These two arrays always have the same length in the first
  dimension.  For example, to represent a cubic curve, you must
  provide three vertices and three `CURVE4` codes.
  
  The code types are:
  
  - `STOP`   :  1 vertex (ignored)
      A marker for the end of the entire path (currently not required and
      ignored)
  
  - `MOVETO` :  1 vertex
      Pick up the pen and move to the given vertex.
  
  - `LINETO` :  1 vertex
      Draw a line from the current position to the given vertex.
  
  - `CURVE3` :  1 control point, 1 endpoint
      Draw a quadratic Bézier curve from the current position, with the given
      control point, to the given end point.
  
  - `CURVE4` :  2 control points, 1 endpoint
      Draw a cubic Bézier curve from the current position, with the given
      control points, to the given end point.
  
  - `CLOSEPOLY` : 1 vertex (ignored)
      Draw a line segment to the start point of the current polyline.
  
  If *codes* is None, it is interpreted as a `MOVETO` followed by a series
  of `LINETO`.
  
  Users of Path objects should not access the vertices and codes arrays
  directly.  Instead, they should use `iter_segments` or `cleaned` to get the
  vertex/code pairs.  This helps, in particular, to consistently handle the
  case of *codes* being None.
  
  Some behavior of Path objects can be controlled by rcParams. See the
  rcParams whose keys start with 'path.'.
  
  .. note::
  
      The vertices and codes arrays should be treated as
      immutable -- there are a number of optimizations and assumptions
      made up front in the constructor that will not change when the
      data changes.
docstr: Convert this path to a list of polygons or polylines.  Each
  polygon/polyline is an (N, 2) array of vertices.  In other words,
  each polygon has no `MOVETO` instructions or curves.  This
  is useful for displaying in backends that do not support
  compound paths or Bézier curves.
  
  If *width* and *height* are both non-zero then the lines will
  be simplified so that vertices outside of (0, 0), (width,
  height) will be clipped.
  
  If *closed_only* is `True` (default), only closed polygons,
  with the last point being the same as the first point, will be
  returned.  Any unclosed polylines in the path will be
  explicitly closed.  If *closed_only* is `False`, any unclosed
  polygons in the path will be returned as unclosed polygons,
  and the closed polygons will be returned explicitly closed by
  setting the last point to the same as the first point.
docstr_tok: ["Convert","this","path","to","a","list","of","polygons","or","polylines",".","Each","polygon\/polyline","is","an","(","N",",","2",")","array","of","vertices",".","In","other","words",",","each","polygon","has","no","`","MOVETO","`","instructions","or","curves",".","This","is","useful","for","displaying","in","backends","that","do","not","support","compound","paths","or","B\u00e9zier","curves",".","If","*","width","*","and","*","height","*","are","both","non-zero","then","the","lines","will","be","simplified","so","that","vertices","outside","of","(","0",",","0",")",",","(","width",",","height",")","will","be","clipped",".","If","*","closed_only","*","is","`","True","`","(","default",")",",","only","closed","polygons",",","with","the","last","point","being","the","same","as","the","first","point",",","will","be","returned",".","Any","unclosed","polylines","in","the","path","will","be","explicitly","closed",".","If","*","closed_only","*","is","`","False","`",",","any","unclosed","polygons","in","the","path","will","be","returned","as","unclosed","polygons",",","and","the","closed","polygons","will","be","returned","explicitly","closed","by","setting","the","last","point","to","the","same","as","the","first","point","."]
code: def to_polygons(
      self, transform=None, width=0, height=0, closed_only=True
  ):
      """
      Convert this path to a list of polygons or polylines.  Each
      polygon/polyline is an (N, 2) array of vertices.  In other words,
      each polygon has no `MOVETO` instructions or curves.  This
      is useful for displaying in backends that do not support
      compound paths or Bézier curves.
  
      If *width* and *height* are both non-zero then the lines will
      be simplified so that vertices outside of (0, 0), (width,
      height) will be clipped.
  
      If *closed_only* is `True` (default), only closed polygons,
      with the last point being the same as the first point, will be
      returned.  Any unclosed polylines in the path will be
      explicitly closed.  If *closed_only* is `False`, any unclosed
      polygons in the path will be returned as unclosed polygons,
      and the closed polygons will be returned explicitly closed by
      setting the last point to the same as the first point.
      """
      if len(self.vertices) == 0:
          return []
  
      if transform is not None:
          transform = transform.frozen()
  
      if self.codes is None and (width == 0 or height == 0):
          vertices = self.vertices
          if closed_only:
              if len(vertices) < 3:
                  return []
              elif np.any(vertices[0] != vertices[-1]):
                  vertices = [*vertices, vertices[0]]
  
          if transform is None:
              return [vertices]
          else:
              return [transform.transform(vertices)]
  
      # Deal with the case where there are curves and/or multiple
      # subpaths (using extension code)
      return _path.convert_path_to_polygons(
          self, transform, width, height, closed_only
      )
  
imports: import copy
  from functools import lru_cache
  from weakref import WeakValueDictionary
  import numpy
  import matplotlib
  from .None import _api, _path
  from .cbook import _to_unmasked_float_array, simple_linear_interpolation
  from .bezier import BezierSegment
label_desc: Use image node_id 32 for calling the Path obj's underlying member method code with example usage: obj.to_polygons(transform, width, height, closed_only) and returns: _path, list, list, list, list