pathToContext static method

void pathToContext(
  1. dynamic path,
  2. dynamic ctx
)

Implementation

static void pathToContext(path, ctx) {
  int c = 0;
  final crds = path.crds;

  for (var j = 0; j < path.cmds.length; j++) {
    var cmd = path.cmds[j];
    if (cmd == "M") {
      ctx.moveTo(crds[c], crds[c + 1]);
      c += 2;
    } else if (cmd == "L") {
      ctx.lineTo(crds[c], crds[c + 1]);
      c += 2;
    } else if (cmd == "C") {
      ctx.bezierCurveTo(crds[c], crds[c + 1], crds[c + 2], crds[c + 3],
          crds[c + 4], crds[c + 5]);
      c += 6;
    } else if (cmd == "Q") {
      ctx.quadraticCurveTo(crds[c], crds[c + 1], crds[c + 2], crds[c + 3]);
      c += 4;
    } else if (cmd.charAt(0) == "#") {
      ctx.beginPath();
      ctx.fillStyle = cmd;
    } else if (cmd == "Z") {
      ctx.closePath();
    } else if (cmd == "X") {
      ctx.fill();
    }
  }
}