defs(m) {
      const gradient = this._defs.gradient,
        clipping = this._defs.clipping,
        count = Object.keys(gradient).length + Object.keys(clipping).length;
      if (count === 0) return; // nothing to do

      m.open('defs');
      for (const id in gradient) {
        const def = gradient[id],
          stops = def.stops;
        if (def.gradient === 'radial') {
          // SVG radial gradients automatically transform to normalized bbox
          // coordinates, in a way that is cumbersome to replicate in canvas.
          // We wrap the radial gradient in a pattern element, allowing us to
          // maintain a circular gradient that matches what canvas provides.

          m.open('pattern', {
            id: patternPrefix + id,
            viewBox: '0,0,1,1',
            width: '100%',
            height: '100%',
            preserveAspectRatio: 'xMidYMid slice'
          });
          m.open('rect', {
            width: '1',
            height: '1',
            fill: 'url(#' + id + ')'
          }).close();
          m.close(); // </pattern>

          m.open('radialGradient', {
            id: id,
            fx: def.x1,
            fy: def.y1,
            fr: def.r1,
            cx: def.x2,
            cy: def.y2,
            r: def.r2
          });
        } else {
          m.open('linearGradient', {
            id: id,
            x1: def.x1,
            x2: def.x2,
            y1: def.y1,
            y2: def.y2
          });
        }
        for (let i = 0; i < stops.length; ++i) {
          m.open('stop', {
            offset: stops[i].offset,
            'stop-color': stops[i].color
          }).close();
        }
        m.close();
      }
      for (const id in clipping) {
        const def = clipping[id];
        m.open('clipPath', {
          id: id
        });
        if (def.path) {
          m.open('path', {
            d: def.path
          }).close();
        } else {
          m.open('rect', {
            x: 0,
            y: 0,
            width: def.width,
            height: def.height
          }).close();
        }
        m.close();
      }
      m.close();
    }
Render SVG defs, as needed.
Must be called *after* marks have been processed to ensure the
collected state is current and accurate.
@param {object} m - The markup context.