//canvas操作工具类
export default {
  // 获取canvas的context
  getScreenDpr() {
    return window.devicePixelRatio
  },
  //screen x,y 转换为canvas x,y
  transferScreenXYWithDpr(x, y) {
    const dpr = this.getScreenDpr()
    return {x:x * dpr, y:y * dpr}
  },
  //新建一个canvas
  createCanvas(width, height) {
    const canvas = document.createElement("canvas"),
      dpr = this.getScreenDpr();
    canvas.width = width * dpr;
    canvas.height = height * dpr;
    canvas.style.width = width + "px";
    canvas.style.height = height + "px";
    return canvas
  },
}