code: def fill_polygon(polygon, canvas, color=1):
      """
      fill_polygon([(y0,x0), (y1,x1),...], canvas, color=1)
  
      Draw a filled polygon in canvas
  
      Parameters
      ----------
      polygon : list of pairs
          a list of (y,x) points
      canvas : ndarray
          where to draw, will be modified in place
      color : integer, optional
          which colour to use (default: 1)
      """
      # algorithm adapted from: https://www.alienryderflex.com/polygon_fill/
      if not len(polygon):
          return
      min_y = min(y for y, x in polygon)
      max_y = max(y for y, x in polygon)
      polygon = [(float(y), float(x)) for y, x in polygon]
      if max_y < canvas.shape[0]:
          max_y += 1
      for y in range(min_y, max_y):
          nodes = []
          j = -1
          for i, p in enumerate(polygon):
              pj = polygon[j]
              if p[0] < y and pj[0] >= y or pj[0] < y and p[0] >= y:
                  dy = pj[0] - p[0]
                  if dy:
                      nodes.append(
                          (
                              p[1]
                              + (y - p[0])
                              / (pj[0] - p[0])
                              * (pj[1] - p[1])
                          )
                      )
                  elif p[0] == y:
                      nodes.append(p[1])
              j = i
          nodes.sort()
          for n, nn in zip(nodes[::2], nodes[1::2]):
              nn += 1
              canvas[y, int(n) : int(nn)] = color
  
imports: from __future__ import division
  import numpy
  from .None import _convex
label_desc: Use image node_id 2 for calling a global function with example usage: fill_polygon(polygon, canvas, color) without return types