@idraw/board
Advanced tools
Comparing version 0.2.0-alpha.21 to 0.2.0-alpha.22
@@ -269,3 +269,3 @@ 'use strict'; | ||
} | ||
var Context$2 = (function () { | ||
var Context$1 = (function () { | ||
function Context(ctx, opts) { | ||
@@ -706,3 +706,3 @@ this._opts = opts; | ||
}, | ||
Context: Context$2, | ||
Context: Context$1, | ||
}; | ||
@@ -775,3 +775,3 @@ | ||
} | ||
var TempData$1 = (function () { | ||
var TempData = (function () { | ||
function TempData() { | ||
@@ -795,3 +795,3 @@ this._temp = createTempData(); | ||
this._isMoving = false; | ||
this._temp = new TempData$1; | ||
this._temp = new TempData; | ||
this._container = window; | ||
@@ -1286,34 +1286,2 @@ this._canvas = canvas; | ||
var Context$1 = index.Context; | ||
function createDefaultData(opts) { | ||
var canvas = document.createElement('canvas'); | ||
var ctx2d = canvas.getContext('2d'); | ||
var ctx = new Context$1(ctx2d, { | ||
width: opts.width, | ||
height: opts.height, | ||
contextWidth: opts.contextWidth, | ||
contextHeight: opts.contextHeight, | ||
devicePixelRatio: opts.devicePixelRatio || window.devicePixelRatio || 1, | ||
}); | ||
return { | ||
plugins: [], | ||
ctx: ctx | ||
}; | ||
} | ||
var TempData = (function () { | ||
function TempData(opts) { | ||
this._temp = createDefaultData(opts); | ||
} | ||
TempData.prototype.set = function (name, value) { | ||
this._temp[name] = value; | ||
}; | ||
TempData.prototype.get = function (name) { | ||
return this._temp[name]; | ||
}; | ||
TempData.prototype.clear = function (opts) { | ||
this._temp = createDefaultData(opts); | ||
}; | ||
return TempData; | ||
}()); | ||
var _canvas = Symbol('_canvas'); | ||
@@ -1337,3 +1305,2 @@ var _displayCanvas = Symbol('_displayCanvas'); | ||
var _screen = Symbol('_screen'); | ||
var _tempData = Symbol('_tempData'); | ||
@@ -1346,3 +1313,2 @@ var _a; | ||
this[_a] = false; | ||
this[_tempData] = new TempData(opts); | ||
this[_mount] = mount; | ||
@@ -1446,5 +1412,2 @@ this[_canvas] = document.createElement('canvas'); | ||
}; | ||
Board.prototype.addPlugin = function (plugin) { | ||
this[_tempData].get('plugins').push(plugin); | ||
}; | ||
Board.prototype.clear = function () { | ||
@@ -1451,0 +1414,0 @@ var displayCtx = this[_displayCanvas].getContext('2d'); |
@@ -1,2 +0,1 @@ | ||
import { InterfacePlugin } from '@idraw/types'; | ||
import { TypeBoardOptions } from '@idraw/types'; | ||
@@ -23,3 +22,2 @@ import { TypeBoardSizeOptions } from '@idraw/types'; | ||
private [_screen]; | ||
private [_tempData]; | ||
constructor(mount: HTMLDivElement, opts: TypeBoardOptions); | ||
@@ -43,3 +41,2 @@ getDisplayContext2D(): CanvasRenderingContext2D; | ||
draw(): TypeScreenContext; | ||
addPlugin(plugin: InterfacePlugin): void; | ||
clear(): void; | ||
@@ -106,4 +103,2 @@ on<T extends keyof TypeBoardEventArgMap>(name: T, callback: (p: TypeBoardEventArgMap[T]) => void): void; | ||
declare const _tempData: unique symbol; | ||
declare interface TypeBoardEventArgMap { | ||
@@ -110,0 +105,0 @@ 'doubleClick': TypePoint; |
@@ -267,3 +267,3 @@ var __assign$1 = function() { | ||
} | ||
var Context$2 = (function () { | ||
var Context$1 = (function () { | ||
function Context(ctx, opts) { | ||
@@ -704,3 +704,3 @@ this._opts = opts; | ||
}, | ||
Context: Context$2, | ||
Context: Context$1, | ||
}; | ||
@@ -773,3 +773,3 @@ | ||
} | ||
var TempData$1 = (function () { | ||
var TempData = (function () { | ||
function TempData() { | ||
@@ -793,3 +793,3 @@ this._temp = createTempData(); | ||
this._isMoving = false; | ||
this._temp = new TempData$1; | ||
this._temp = new TempData; | ||
this._container = window; | ||
@@ -1284,34 +1284,2 @@ this._canvas = canvas; | ||
var Context$1 = index.Context; | ||
function createDefaultData(opts) { | ||
var canvas = document.createElement('canvas'); | ||
var ctx2d = canvas.getContext('2d'); | ||
var ctx = new Context$1(ctx2d, { | ||
width: opts.width, | ||
height: opts.height, | ||
contextWidth: opts.contextWidth, | ||
contextHeight: opts.contextHeight, | ||
devicePixelRatio: opts.devicePixelRatio || window.devicePixelRatio || 1, | ||
}); | ||
return { | ||
plugins: [], | ||
ctx: ctx | ||
}; | ||
} | ||
var TempData = (function () { | ||
function TempData(opts) { | ||
this._temp = createDefaultData(opts); | ||
} | ||
TempData.prototype.set = function (name, value) { | ||
this._temp[name] = value; | ||
}; | ||
TempData.prototype.get = function (name) { | ||
return this._temp[name]; | ||
}; | ||
TempData.prototype.clear = function (opts) { | ||
this._temp = createDefaultData(opts); | ||
}; | ||
return TempData; | ||
}()); | ||
var _canvas = Symbol('_canvas'); | ||
@@ -1335,3 +1303,2 @@ var _displayCanvas = Symbol('_displayCanvas'); | ||
var _screen = Symbol('_screen'); | ||
var _tempData = Symbol('_tempData'); | ||
@@ -1344,3 +1311,2 @@ var _a; | ||
this[_a] = false; | ||
this[_tempData] = new TempData(opts); | ||
this[_mount] = mount; | ||
@@ -1444,5 +1410,2 @@ this[_canvas] = document.createElement('canvas'); | ||
}; | ||
Board.prototype.addPlugin = function (plugin) { | ||
this[_tempData].get('plugins').push(plugin); | ||
}; | ||
Board.prototype.clear = function () { | ||
@@ -1449,0 +1412,0 @@ var displayCtx = this[_displayCanvas].getContext('2d'); |
@@ -1,1 +0,1 @@ | ||
var iDrawBoard=function(){'use strict';var t=function(){return t=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},t.apply(this,arguments)};function e(t){return'string'==typeof t&&/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}function i(t){return(Object.prototype.toString.call(t)||'').replace(/(\[object|\])/gi,'').trim()}var o={type:function(t,e){var o=i(t);return!0===e?o.toLocaleLowerCase():o},array:function(t){return'Array'===i(t)},json:function(t){return'Object'===i(t)},function:function(t){return'Function'===i(t)},asyncFunction:function(t){return'AsyncFunction'===i(t)},string:function(t){return'String'===i(t)},number:function(t){return'Number'===i(t)},undefined:function(t){return'Undefined'===i(t)},null:function(t){return'Null'===i(t)},promise:function(t){return'Promise'===i(t)}},n=function(){return n=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},n.apply(this,arguments)};function r(t,e,i,o){return new(i||(i=Promise))((function(n,r){function s(t){try{h(o.next(t))}catch(t){r(t)}}function a(t){try{h(o.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((o=o.apply(t,e||[])).next())}))}function s(t,e){var i,o,n,r,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,o&&(n=2&r[0]?o.return:r[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,r[1])).done)return n;switch(o=0,n&&(r=[2&r[0],n.value]),r[0]){case 0:case 1:n=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!n||r[1]>n[0]&&r[1]<n[3])){s.label=r[1];break}if(6===r[0]&&s.label<n[1]){s.label=n[1],n=r;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(r);break}n[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],o=0}finally{i=n=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}}function a(t,e){var i=e.width,o=e.height;return new Promise((function(e,n){var r=new Blob(["\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\""+(i||'')+"\" height = \""+(o||'')+"\">\n <foreignObject width=\"100%\" height=\"100%\">\n <div xmlns = \"http://www.w3.org/1999/xhtml\">\n "+t+"\n </div>\n </foreignObject>\n </svg>\n "],{type:'image/svg+xml;charset=utf-8'}),s=new FileReader;s.readAsDataURL(r),s.onload=function(t){var i,o=null===(i=null==t?void 0:t.target)||void 0===i?void 0:i.result;e(o)},s.onerror=function(t){n(t)}}))}function h(t){return new Promise((function(e,i){var o=new Blob([t],{type:'image/svg+xml;charset=utf-8'}),n=new FileReader;n.readAsDataURL(o),n.onload=function(t){var i,o=null===(i=null==t?void 0:t.target)||void 0===i?void 0:i.result;e(o)},n.onerror=function(t){i(t)}}))}var l=window.Image;function c(t){return new Promise((function(e,i){var o=new l;o.onload=function(){e(o)},o.onabort=i,o.onerror=i,o.src=t}))}var u=function(){function t(t,e){this._opts=e,this._ctx=t,this._transform={scale:1,scrollX:0,scrollY:0}}return t.prototype.getContext=function(){return this._ctx},t.prototype.resetSize=function(t){this._opts=n(n({},this._opts),t)},t.prototype.calcDeviceNum=function(t){return t*this._opts.devicePixelRatio},t.prototype.calcScreenNum=function(t){return t/this._opts.devicePixelRatio},t.prototype.getSize=function(){return{width:this._opts.width,height:this._opts.height,contextWidth:this._opts.contextWidth,contextHeight:this._opts.contextHeight,devicePixelRatio:this._opts.devicePixelRatio}},t.prototype.setTransform=function(t){this._transform=n(n({},this._transform),t)},t.prototype.getTransform=function(){return{scale:this._transform.scale,scrollX:this._transform.scrollX,scrollY:this._transform.scrollY}},t.prototype.setFillStyle=function(t){this._ctx.fillStyle=t},t.prototype.fill=function(t){return this._ctx.fill(t||'nonzero')},t.prototype.arc=function(t,e,i,o,n,r){return this._ctx.arc(this._doSize(t),this._doSize(e),this._doSize(i),o,n,r)},t.prototype.rect=function(t,e,i,o){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o))},t.prototype.fillRect=function(t,e,i,o){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o))},t.prototype.clearRect=function(t,e,i,o){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o))},t.prototype.beginPath=function(){return this._ctx.beginPath()},t.prototype.closePath=function(){return this._ctx.closePath()},t.prototype.lineTo=function(t,e){return this._ctx.lineTo(this._doSize(t),this._doSize(e))},t.prototype.moveTo=function(t,e){return this._ctx.moveTo(this._doSize(t),this._doSize(e))},t.prototype.arcTo=function(t,e,i,o,n){return this._ctx.arcTo(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o),this._doSize(n))},t.prototype.setLineWidth=function(t){return this._ctx.lineWidth=this._doSize(t)},t.prototype.setLineDash=function(t){var e=this;return this._ctx.setLineDash(t.map((function(t){return e._doSize(t)})))},t.prototype.isPointInPath=function(t,e){return this._ctx.isPointInPath(this._doX(t),this._doY(e))},t.prototype.isPointInPathWithoutScroll=function(t,e){return this._ctx.isPointInPath(this._doSize(t),this._doSize(e))},t.prototype.setStrokeStyle=function(t){this._ctx.strokeStyle=t},t.prototype.stroke=function(){return this._ctx.stroke()},t.prototype.translate=function(t,e){return this._ctx.translate(this._doSize(t),this._doSize(e))},t.prototype.rotate=function(t){return this._ctx.rotate(t)},t.prototype.drawImage=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[0],o=t[1],n=t[2],r=t[3],s=t[4],a=t[t.length-4],h=t[t.length-3],l=t[t.length-2],c=t[t.length-1];return 9===t.length?this._ctx.drawImage(i,this._doSize(o),this._doSize(n),this._doSize(r),this._doSize(s),this._doSize(a),this._doSize(h),this._doSize(l),this._doSize(c)):this._ctx.drawImage(i,this._doSize(a),this._doSize(h),this._doSize(l),this._doSize(c))},t.prototype.createPattern=function(t,e){return this._ctx.createPattern(t,e)},t.prototype.measureText=function(t){return this._ctx.measureText(t)},t.prototype.setTextAlign=function(t){this._ctx.textAlign=t},t.prototype.fillText=function(t,e,i,o){return void 0!==o?this._ctx.fillText(t,this._doSize(e),this._doSize(i),this._doSize(o)):this._ctx.fillText(t,this._doSize(e),this._doSize(i))},t.prototype.strokeText=function(t,e,i,o){return void 0!==o?this._ctx.strokeText(t,this._doSize(e),this._doSize(i),this._doSize(o)):this._ctx.strokeText(t,this._doSize(e),this._doSize(i))},t.prototype.setFont=function(t){var e=[];'bold'===t.fontWeight&&e.push(""+t.fontWeight),e.push(this._doSize(t.fontSize||12)+"px"),e.push(""+(t.fontFamily||'sans-serif')),this._ctx.font=""+e.join(' ')},t.prototype.setTextBaseline=function(t){this._ctx.textBaseline=t},t.prototype.setGlobalAlpha=function(t){this._ctx.globalAlpha=t},t.prototype.save=function(){this._ctx.save()},t.prototype.restore=function(){this._ctx.restore()},t.prototype.scale=function(t,e){this._ctx.scale(t,e)},t.prototype.setShadowColor=function(t){this._ctx.shadowColor=t},t.prototype.setShadowOffsetX=function(t){this._ctx.shadowOffsetX=this._doSize(t)},t.prototype.setShadowOffsetY=function(t){this._ctx.shadowOffsetY=this._doSize(t)},t.prototype.setShadowBlur=function(t){this._ctx.shadowBlur=this._doSize(t)},t.prototype.ellipse=function(t,e,i,o,n,r,s,a){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o),n,r,s,a)},t.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},t.prototype._doX=function(t){var e=this._transform,i=e.scale,o=(t-e.scrollX)/i;return this._doSize(o)},t.prototype._doY=function(t){var e=this._transform,i=e.scale,o=(t-e.scrollY)/i;return this._doSize(o)},t}();function p(t){return'number'==typeof t&&(t>0||t<=0)}function f(t){return'number'==typeof t&&t>=0}function d(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(""+t)}function v(t){return'string'==typeof t&&/^(data:image\/)/.test(""+t)}var _={x:function(t){return p(t)},y:function(t){return p(t)},w:f,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:p,borderWidth:function(t){return f(t)},borderRadius:function(t){return p(t)&&t>=0},color:function(t){return e(t)},imageSrc:function(t){return v(t)||d(t)},imageURL:d,imageBase64:v,svg:function(t){return'string'==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test((""+t).trim())&&/<\/[\s]{0,}svg>$/i.test((""+t).trim())},html:function(t){var e=!1;if('string'==typeof t){var i=document.createElement('div');i.innerHTML=t,i.children.length>0&&(e=!0),i=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return p(t)&&t>0},lineHeight:function(t){return p(t)&&t>0},textAlign:function(t){return['center','left','right'].includes(t)},fontFamily:function(t){return'string'==typeof t&&t.length>0},fontWeight:function(t){return['bold'].includes(t)},strokeWidth:function(t){return p(t)&&t>0}};function g(t){void 0===t&&(t={});var e=t.borderColor,i=t.borderRadius,o=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!_.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!_.number(i))&&!(t.hasOwnProperty('borderWidth')&&!_.number(o)))}var y={attrs:function(t){var e=t.x,i=t.y,o=t.w,n=t.h,r=t.angle;return!!(_.x(e)&&_.y(i)&&_.w(o)&&_.h(n)&&_.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){var e=t.text,i=t.color,o=t.fontSize,n=t.lineHeight,r=t.fontFamily,s=t.textAlign,a=t.fontWeight,h=t.bgColor,l=t.strokeWidth,c=t.strokeColor;return!!_.text(e)&&(!!_.color(i)&&(!!_.fontSize(o)&&(!(t.hasOwnProperty('bgColor')&&!_.color(h))&&(!(t.hasOwnProperty('fontWeight')&&!_.fontWeight(a))&&(!(t.hasOwnProperty('lineHeight')&&!_.lineHeight(n))&&(!(t.hasOwnProperty('fontFamily')&&!_.fontFamily(r))&&(!(t.hasOwnProperty('textAlign')&&!_.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!_.strokeWidth(l))&&(!(t.hasOwnProperty('strokeColor')&&!_.color(c))&&!!g(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!_.color(e))&&!!g(t)},circleDesc:function(t){var e=t.bgColor,i=t.borderColor,o=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!_.color(e))&&(!(t.hasOwnProperty('borderColor')&&!_.color(i))&&!(t.hasOwnProperty('borderWidth')&&!_.number(o)))},imageDesc:function(t){var e=t.src;return!!_.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!_.svg(e)},htmlDesc:function(t){var e=t.html;return!!_.html(e)}},S={is:_,check:y,time:{delay:function(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))},compose:function(t){return function(e,i){return function o(n){var r=t[n];n===t.length&&i&&(r=i);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,o.bind(null,n+1)))}catch(t){return Promise.reject(t)}}(0)}},throttle:function(t,e){var i=-1;return function(){for(var o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];i>0||(i=setTimeout((function(){t.apply(void 0,o),i=-1}),e))}}},loader:{loadImage:c,loadSVG:function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,h(t)];case 1:return[4,c(e.sent())];case 2:return[2,e.sent()]}}))}))},loadHTML:function(t,e){return r(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,a(t,e)];case 1:return[4,c(i.sent())];case 2:return[2,i.sent()]}}))}))}},file:{downloadImageFromCanvas:function(t,e){var i=e.filename,o=e.type,n=void 0===o?'image/jpeg':o,r=t.toDataURL(n),s=document.createElement('a');s.href=r,s.download=i;var a=document.createEvent('MouseEvents');a.initEvent('click',!0,!1),s.dispatchEvent(a)}},color:{toColorHexStr:function(t){return'#'+t.toString(16)},toColorHexNum:function(t){return parseInt(t.replace(/^\#/,'0x'))},isColorStr:e},uuid:{createUUID:function(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return""+t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()}},istype:o,data:{deepClone:function(t){return function t(e){var i,o=(i=e,Object.prototype.toString.call(i).replace(/[\]|\[]{1,1}/gi,'').split(' ')[1]);if(['Null','Number','String','Boolean','Undefined'].indexOf(o)>=0)return e;if('Array'===o){var n=[];return e.forEach((function(e){n.push(t(e))})),n}if('Object'===o){var r={};return Object.keys(e).forEach((function(i){r[i]=t(e[i])})),r}}(t)}},Context:u},m=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var i=this._listeners.get(t);null==i||i.push(e),this._listeners.set(t,i||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var i=this._listeners.get(t);if(Array.isArray(i))for(var o=0;o<(null==i?void 0:i.length);o++)if(i[o]===e){i.splice(o,1);break}this._listeners.set(t,i||[])}},t.prototype.trigger=function(t,e){var i=this._listeners.get(t);return!!Array.isArray(i)&&(i.forEach((function(t){t(e)})),!0)},t.prototype.has=function(t){if(this._listeners.has(t)){var e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1},t}();var x=function(){function t(){this._temp={prevClickPoint:null,isHoverCanvas:!1,isDragCanvas:!1,statusMap:{canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}}}return t.prototype.set=function(t,e){this._temp[t]=e},t.prototype.get=function(t){return this._temp[t]},t.prototype.clear=function(){this._temp={prevClickPoint:null,isHoverCanvas:!1,isDragCanvas:!1,statusMap:{canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}}},t}(),b=function(){function t(t,e){this._isMoving=!1,this._temp=new x,this._container=window,this._canvas=t,this._isMoving=!1,this._initEvent(),this._event=new m}return t.prototype.setStatusMap=function(t){this._temp.set('statusMap',t)},t.prototype.on=function(t,e){this._event.on(t,e)},t.prototype.off=function(t,e){this._event.off(t,e)},t.prototype._initEvent=function(){var t=this._canvas,e=this._container;e.addEventListener('mousemove',this._listenWindowMove.bind(this),!1),e.addEventListener('mouseup',this._listenWindowMoveEnd.bind(this),!1),t.addEventListener('mousemove',this._listenHover.bind(this),!1),t.addEventListener('mousedown',this._listenMoveStart.bind(this),!1),t.addEventListener('mousemove',this._listenMove.bind(this),!1),t.addEventListener('mouseup',this._listenMoveEnd.bind(this),!1),t.addEventListener('click',this._listenCanvasClick.bind(this),!1),t.addEventListener('wheel',this._listenCanvasWheel.bind(this),!1),t.addEventListener('mousedown',this._listenCanvasMoveStart.bind(this),!0),t.addEventListener('mouseup',this._listenCanvasMoveEnd.bind(this),!0),t.addEventListener('mouseover',this._listenCanvasMoveOver.bind(this),!0),t.addEventListener('mouseleave',this._listenCanvasMoveLeave.bind(this),!0),this._initParentEvent()},t.prototype._initParentEvent=function(){for(var t=window,e=t.origin;t.self!==t.top&&(t.self!==t.parent&&t.origin===e&&t.parent.window.addEventListener('mousemove',this._listSameOriginParentWindow.bind(this),!1),t=t.parent););},t.prototype._listenHover=function(t){t.preventDefault();var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.has('hover')&&this._event.trigger('hover',e),this._isMoving=!0},t.prototype._listenMoveStart=function(t){t.preventDefault();var e=this._getPosition(t);this._isVaildPoint(e)&&(this._event.has('point')&&this._event.trigger('point',e),this._event.has('moveStart')&&this._event.trigger('moveStart',e)),this._isMoving=!0},t.prototype._listenMove=function(t){if(t.preventDefault(),t.stopPropagation(),this._event.has('move')&&!0===this._isMoving){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('move',e)}},t.prototype._listenMoveEnd=function(t){if(t.preventDefault(),this._event.has('moveEnd')){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('moveEnd',e)}this._isMoving=!1},t.prototype._listSameOriginParentWindow=function(){this._temp.get('isHoverCanvas')&&this._event.has('leave')&&this._event.trigger('leave',void 0),this._temp.get('isDragCanvas')&&this._event.has('moveEnd')&&this._event.trigger('moveEnd',{x:NaN,y:NaN}),this._isMoving=!1,this._temp.set('isDragCanvas',!1),this._temp.set('isHoverCanvas',!1)},t.prototype._listenCanvasMoveStart=function(){this._temp.get('isHoverCanvas')&&this._temp.set('isDragCanvas',!0)},t.prototype._listenCanvasMoveEnd=function(){this._temp.set('isDragCanvas',!1)},t.prototype._listenCanvasMoveOver=function(){this._temp.set('isHoverCanvas',!0)},t.prototype._listenCanvasMoveLeave=function(){this._temp.set('isHoverCanvas',!1),this._event.has('leave')&&this._event.trigger('leave',void 0)},t.prototype._listenWindowMove=function(t){if(!0===this._temp.get('isDragCanvas')&&(t.preventDefault(),t.stopPropagation(),this._event.has('move')&&!0===this._isMoving)){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('move',e)}},t.prototype._listenWindowMoveEnd=function(t){if(!0!=!this._temp.get('isDragCanvas')){if(t.preventDefault(),this._event.has('moveEnd')){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('moveEnd',e)}this._temp.set('isDragCanvas',!1),this._isMoving=!1}},t.prototype._listenCanvasWheel=function(t){this._event.has('wheelX')&&(t.deltaX>0||t.deltaX<0)&&this._event.trigger('wheelX',t.deltaX),this._event.has('wheelY')&&(t.deltaY>0||t.deltaY<0)&&this._event.trigger('wheelY',t.deltaY);var e=this._temp.get('statusMap'),i=e.canScrollYNext,o=e.canScrollYPrev;(t.deltaX>0&&t.deltaX<0||t.deltaY>0&&!0===i||t.deltaY<0&&!0===o)&&t.preventDefault()},t.prototype._listenCanvasClick=function(t){t.preventDefault();var e=this._getPosition(t),i=Date.now();if(this._isVaildPoint(e)){var o=this._temp.get('prevClickPoint');o&&i-o.t<=500&&Math.abs(o.x-e.x)<=5&&Math.abs(o.y-e.y)<=5?this._event.has('doubleClick')&&this._event.trigger('doubleClick',{x:e.x,y:e.y}):this._temp.set('prevClickPoint',{x:e.x,y:e.y,t:i})}},t.prototype._getPosition=function(t){var e=this._canvas,i=0,o=0;if(t&&t.touches&&t.touches.length>0){var n=t.touches[0];n&&(i=n.clientX,o=n.clientY)}else i=t.clientX,o=t.clientY;return{x:i-e.getBoundingClientRect().left,y:o-e.getBoundingClientRect().top,t:Date.now()}},t.prototype._isVaildPoint=function(t){return w(t.x)&&w(t.y)},t}();function w(t){return t>0||t<0||0===t}var z={lineWidth:12,color:'#a0a0a0'},P=function(){function e(t,e){this._displayCtx=t,this._opts=this._getOpts(e)}return e.prototype.draw=function(t){var e=this._opts,i=e.width,o=e.height,n=this.calc(t),r=this._displayCtx;n.xSize>0&&(r.globalAlpha=.2,r.fillStyle=n.color,r.fillRect(0,this._doSize(o-n.lineSize),this._doSize(i),this._doSize(n.lineSize)),r.globalAlpha=1,C(r,{x:this._doSize(n.translateX),y:this._doSize(o-n.lineSize),w:this._doSize(n.xSize),h:this._doSize(n.lineSize),r:this._doSize(n.lineSize/2),color:n.color})),n.ySize>0&&(r.globalAlpha=.2,r.fillStyle=n.color,r.fillRect(this._doSize(i-n.lineSize),0,this._doSize(n.lineSize),this._doSize(o)),r.globalAlpha=1,C(r,{x:this._doSize(i-n.lineSize),y:this._doSize(n.translateY),w:this._doSize(n.lineSize),h:this._doSize(n.ySize),r:this._doSize(n.lineSize/2),color:n.color})),r.globalAlpha=1},e.prototype.resetSize=function(e){this._opts=t(t({},this._opts),e)},e.prototype.isPointAtScrollY=function(t){var e=this._opts,i=e.width,o=e.height,n=e.scrollConfig,r=this._displayCtx;return r.beginPath(),r.rect(this._doSize(i-n.lineWidth),0,this._doSize(n.lineWidth),this._doSize(o)),r.closePath(),!!r.isPointInPath(this._doSize(t.x),this._doSize(t.y))},e.prototype.isPointAtScrollX=function(t){var e=this._opts,i=e.width,o=e.height,n=e.scrollConfig,r=this._displayCtx;return r.beginPath(),r.rect(0,this._doSize(o-n.lineWidth),this._doSize(i-n.lineWidth),this._doSize(n.lineWidth)),r.closePath(),!!r.isPointInPath(this._doSize(t.x),this._doSize(t.y))},e.prototype.getLineWidth=function(){return this._opts.scrollConfig.lineWidth},e.prototype.calc=function(t){var e=this._opts,i=e.width,o=e.height,n=e.scrollConfig,r=2.5*n.lineWidth,s=n.lineWidth,a=0,h=0;t.left<=0&&t.right<=0&&(a=Math.max(r,i-(Math.abs(t.left)+Math.abs(t.right))))>=i&&(a=0),(t.top<=0||t.bottom<=0)&&(h=Math.max(r,o-(Math.abs(t.top)+Math.abs(t.bottom))))>=o&&(h=0);var l=0;a>0&&(l=a/2+(i-a)*Math.abs(t.left)/(Math.abs(t.left)+Math.abs(t.right)),l=Math.min(Math.max(0,l-a/2),i-a));var c=0;return h>0&&(c=h/2+(o-h)*Math.abs(t.top)/(Math.abs(t.top)+Math.abs(t.bottom)),c=Math.min(Math.max(0,c-h/2),o-h)),{lineSize:s,xSize:a,ySize:h,translateY:c,translateX:l,color:this._opts.scrollConfig.color}},e.prototype._doSize=function(t){return t*this._opts.devicePixelRatio},e.prototype._getOpts=function(e){var i=t({scrollConfig:z},e);return i.scrollConfig||(i.scrollConfig=z),i.scrollConfig.lineWidth>0||(i.scrollConfig.lineWidth=z.lineWidth),i.scrollConfig.lineWidth=Math.max(i.scrollConfig.lineWidth,z.lineWidth),!0!==S.color.isColorStr(i.scrollConfig.color)&&(i.scrollConfig.color=i.scrollConfig.color),i},e}();function C(t,e){var i=e.x,o=e.y,n=e.w,r=e.h,s=e.color,a=e.r;(n<2*(a=Math.min(a,n/2,r/2))||r<2*a)&&(a=0),t.beginPath(),t.moveTo(i+a,o),t.arcTo(i+n,o,i+n,o+r,a),t.arcTo(i+n,o+r,i,o+r,a),t.arcTo(i,o+r,i,o,a),t.arcTo(i,o,i+n,o,a),t.closePath(),t.fillStyle=s,t.fill()}var M=Symbol('_opts'),Y=Symbol('_ctx'),X=function(){function e(t,e){this[M]=e,this[Y]=t}return e.prototype.resetSize=function(e){this[M]=t(t({},this[M]),e)},e.prototype.calcScreen=function(){var t=this[Y].getTransform().scale,e=this[M],i=e.width,o=e.height,n=e.contextWidth,r=e.contextHeight,s=e.devicePixelRatio,a=!0,h=!0,l=!0,c=!0;n*t<=i&&(this[Y].setTransform({scrollX:(i-n*t)/2}),a=!1,h=!1),r*t<=o&&(this[Y].setTransform({scrollY:(o-r*t)/2}),l=!1,c=!1),n*t>=i&&this[Y].getTransform().scrollX>0&&(this[Y].setTransform({scrollX:0}),a=!1),r*t>=o&&this[Y].getTransform().scrollY>0&&(this[Y].setTransform({scrollY:0}),l=!1);var u=this[Y].getTransform(),p=u.scrollX,f=u.scrollY;p<0&&Math.abs(p)>Math.abs(n*t-i)&&(this[Y].setTransform({scrollX:0-Math.abs(n*t-i)}),h=!1),f<0&&Math.abs(f)>Math.abs(r*t-o)&&(this[Y].setTransform({scrollY:0-Math.abs(r*t-o)}),c=!1);var d=this[Y].getTransform(),v=d.scrollX,_=d.scrollY;return{size:{x:v*t,y:_*t,w:n*t,h:r*t},position:{top:_,bottom:o-(r*t+_),left:v,right:i-(n*t+v)},deviceSize:{x:v*s,y:_*s,w:n*s*t,h:r*s*t},width:this[M].width,height:this[M].height,devicePixelRatio:this[M].devicePixelRatio,canScrollYPrev:l,canScrollYNext:c,canScrollXPrev:a,canScrollXNext:h}},e.prototype.calcScreenScroll=function(t,e,i,o,n){var r=o-i;t<=0&&e<=0&&(r=Math.abs(t)+Math.abs(e));var s=1;return r>0&&(s=r/(o-i)),0-s*n},e}(),T=S.Context;function W(t){var e=document.createElement('canvas').getContext('2d');return{plugins:[],ctx:new T(e,{width:t.width,height:t.height,contextWidth:t.contextWidth,contextHeight:t.contextHeight,devicePixelRatio:t.devicePixelRatio||window.devicePixelRatio||1})}}var E,O=function(){function t(t){this._temp=W(t)}return t.prototype.set=function(t,e){this._temp[t]=e},t.prototype.get=function(t){return this._temp[t]},t.prototype.clear=function(t){this._temp=W(t)},t}(),D=Symbol('_canvas'),R=Symbol('_displayCanvas'),k=Symbol('_helperCanvas'),A=Symbol('_mount'),N=Symbol('_opts'),L=Symbol('_hasRendered'),H=Symbol('_ctx'),j=Symbol('_helperCtx'),I=Symbol('_watcher'),F=Symbol('_render'),B=Symbol('_parsePrivateOptions'),V=Symbol('_scroller'),U=Symbol('_initEvent'),G=Symbol('_doScrollX'),$=Symbol('_doScrollY'),q=Symbol('_doMoveScroll'),J=Symbol('_resetContext'),K=Symbol('_screen'),Q=Symbol('_tempData'),Z=S.Context,tt=S.time.throttle,et=function(){function e(t,e){this[E]=!1,this[Q]=new O(e),this[A]=t,this[D]=document.createElement('canvas'),this[k]=document.createElement('canvas'),this[R]=document.createElement('canvas'),this[A].appendChild(this[R]),this[N]=this[B](e);var i=this[D].getContext('2d'),o=this[R].getContext('2d'),n=this[k].getContext('2d');this[H]=new Z(i,this[N]),this[j]=new Z(n,this[N]),this[K]=new X(this[H],this[N]),this[I]=new b(this[R],this[H]),this[V]=new P(o,{width:e.width,height:e.height,devicePixelRatio:e.devicePixelRatio||1,scrollConfig:e.scrollConfig}),this[F]()}return e.prototype.getDisplayContext2D=function(){return this[R].getContext('2d')},e.prototype.getOriginContext2D=function(){return this[H].getContext()},e.prototype.getHelperContext2D=function(){return this[j].getContext()},e.prototype.getContext=function(){return this[H]},e.prototype.getHelperContext=function(){return this[j]},e.prototype.scale=function(t){t>0&&(this[H].setTransform({scale:t}),this[j].setTransform({scale:t}));var e=this[K].calcScreen();return{position:e.position,size:e.size}},e.prototype.scrollX=function(t){this[I].setStatusMap({canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}),(t>=0||t<0)&&(this[H].setTransform({scrollX:t}),this[j].setTransform({scrollX:t}));var e=this[K].calcScreen(),i=e.position,o=e.size,n=e.canScrollXNext,r=e.canScrollYNext,s=e.canScrollXPrev,a=e.canScrollYPrev;return this[I].setStatusMap({canScrollYPrev:a,canScrollYNext:r,canScrollXPrev:s,canScrollXNext:n}),{position:i,size:o}},e.prototype.scrollY=function(t){this[I].setStatusMap({canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}),(t>=0||t<0)&&(this[H].setTransform({scrollY:t}),this[j].setTransform({scrollY:t}));var e=this[K].calcScreen(),i=e.position,o=e.size,n=e.canScrollXNext,r=e.canScrollYNext,s=e.canScrollXPrev,a=e.canScrollYPrev;return this[I].setStatusMap({canScrollYPrev:a,canScrollYNext:r,canScrollXPrev:s,canScrollXNext:n}),{position:i,size:o}},e.prototype.getTransform=function(){return this[H].getTransform()},e.prototype.draw=function(){this.clear();var t=this[K].calcScreen(),e=t.position,i=t.deviceSize,o=t.size,n=this[R].getContext('2d');return null==n||n.drawImage(this[D],i.x,i.y,i.w,i.h),null==n||n.drawImage(this[k],i.x,i.y,i.w,i.h),!0===this[N].canScroll&&this[V].draw(e),{position:e,size:o}},e.prototype.addPlugin=function(t){this[Q].get('plugins').push(t)},e.prototype.clear=function(){var t=this[R].getContext('2d');null==t||t.clearRect(0,0,this[R].width,this[R].height)},e.prototype.on=function(t,e){this[I].on(t,e)},e.prototype.off=function(t,e){this[I].off(t,e)},e.prototype.getScreenInfo=function(){return this[K].calcScreen()},e.prototype.setCursor=function(t){this[R].style.cursor=t},e.prototype.resetCursor=function(){this[R].style.cursor='auto'},e.prototype.resetSize=function(e){this[N]=t(t({},this[N]),e),this[J](),this[H].resetSize(e),this[j].resetSize(e),this[K].resetSize(e),this[V].resetSize({width:this[N].width,height:this[N].height,devicePixelRatio:this[N].devicePixelRatio}),this.draw()},e.prototype.getScrollLineWidth=function(){var t=0;return!0===this[N].canScroll&&(t=this[V].getLineWidth()),t},e.prototype.pointScreenToContext=function(t){var e=this.getTransform(),i=e.scrollX,o=e.scrollY,n=e.scale;return{x:(t.x-i)/n,y:(t.y-o)/n}},e.prototype.pointContextToScreen=function(t){var e=this.getTransform(),i=e.scrollX,o=e.scrollY,n=e.scale;return{x:t.x*n+i,y:t.y*n+o}},e.prototype[(E=L,F)]=function(){!0!==this[L]&&(this[J](),this[U](),this[L]=!0)},e.prototype[J]=function(){var e,i,o,n,r,s,a=this[N],h=a.width,l=a.height,c=a.contextWidth,u=a.contextHeight,p=a.devicePixelRatio;this[D].width=c*p,this[D].height=u*p,this[k].width=c*p,this[k].height=u*p,this[R].width=h*p,this[R].height=l*p,e=this[R],i={width:h+"px",height:l+"px"},o=function(t){var e={};return(t.getAttribute('style')||'').split(';').forEach((function(t){var i=t.split(':');i[0]&&'string'==typeof i[0]&&(e[i[0]]=i[1]||'')})),e}(e),n=t(t({},o),i),r=Object.keys(n),s='',r.forEach((function(t){s+=t+":"+(n[t]||'')+";"})),e.setAttribute('style',s)},e.prototype[B]=function(e){return t(t({},{devicePixelRatio:1}),e)},e.prototype[U]=function(){var t=this;if(!0!==this[L]&&!0===this[N].canScroll){this.on('wheelX',tt((function(e){t[G](e)}),16)),this.on('wheelY',tt((function(e){t[$](e)}),16));var e=null;this.on('moveStart',tt((function(i){t[V].isPointAtScrollX(i)?e='x':t[V].isPointAtScrollY(i)&&(e='y')}),16)),this.on('move',tt((function(i){e&&t[q](e,i)}),16)),this.on('moveEnd',tt((function(i){e&&t[q](e,i),e=null}),16))}},e.prototype[G]=function(t,e){var i=this[N].width,o=e;'number'==typeof o&&(o>0||o<=0)||(o=this[H].getTransform().scrollX);var n=this[K].calcScreen().position,r=this[V].calc(n).xSize,s=this[K].calcScreenScroll(n.left,n.right,r,i,t);this.scrollX(o+s),this.draw()},e.prototype[$]=function(t,e){var i=this[N].height,o=e;'number'==typeof o&&(o>0||o<=0)||(o=this[H].getTransform().scrollY);var n=this[K].calcScreen().position,r=this[V].calc(n).ySize,s=this[K].calcScreenScroll(n.top,n.bottom,r,i,t);this.scrollY(o+s),this.draw()},e.prototype[q]=function(t,e){if(t){var i=this[K].calcScreen().position,o=this[V].calc(i),n=o.xSize,r=o.ySize;'x'===t?this[G](e.x-n/2,0):'y'===t&&this[$](e.y-r/2,0)}},e}();return et}(); | ||
var iDrawBoard=function(){'use strict';var t=function(){return t=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},t.apply(this,arguments)};function e(t){return'string'==typeof t&&/^\#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)}function i(t){return(Object.prototype.toString.call(t)||'').replace(/(\[object|\])/gi,'').trim()}var o={type:function(t,e){var o=i(t);return!0===e?o.toLocaleLowerCase():o},array:function(t){return'Array'===i(t)},json:function(t){return'Object'===i(t)},function:function(t){return'Function'===i(t)},asyncFunction:function(t){return'AsyncFunction'===i(t)},string:function(t){return'String'===i(t)},number:function(t){return'Number'===i(t)},undefined:function(t){return'Undefined'===i(t)},null:function(t){return'Null'===i(t)},promise:function(t){return'Promise'===i(t)}},n=function(){return n=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},n.apply(this,arguments)};function r(t,e,i,o){return new(i||(i=Promise))((function(n,r){function s(t){try{h(o.next(t))}catch(t){r(t)}}function a(t){try{h(o.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}h((o=o.apply(t,e||[])).next())}))}function s(t,e){var i,o,n,r,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,o&&(n=2&r[0]?o.return:r[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,r[1])).done)return n;switch(o=0,n&&(r=[2&r[0],n.value]),r[0]){case 0:case 1:n=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,o=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!n||r[1]>n[0]&&r[1]<n[3])){s.label=r[1];break}if(6===r[0]&&s.label<n[1]){s.label=n[1],n=r;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(r);break}n[2]&&s.ops.pop(),s.trys.pop();continue}r=e.call(t,s)}catch(t){r=[6,t],o=0}finally{i=n=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}}function a(t,e){var i=e.width,o=e.height;return new Promise((function(e,n){var r=new Blob(["\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\""+(i||'')+"\" height = \""+(o||'')+"\">\n <foreignObject width=\"100%\" height=\"100%\">\n <div xmlns = \"http://www.w3.org/1999/xhtml\">\n "+t+"\n </div>\n </foreignObject>\n </svg>\n "],{type:'image/svg+xml;charset=utf-8'}),s=new FileReader;s.readAsDataURL(r),s.onload=function(t){var i,o=null===(i=null==t?void 0:t.target)||void 0===i?void 0:i.result;e(o)},s.onerror=function(t){n(t)}}))}function h(t){return new Promise((function(e,i){var o=new Blob([t],{type:'image/svg+xml;charset=utf-8'}),n=new FileReader;n.readAsDataURL(o),n.onload=function(t){var i,o=null===(i=null==t?void 0:t.target)||void 0===i?void 0:i.result;e(o)},n.onerror=function(t){i(t)}}))}var l=window.Image;function c(t){return new Promise((function(e,i){var o=new l;o.onload=function(){e(o)},o.onabort=i,o.onerror=i,o.src=t}))}var u=function(){function t(t,e){this._opts=e,this._ctx=t,this._transform={scale:1,scrollX:0,scrollY:0}}return t.prototype.getContext=function(){return this._ctx},t.prototype.resetSize=function(t){this._opts=n(n({},this._opts),t)},t.prototype.calcDeviceNum=function(t){return t*this._opts.devicePixelRatio},t.prototype.calcScreenNum=function(t){return t/this._opts.devicePixelRatio},t.prototype.getSize=function(){return{width:this._opts.width,height:this._opts.height,contextWidth:this._opts.contextWidth,contextHeight:this._opts.contextHeight,devicePixelRatio:this._opts.devicePixelRatio}},t.prototype.setTransform=function(t){this._transform=n(n({},this._transform),t)},t.prototype.getTransform=function(){return{scale:this._transform.scale,scrollX:this._transform.scrollX,scrollY:this._transform.scrollY}},t.prototype.setFillStyle=function(t){this._ctx.fillStyle=t},t.prototype.fill=function(t){return this._ctx.fill(t||'nonzero')},t.prototype.arc=function(t,e,i,o,n,r){return this._ctx.arc(this._doSize(t),this._doSize(e),this._doSize(i),o,n,r)},t.prototype.rect=function(t,e,i,o){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o))},t.prototype.fillRect=function(t,e,i,o){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o))},t.prototype.clearRect=function(t,e,i,o){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o))},t.prototype.beginPath=function(){return this._ctx.beginPath()},t.prototype.closePath=function(){return this._ctx.closePath()},t.prototype.lineTo=function(t,e){return this._ctx.lineTo(this._doSize(t),this._doSize(e))},t.prototype.moveTo=function(t,e){return this._ctx.moveTo(this._doSize(t),this._doSize(e))},t.prototype.arcTo=function(t,e,i,o,n){return this._ctx.arcTo(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o),this._doSize(n))},t.prototype.setLineWidth=function(t){return this._ctx.lineWidth=this._doSize(t)},t.prototype.setLineDash=function(t){var e=this;return this._ctx.setLineDash(t.map((function(t){return e._doSize(t)})))},t.prototype.isPointInPath=function(t,e){return this._ctx.isPointInPath(this._doX(t),this._doY(e))},t.prototype.isPointInPathWithoutScroll=function(t,e){return this._ctx.isPointInPath(this._doSize(t),this._doSize(e))},t.prototype.setStrokeStyle=function(t){this._ctx.strokeStyle=t},t.prototype.stroke=function(){return this._ctx.stroke()},t.prototype.translate=function(t,e){return this._ctx.translate(this._doSize(t),this._doSize(e))},t.prototype.rotate=function(t){return this._ctx.rotate(t)},t.prototype.drawImage=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t[0],o=t[1],n=t[2],r=t[3],s=t[4],a=t[t.length-4],h=t[t.length-3],l=t[t.length-2],c=t[t.length-1];return 9===t.length?this._ctx.drawImage(i,this._doSize(o),this._doSize(n),this._doSize(r),this._doSize(s),this._doSize(a),this._doSize(h),this._doSize(l),this._doSize(c)):this._ctx.drawImage(i,this._doSize(a),this._doSize(h),this._doSize(l),this._doSize(c))},t.prototype.createPattern=function(t,e){return this._ctx.createPattern(t,e)},t.prototype.measureText=function(t){return this._ctx.measureText(t)},t.prototype.setTextAlign=function(t){this._ctx.textAlign=t},t.prototype.fillText=function(t,e,i,o){return void 0!==o?this._ctx.fillText(t,this._doSize(e),this._doSize(i),this._doSize(o)):this._ctx.fillText(t,this._doSize(e),this._doSize(i))},t.prototype.strokeText=function(t,e,i,o){return void 0!==o?this._ctx.strokeText(t,this._doSize(e),this._doSize(i),this._doSize(o)):this._ctx.strokeText(t,this._doSize(e),this._doSize(i))},t.prototype.setFont=function(t){var e=[];'bold'===t.fontWeight&&e.push(""+t.fontWeight),e.push(this._doSize(t.fontSize||12)+"px"),e.push(""+(t.fontFamily||'sans-serif')),this._ctx.font=""+e.join(' ')},t.prototype.setTextBaseline=function(t){this._ctx.textBaseline=t},t.prototype.setGlobalAlpha=function(t){this._ctx.globalAlpha=t},t.prototype.save=function(){this._ctx.save()},t.prototype.restore=function(){this._ctx.restore()},t.prototype.scale=function(t,e){this._ctx.scale(t,e)},t.prototype.setShadowColor=function(t){this._ctx.shadowColor=t},t.prototype.setShadowOffsetX=function(t){this._ctx.shadowOffsetX=this._doSize(t)},t.prototype.setShadowOffsetY=function(t){this._ctx.shadowOffsetY=this._doSize(t)},t.prototype.setShadowBlur=function(t){this._ctx.shadowBlur=this._doSize(t)},t.prototype.ellipse=function(t,e,i,o,n,r,s,a){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o),n,r,s,a)},t.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},t.prototype._doX=function(t){var e=this._transform,i=e.scale,o=(t-e.scrollX)/i;return this._doSize(o)},t.prototype._doY=function(t){var e=this._transform,i=e.scale,o=(t-e.scrollY)/i;return this._doSize(o)},t}();function p(t){return'number'==typeof t&&(t>0||t<=0)}function f(t){return'number'==typeof t&&t>=0}function d(t){return'string'==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(""+t)}function v(t){return'string'==typeof t&&/^(data:image\/)/.test(""+t)}var _={x:function(t){return p(t)},y:function(t){return p(t)},w:f,h:function(t){return'number'==typeof t&&t>=0},angle:function(t){return'number'==typeof t&&t>=-360&&t<=360},number:p,borderWidth:function(t){return f(t)},borderRadius:function(t){return p(t)&&t>=0},color:function(t){return e(t)},imageSrc:function(t){return v(t)||d(t)},imageURL:d,imageBase64:v,svg:function(t){return'string'==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test((""+t).trim())&&/<\/[\s]{0,}svg>$/i.test((""+t).trim())},html:function(t){var e=!1;if('string'==typeof t){var i=document.createElement('div');i.innerHTML=t,i.children.length>0&&(e=!0),i=null}return e},text:function(t){return'string'==typeof t},fontSize:function(t){return p(t)&&t>0},lineHeight:function(t){return p(t)&&t>0},textAlign:function(t){return['center','left','right'].includes(t)},fontFamily:function(t){return'string'==typeof t&&t.length>0},fontWeight:function(t){return['bold'].includes(t)},strokeWidth:function(t){return p(t)&&t>0}};function g(t){void 0===t&&(t={});var e=t.borderColor,i=t.borderRadius,o=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!_.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!_.number(i))&&!(t.hasOwnProperty('borderWidth')&&!_.number(o)))}var y={attrs:function(t){var e=t.x,i=t.y,o=t.w,n=t.h,r=t.angle;return!!(_.x(e)&&_.y(i)&&_.w(o)&&_.h(n)&&_.angle(r))&&(r>=-360&&r<=360)},textDesc:function(t){var e=t.text,i=t.color,o=t.fontSize,n=t.lineHeight,r=t.fontFamily,s=t.textAlign,a=t.fontWeight,h=t.bgColor,l=t.strokeWidth,c=t.strokeColor;return!!_.text(e)&&(!!_.color(i)&&(!!_.fontSize(o)&&(!(t.hasOwnProperty('bgColor')&&!_.color(h))&&(!(t.hasOwnProperty('fontWeight')&&!_.fontWeight(a))&&(!(t.hasOwnProperty('lineHeight')&&!_.lineHeight(n))&&(!(t.hasOwnProperty('fontFamily')&&!_.fontFamily(r))&&(!(t.hasOwnProperty('textAlign')&&!_.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!_.strokeWidth(l))&&(!(t.hasOwnProperty('strokeColor')&&!_.color(c))&&!!g(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!_.color(e))&&!!g(t)},circleDesc:function(t){var e=t.bgColor,i=t.borderColor,o=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!_.color(e))&&(!(t.hasOwnProperty('borderColor')&&!_.color(i))&&!(t.hasOwnProperty('borderWidth')&&!_.number(o)))},imageDesc:function(t){var e=t.src;return!!_.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!_.svg(e)},htmlDesc:function(t){var e=t.html;return!!_.html(e)}},S={is:_,check:y,time:{delay:function(t){return new Promise((function(e){setTimeout((function(){e()}),t)}))},compose:function(t){return function(e,i){return function o(n){var r=t[n];n===t.length&&i&&(r=i);if(!r)return Promise.resolve();try{return Promise.resolve(r(e,o.bind(null,n+1)))}catch(t){return Promise.reject(t)}}(0)}},throttle:function(t,e){var i=-1;return function(){for(var o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];i>0||(i=setTimeout((function(){t.apply(void 0,o),i=-1}),e))}}},loader:{loadImage:c,loadSVG:function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,h(t)];case 1:return[4,c(e.sent())];case 2:return[2,e.sent()]}}))}))},loadHTML:function(t,e){return r(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,a(t,e)];case 1:return[4,c(i.sent())];case 2:return[2,i.sent()]}}))}))}},file:{downloadImageFromCanvas:function(t,e){var i=e.filename,o=e.type,n=void 0===o?'image/jpeg':o,r=t.toDataURL(n),s=document.createElement('a');s.href=r,s.download=i;var a=document.createEvent('MouseEvents');a.initEvent('click',!0,!1),s.dispatchEvent(a)}},color:{toColorHexStr:function(t){return'#'+t.toString(16)},toColorHexNum:function(t){return parseInt(t.replace(/^\#/,'0x'))},isColorStr:e},uuid:{createUUID:function(){function t(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return""+t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()}},istype:o,data:{deepClone:function(t){return function t(e){var i,o=(i=e,Object.prototype.toString.call(i).replace(/[\]|\[]{1,1}/gi,'').split(' ')[1]);if(['Null','Number','String','Boolean','Undefined'].indexOf(o)>=0)return e;if('Array'===o){var n=[];return e.forEach((function(e){n.push(t(e))})),n}if('Object'===o){var r={};return Object.keys(e).forEach((function(i){r[i]=t(e[i])})),r}}(t)}},Context:u},m=function(){function t(){this._listeners=new Map}return t.prototype.on=function(t,e){if(this._listeners.has(t)){var i=this._listeners.get(t);null==i||i.push(e),this._listeners.set(t,i||[])}else this._listeners.set(t,[e])},t.prototype.off=function(t,e){if(this._listeners.has(t)){var i=this._listeners.get(t);if(Array.isArray(i))for(var o=0;o<(null==i?void 0:i.length);o++)if(i[o]===e){i.splice(o,1);break}this._listeners.set(t,i||[])}},t.prototype.trigger=function(t,e){var i=this._listeners.get(t);return!!Array.isArray(i)&&(i.forEach((function(t){t(e)})),!0)},t.prototype.has=function(t){if(this._listeners.has(t)){var e=this._listeners.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1},t}();var x=function(){function t(){this._temp={prevClickPoint:null,isHoverCanvas:!1,isDragCanvas:!1,statusMap:{canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}}}return t.prototype.set=function(t,e){this._temp[t]=e},t.prototype.get=function(t){return this._temp[t]},t.prototype.clear=function(){this._temp={prevClickPoint:null,isHoverCanvas:!1,isDragCanvas:!1,statusMap:{canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}}},t}(),b=function(){function t(t,e){this._isMoving=!1,this._temp=new x,this._container=window,this._canvas=t,this._isMoving=!1,this._initEvent(),this._event=new m}return t.prototype.setStatusMap=function(t){this._temp.set('statusMap',t)},t.prototype.on=function(t,e){this._event.on(t,e)},t.prototype.off=function(t,e){this._event.off(t,e)},t.prototype._initEvent=function(){var t=this._canvas,e=this._container;e.addEventListener('mousemove',this._listenWindowMove.bind(this),!1),e.addEventListener('mouseup',this._listenWindowMoveEnd.bind(this),!1),t.addEventListener('mousemove',this._listenHover.bind(this),!1),t.addEventListener('mousedown',this._listenMoveStart.bind(this),!1),t.addEventListener('mousemove',this._listenMove.bind(this),!1),t.addEventListener('mouseup',this._listenMoveEnd.bind(this),!1),t.addEventListener('click',this._listenCanvasClick.bind(this),!1),t.addEventListener('wheel',this._listenCanvasWheel.bind(this),!1),t.addEventListener('mousedown',this._listenCanvasMoveStart.bind(this),!0),t.addEventListener('mouseup',this._listenCanvasMoveEnd.bind(this),!0),t.addEventListener('mouseover',this._listenCanvasMoveOver.bind(this),!0),t.addEventListener('mouseleave',this._listenCanvasMoveLeave.bind(this),!0),this._initParentEvent()},t.prototype._initParentEvent=function(){for(var t=window,e=t.origin;t.self!==t.top&&(t.self!==t.parent&&t.origin===e&&t.parent.window.addEventListener('mousemove',this._listSameOriginParentWindow.bind(this),!1),t=t.parent););},t.prototype._listenHover=function(t){t.preventDefault();var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.has('hover')&&this._event.trigger('hover',e),this._isMoving=!0},t.prototype._listenMoveStart=function(t){t.preventDefault();var e=this._getPosition(t);this._isVaildPoint(e)&&(this._event.has('point')&&this._event.trigger('point',e),this._event.has('moveStart')&&this._event.trigger('moveStart',e)),this._isMoving=!0},t.prototype._listenMove=function(t){if(t.preventDefault(),t.stopPropagation(),this._event.has('move')&&!0===this._isMoving){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('move',e)}},t.prototype._listenMoveEnd=function(t){if(t.preventDefault(),this._event.has('moveEnd')){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('moveEnd',e)}this._isMoving=!1},t.prototype._listSameOriginParentWindow=function(){this._temp.get('isHoverCanvas')&&this._event.has('leave')&&this._event.trigger('leave',void 0),this._temp.get('isDragCanvas')&&this._event.has('moveEnd')&&this._event.trigger('moveEnd',{x:NaN,y:NaN}),this._isMoving=!1,this._temp.set('isDragCanvas',!1),this._temp.set('isHoverCanvas',!1)},t.prototype._listenCanvasMoveStart=function(){this._temp.get('isHoverCanvas')&&this._temp.set('isDragCanvas',!0)},t.prototype._listenCanvasMoveEnd=function(){this._temp.set('isDragCanvas',!1)},t.prototype._listenCanvasMoveOver=function(){this._temp.set('isHoverCanvas',!0)},t.prototype._listenCanvasMoveLeave=function(){this._temp.set('isHoverCanvas',!1),this._event.has('leave')&&this._event.trigger('leave',void 0)},t.prototype._listenWindowMove=function(t){if(!0===this._temp.get('isDragCanvas')&&(t.preventDefault(),t.stopPropagation(),this._event.has('move')&&!0===this._isMoving)){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('move',e)}},t.prototype._listenWindowMoveEnd=function(t){if(!0!=!this._temp.get('isDragCanvas')){if(t.preventDefault(),this._event.has('moveEnd')){var e=this._getPosition(t);this._isVaildPoint(e)&&this._event.trigger('moveEnd',e)}this._temp.set('isDragCanvas',!1),this._isMoving=!1}},t.prototype._listenCanvasWheel=function(t){this._event.has('wheelX')&&(t.deltaX>0||t.deltaX<0)&&this._event.trigger('wheelX',t.deltaX),this._event.has('wheelY')&&(t.deltaY>0||t.deltaY<0)&&this._event.trigger('wheelY',t.deltaY);var e=this._temp.get('statusMap'),i=e.canScrollYNext,o=e.canScrollYPrev;(t.deltaX>0&&t.deltaX<0||t.deltaY>0&&!0===i||t.deltaY<0&&!0===o)&&t.preventDefault()},t.prototype._listenCanvasClick=function(t){t.preventDefault();var e=this._getPosition(t),i=Date.now();if(this._isVaildPoint(e)){var o=this._temp.get('prevClickPoint');o&&i-o.t<=500&&Math.abs(o.x-e.x)<=5&&Math.abs(o.y-e.y)<=5?this._event.has('doubleClick')&&this._event.trigger('doubleClick',{x:e.x,y:e.y}):this._temp.set('prevClickPoint',{x:e.x,y:e.y,t:i})}},t.prototype._getPosition=function(t){var e=this._canvas,i=0,o=0;if(t&&t.touches&&t.touches.length>0){var n=t.touches[0];n&&(i=n.clientX,o=n.clientY)}else i=t.clientX,o=t.clientY;return{x:i-e.getBoundingClientRect().left,y:o-e.getBoundingClientRect().top,t:Date.now()}},t.prototype._isVaildPoint=function(t){return z(t.x)&&z(t.y)},t}();function z(t){return t>0||t<0||0===t}var w={lineWidth:12,color:'#a0a0a0'},P=function(){function e(t,e){this._displayCtx=t,this._opts=this._getOpts(e)}return e.prototype.draw=function(t){var e=this._opts,i=e.width,o=e.height,n=this.calc(t),r=this._displayCtx;n.xSize>0&&(r.globalAlpha=.2,r.fillStyle=n.color,r.fillRect(0,this._doSize(o-n.lineSize),this._doSize(i),this._doSize(n.lineSize)),r.globalAlpha=1,C(r,{x:this._doSize(n.translateX),y:this._doSize(o-n.lineSize),w:this._doSize(n.xSize),h:this._doSize(n.lineSize),r:this._doSize(n.lineSize/2),color:n.color})),n.ySize>0&&(r.globalAlpha=.2,r.fillStyle=n.color,r.fillRect(this._doSize(i-n.lineSize),0,this._doSize(n.lineSize),this._doSize(o)),r.globalAlpha=1,C(r,{x:this._doSize(i-n.lineSize),y:this._doSize(n.translateY),w:this._doSize(n.lineSize),h:this._doSize(n.ySize),r:this._doSize(n.lineSize/2),color:n.color})),r.globalAlpha=1},e.prototype.resetSize=function(e){this._opts=t(t({},this._opts),e)},e.prototype.isPointAtScrollY=function(t){var e=this._opts,i=e.width,o=e.height,n=e.scrollConfig,r=this._displayCtx;return r.beginPath(),r.rect(this._doSize(i-n.lineWidth),0,this._doSize(n.lineWidth),this._doSize(o)),r.closePath(),!!r.isPointInPath(this._doSize(t.x),this._doSize(t.y))},e.prototype.isPointAtScrollX=function(t){var e=this._opts,i=e.width,o=e.height,n=e.scrollConfig,r=this._displayCtx;return r.beginPath(),r.rect(0,this._doSize(o-n.lineWidth),this._doSize(i-n.lineWidth),this._doSize(n.lineWidth)),r.closePath(),!!r.isPointInPath(this._doSize(t.x),this._doSize(t.y))},e.prototype.getLineWidth=function(){return this._opts.scrollConfig.lineWidth},e.prototype.calc=function(t){var e=this._opts,i=e.width,o=e.height,n=e.scrollConfig,r=2.5*n.lineWidth,s=n.lineWidth,a=0,h=0;t.left<=0&&t.right<=0&&(a=Math.max(r,i-(Math.abs(t.left)+Math.abs(t.right))))>=i&&(a=0),(t.top<=0||t.bottom<=0)&&(h=Math.max(r,o-(Math.abs(t.top)+Math.abs(t.bottom))))>=o&&(h=0);var l=0;a>0&&(l=a/2+(i-a)*Math.abs(t.left)/(Math.abs(t.left)+Math.abs(t.right)),l=Math.min(Math.max(0,l-a/2),i-a));var c=0;return h>0&&(c=h/2+(o-h)*Math.abs(t.top)/(Math.abs(t.top)+Math.abs(t.bottom)),c=Math.min(Math.max(0,c-h/2),o-h)),{lineSize:s,xSize:a,ySize:h,translateY:c,translateX:l,color:this._opts.scrollConfig.color}},e.prototype._doSize=function(t){return t*this._opts.devicePixelRatio},e.prototype._getOpts=function(e){var i=t({scrollConfig:w},e);return i.scrollConfig||(i.scrollConfig=w),i.scrollConfig.lineWidth>0||(i.scrollConfig.lineWidth=w.lineWidth),i.scrollConfig.lineWidth=Math.max(i.scrollConfig.lineWidth,w.lineWidth),!0!==S.color.isColorStr(i.scrollConfig.color)&&(i.scrollConfig.color=i.scrollConfig.color),i},e}();function C(t,e){var i=e.x,o=e.y,n=e.w,r=e.h,s=e.color,a=e.r;(n<2*(a=Math.min(a,n/2,r/2))||r<2*a)&&(a=0),t.beginPath(),t.moveTo(i+a,o),t.arcTo(i+n,o,i+n,o+r,a),t.arcTo(i+n,o+r,i,o+r,a),t.arcTo(i,o+r,i,o,a),t.arcTo(i,o,i+n,o,a),t.closePath(),t.fillStyle=s,t.fill()}var M,Y=Symbol('_opts'),X=Symbol('_ctx'),T=function(){function e(t,e){this[Y]=e,this[X]=t}return e.prototype.resetSize=function(e){this[Y]=t(t({},this[Y]),e)},e.prototype.calcScreen=function(){var t=this[X].getTransform().scale,e=this[Y],i=e.width,o=e.height,n=e.contextWidth,r=e.contextHeight,s=e.devicePixelRatio,a=!0,h=!0,l=!0,c=!0;n*t<=i&&(this[X].setTransform({scrollX:(i-n*t)/2}),a=!1,h=!1),r*t<=o&&(this[X].setTransform({scrollY:(o-r*t)/2}),l=!1,c=!1),n*t>=i&&this[X].getTransform().scrollX>0&&(this[X].setTransform({scrollX:0}),a=!1),r*t>=o&&this[X].getTransform().scrollY>0&&(this[X].setTransform({scrollY:0}),l=!1);var u=this[X].getTransform(),p=u.scrollX,f=u.scrollY;p<0&&Math.abs(p)>Math.abs(n*t-i)&&(this[X].setTransform({scrollX:0-Math.abs(n*t-i)}),h=!1),f<0&&Math.abs(f)>Math.abs(r*t-o)&&(this[X].setTransform({scrollY:0-Math.abs(r*t-o)}),c=!1);var d=this[X].getTransform(),v=d.scrollX,_=d.scrollY;return{size:{x:v*t,y:_*t,w:n*t,h:r*t},position:{top:_,bottom:o-(r*t+_),left:v,right:i-(n*t+v)},deviceSize:{x:v*s,y:_*s,w:n*s*t,h:r*s*t},width:this[Y].width,height:this[Y].height,devicePixelRatio:this[Y].devicePixelRatio,canScrollYPrev:l,canScrollYNext:c,canScrollXPrev:a,canScrollXNext:h}},e.prototype.calcScreenScroll=function(t,e,i,o,n){var r=o-i;t<=0&&e<=0&&(r=Math.abs(t)+Math.abs(e));var s=1;return r>0&&(s=r/(o-i)),0-s*n},e}(),W=Symbol('_canvas'),E=Symbol('_displayCanvas'),O=Symbol('_helperCanvas'),D=Symbol('_mount'),R=Symbol('_opts'),k=Symbol('_hasRendered'),A=Symbol('_ctx'),N=Symbol('_helperCtx'),L=Symbol('_watcher'),H=Symbol('_render'),j=Symbol('_parsePrivateOptions'),I=Symbol('_scroller'),F=Symbol('_initEvent'),B=Symbol('_doScrollX'),V=Symbol('_doScrollY'),U=Symbol('_doMoveScroll'),G=Symbol('_resetContext'),$=Symbol('_screen'),q=S.Context,J=S.time.throttle,K=function(){function e(t,e){this[M]=!1,this[D]=t,this[W]=document.createElement('canvas'),this[O]=document.createElement('canvas'),this[E]=document.createElement('canvas'),this[D].appendChild(this[E]),this[R]=this[j](e);var i=this[W].getContext('2d'),o=this[E].getContext('2d'),n=this[O].getContext('2d');this[A]=new q(i,this[R]),this[N]=new q(n,this[R]),this[$]=new T(this[A],this[R]),this[L]=new b(this[E],this[A]),this[I]=new P(o,{width:e.width,height:e.height,devicePixelRatio:e.devicePixelRatio||1,scrollConfig:e.scrollConfig}),this[H]()}return e.prototype.getDisplayContext2D=function(){return this[E].getContext('2d')},e.prototype.getOriginContext2D=function(){return this[A].getContext()},e.prototype.getHelperContext2D=function(){return this[N].getContext()},e.prototype.getContext=function(){return this[A]},e.prototype.getHelperContext=function(){return this[N]},e.prototype.scale=function(t){t>0&&(this[A].setTransform({scale:t}),this[N].setTransform({scale:t}));var e=this[$].calcScreen();return{position:e.position,size:e.size}},e.prototype.scrollX=function(t){this[L].setStatusMap({canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}),(t>=0||t<0)&&(this[A].setTransform({scrollX:t}),this[N].setTransform({scrollX:t}));var e=this[$].calcScreen(),i=e.position,o=e.size,n=e.canScrollXNext,r=e.canScrollYNext,s=e.canScrollXPrev,a=e.canScrollYPrev;return this[L].setStatusMap({canScrollYPrev:a,canScrollYNext:r,canScrollXPrev:s,canScrollXNext:n}),{position:i,size:o}},e.prototype.scrollY=function(t){this[L].setStatusMap({canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}),(t>=0||t<0)&&(this[A].setTransform({scrollY:t}),this[N].setTransform({scrollY:t}));var e=this[$].calcScreen(),i=e.position,o=e.size,n=e.canScrollXNext,r=e.canScrollYNext,s=e.canScrollXPrev,a=e.canScrollYPrev;return this[L].setStatusMap({canScrollYPrev:a,canScrollYNext:r,canScrollXPrev:s,canScrollXNext:n}),{position:i,size:o}},e.prototype.getTransform=function(){return this[A].getTransform()},e.prototype.draw=function(){this.clear();var t=this[$].calcScreen(),e=t.position,i=t.deviceSize,o=t.size,n=this[E].getContext('2d');return null==n||n.drawImage(this[W],i.x,i.y,i.w,i.h),null==n||n.drawImage(this[O],i.x,i.y,i.w,i.h),!0===this[R].canScroll&&this[I].draw(e),{position:e,size:o}},e.prototype.clear=function(){var t=this[E].getContext('2d');null==t||t.clearRect(0,0,this[E].width,this[E].height)},e.prototype.on=function(t,e){this[L].on(t,e)},e.prototype.off=function(t,e){this[L].off(t,e)},e.prototype.getScreenInfo=function(){return this[$].calcScreen()},e.prototype.setCursor=function(t){this[E].style.cursor=t},e.prototype.resetCursor=function(){this[E].style.cursor='auto'},e.prototype.resetSize=function(e){this[R]=t(t({},this[R]),e),this[G](),this[A].resetSize(e),this[N].resetSize(e),this[$].resetSize(e),this[I].resetSize({width:this[R].width,height:this[R].height,devicePixelRatio:this[R].devicePixelRatio}),this.draw()},e.prototype.getScrollLineWidth=function(){var t=0;return!0===this[R].canScroll&&(t=this[I].getLineWidth()),t},e.prototype.pointScreenToContext=function(t){var e=this.getTransform(),i=e.scrollX,o=e.scrollY,n=e.scale;return{x:(t.x-i)/n,y:(t.y-o)/n}},e.prototype.pointContextToScreen=function(t){var e=this.getTransform(),i=e.scrollX,o=e.scrollY,n=e.scale;return{x:t.x*n+i,y:t.y*n+o}},e.prototype[(M=k,H)]=function(){!0!==this[k]&&(this[G](),this[F](),this[k]=!0)},e.prototype[G]=function(){var e,i,o,n,r,s,a=this[R],h=a.width,l=a.height,c=a.contextWidth,u=a.contextHeight,p=a.devicePixelRatio;this[W].width=c*p,this[W].height=u*p,this[O].width=c*p,this[O].height=u*p,this[E].width=h*p,this[E].height=l*p,e=this[E],i={width:h+"px",height:l+"px"},o=function(t){var e={};return(t.getAttribute('style')||'').split(';').forEach((function(t){var i=t.split(':');i[0]&&'string'==typeof i[0]&&(e[i[0]]=i[1]||'')})),e}(e),n=t(t({},o),i),r=Object.keys(n),s='',r.forEach((function(t){s+=t+":"+(n[t]||'')+";"})),e.setAttribute('style',s)},e.prototype[j]=function(e){return t(t({},{devicePixelRatio:1}),e)},e.prototype[F]=function(){var t=this;if(!0!==this[k]&&!0===this[R].canScroll){this.on('wheelX',J((function(e){t[B](e)}),16)),this.on('wheelY',J((function(e){t[V](e)}),16));var e=null;this.on('moveStart',J((function(i){t[I].isPointAtScrollX(i)?e='x':t[I].isPointAtScrollY(i)&&(e='y')}),16)),this.on('move',J((function(i){e&&t[U](e,i)}),16)),this.on('moveEnd',J((function(i){e&&t[U](e,i),e=null}),16))}},e.prototype[B]=function(t,e){var i=this[R].width,o=e;'number'==typeof o&&(o>0||o<=0)||(o=this[A].getTransform().scrollX);var n=this[$].calcScreen().position,r=this[I].calc(n).xSize,s=this[$].calcScreenScroll(n.left,n.right,r,i,t);this.scrollX(o+s),this.draw()},e.prototype[V]=function(t,e){var i=this[R].height,o=e;'number'==typeof o&&(o>0||o<=0)||(o=this[A].getTransform().scrollY);var n=this[$].calcScreen().position,r=this[I].calc(n).ySize,s=this[$].calcScreenScroll(n.top,n.bottom,r,i,t);this.scrollY(o+s),this.draw()},e.prototype[U]=function(t,e){if(t){var i=this[$].calcScreen().position,o=this[I].calc(i),n=o.xSize,r=o.ySize;'x'===t?this[B](e.x-n/2,0):'y'===t&&this[V](e.y-r/2,0)}},e}();return K}(); |
{ | ||
"name": "@idraw/board", | ||
"version": "0.2.0-alpha.21", | ||
"version": "0.2.0-alpha.22", | ||
"description": "", | ||
@@ -27,6 +27,6 @@ "main": "dist/index.cjs.js", | ||
"devDependencies": { | ||
"@idraw/types": "^0.2.0-alpha.21" | ||
"@idraw/types": "^0.2.0-alpha.22" | ||
}, | ||
"dependencies": { | ||
"@idraw/util": "^0.2.0-alpha.21" | ||
"@idraw/util": "^0.2.0-alpha.22" | ||
}, | ||
@@ -36,3 +36,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "befdf7cdb086bbe017de65ebcba8f2a438184a12" | ||
"gitHead": "884153bfe050aee75f4d132316db3bb750371375" | ||
} |
Sorry, the diff of this file is too big to display
214219
4745
Updated@idraw/util@^0.2.0-alpha.22