"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = _default;

function _default(canvas, ctx, width, height) {
  var devicePixelRatio = window.devicePixelRatio || 1;
  var data = ctx.getImageData(0, 0, canvas.width, canvas.height); // 要将 canvas 的宽高设置成容器宽高的 2 倍

  canvas.width = width * devicePixelRatio;
  canvas.height = height * devicePixelRatio;
  canvas.style.width = "".concat(width, "px");
  canvas.style.height = "".concat(height, "px"); // 然后将画布缩放，将图像放大两倍画到画布上

  ctx.scale(devicePixelRatio, devicePixelRatio);
  ctx.putImageData(data, 0, 0);
}