code: def draw_legend(
      self, *, show_tolerance=True, tolerance=None, kinkiness=None
  ):
      cr = cairo.Context(self.surface)
  
      x = self.pad
      y = self.height - self.pad - self.font_size * 2
      width = self.width - 2 * self.pad
  
      xx = x + self.pad * 2
      xxx = x + self.pad * 4
  
      if show_tolerance:
          self.draw_label(
              "Tolerance: badness; closer to zero the worse",
              x=xxx,
              y=y,
              width=width,
          )
          y -= self.pad + self.font_size
  
      self.draw_label("Underweight contours", x=xxx, y=y, width=width)
      cr.rectangle(
          xx - self.pad * 0.7, y, 1.5 * self.pad, self.font_size
      )
      cr.set_source_rgb(*self.fill_color)
      cr.fill_preserve()
      if self.stroke_color:
          cr.set_source_rgb(*self.stroke_color)
          cr.set_line_width(self.stroke_width)
          cr.stroke_preserve()
      cr.set_source_rgba(*self.weight_issue_contour_color)
      cr.fill()
      y -= self.pad + self.font_size
  
      self.draw_label(
          "Colored contours: contours with the wrong order",
          x=xxx,
          y=y,
          width=width,
      )
      cr.rectangle(
          xx - self.pad * 0.7, y, 1.5 * self.pad, self.font_size
      )
      if self.fill_color:
          cr.set_source_rgb(*self.fill_color)
          cr.fill_preserve()
      if self.stroke_color:
          cr.set_source_rgb(*self.stroke_color)
          cr.set_line_width(self.stroke_width)
          cr.stroke_preserve()
      cr.set_source_rgba(*self.contour_colors[0], self.contour_alpha)
      cr.fill()
      y -= self.pad + self.font_size
  
      self.draw_label("Kink artifact", x=xxx, y=y, width=width)
      self.draw_circle(
          cr,
          x=xx,
          y=y + self.font_size * 0.5,
          diameter=self.kink_circle_size,
          stroke_width=self.kink_circle_stroke_width,
          color=self.kink_circle_color,
      )
      y -= self.pad + self.font_size
  
      self.draw_label(
          "Point causing kink in the contour", x=xxx, y=y, width=width
      )
      self.draw_dot(
          cr,
          x=xx,
          y=y + self.font_size * 0.5,
          diameter=self.kink_point_size,
          color=self.kink_point_color,
      )
      y -= self.pad + self.font_size
  
      self.draw_label(
          "Suggested new contour start point", x=xxx, y=y, width=width
      )
      self.draw_dot(
          cr,
          x=xx,
          y=y + self.font_size * 0.5,
          diameter=self.corrected_start_point_size,
          color=self.corrected_start_point_color,
      )
      y -= self.pad + self.font_size
  
      self.draw_label(
          "Contour start point in contours with wrong direction",
          x=xxx,
          y=y,
          width=width,
      )
      self.draw_arrow(
          cr,
          x=xx - self.start_arrow_length * 0.3,
          y=y + self.font_size * 0.5,
          color=self.wrong_start_point_color,
      )
      y -= self.pad + self.font_size
  
      self.draw_label(
          "Contour start point when the first two points overlap",
          x=xxx,
          y=y,
          width=width,
      )
      self.draw_dot(
          cr,
          x=xx,
          y=y + self.font_size * 0.5,
          diameter=self.corrected_start_point_size,
          color=self.start_point_color,
      )
      y -= self.pad + self.font_size
  
      self.draw_label(
          "Contour start point and direction", x=xxx, y=y, width=width
      )
      self.draw_arrow(
          cr,
          x=xx - self.start_arrow_length * 0.3,
          y=y + self.font_size * 0.5,
          color=self.start_point_color,
      )
      y -= self.pad + self.font_size
  
      self.draw_label("Legend:", x=x, y=y, width=width, bold=True)
      y -= self.pad + self.font_size
  
      if kinkiness is not None:
          self.draw_label(
              "Kink-reporting aggressiveness: %g" % kinkiness,
              x=xxx,
              y=y,
              width=width,
          )
          y -= self.pad + self.font_size
  
      if tolerance is not None:
          self.draw_label(
              "Error tolerance: %g" % tolerance,
              x=xxx,
              y=y,
              width=width,
          )
          y -= self.pad + self.font_size
  
      self.draw_label("Parameters:", x=x, y=y, width=width, bold=True)
      y -= self.pad + self.font_size
  
imports: from .interpolatableHelpers import *
  from fontTools.ttLib import TTFont
  from fontTools.ttLib.ttGlyphSet import LerpGlyphSet
  from fontTools.pens.recordingPen import RecordingPen, DecomposingRecordingPen, RecordingPointPen
  from fontTools.pens.boundsPen import ControlBoundsPen
  from fontTools.pens.cairoPen import CairoPen
  from fontTools.pens.pointPen import SegmentToPointPen, PointToSegmentPen, ReverseContourPointPen
  from fontTools.varLib.interpolatableHelpers import PerContourOrComponentPen, SimpleRecordingPointPen
  from itertools import cycle
  from functools import wraps
  from io import BytesIO
  import cairo
  import math
  import os
  import logging
label_desc: Use image node_id 6 for calling the InterpolatablePlot obj's underlying member method code with example usage: obj.draw_legend() without return types