function insertRectangleAt(batch, x1, y1, x2, y2, color, filled) {
  const width = Math.abs(x2);
  const height = Math.abs(y2);
  const dx = (x2 < 0 ? -1 : 1);
  const dy = (y2 < 0 ? -1 : 1);
  const size = SETTINGS.PENCIL_SIZE;
  // stroke rectangle
  if (!filled) {
    for (let ii = 0; ii < width * height; ++ii) {
      const xx = (ii % width) | 0;
      const yy = (ii / width) | 0;
      if (!(
        (xx === 0 || xx >= width-1) ||
        (yy === 0 || yy >= height-1))
      ) continue;
      batch.drawAt(x1 + xx * dx, y1 + yy * dy, size, color);
    };
  // filled rectangle
  } else {
    for (let ii = 0; ii < width * height; ++ii) {
      const xx = (ii % width) | 0;
      const yy = (ii / width) | 0;
      batch.drawAt(x1 + xx * dx, y1 + yy * dy, size, color);
    };
  }
}
Inserts rectangle at given position
@param {Batch} batch
@param {Number} x1
@param {Number} y1
@param {Number} x2
@param {Number} y2
@param {Array} color
@param {Boolean} filled