@idraw/board
Advanced tools
Comparing version 0.2.0-alpha.20 to 0.2.0-alpha.21
@@ -0,5 +1,5 @@ | ||
import { InterfacePlugin } from '@idraw/types'; | ||
import { TypeBoardOptions } from '@idraw/types'; | ||
import { TypeBoardSizeOptions } from '@idraw/types'; | ||
import { TypeContext } from '@idraw/types'; | ||
import { TypePlugin } from '@idraw/types'; | ||
import { TypePoint } from '@idraw/types'; | ||
@@ -12,10 +12,10 @@ import { TypePointCursor } from '@idraw/types'; | ||
declare class Board { | ||
private [_hasRendered]; | ||
private [_canvas]; | ||
private [_helperCanvas]; | ||
private [_displayCanvas]; | ||
private [_mount]; | ||
private [_opts]; | ||
private [_hasRendered]; | ||
private [_ctx]; | ||
private [_displayCtx]; | ||
private [_originCtx]; | ||
private [_helperCtx]; | ||
private [_watcher]; | ||
@@ -26,5 +26,7 @@ private [_scroller]; | ||
constructor(mount: HTMLDivElement, opts: TypeBoardOptions); | ||
getDisplayContext(): CanvasRenderingContext2D; | ||
getOriginContext(): CanvasRenderingContext2D; | ||
getContext(): Context; | ||
getDisplayContext2D(): CanvasRenderingContext2D; | ||
getOriginContext2D(): CanvasRenderingContext2D; | ||
getHelperContext2D(): CanvasRenderingContext2D; | ||
getContext(): TypeContext; | ||
getHelperContext(): TypeContext; | ||
scale(scaleRatio: number): TypeScreenContext; | ||
@@ -42,3 +44,3 @@ scrollX(x: number): { | ||
draw(): TypeScreenContext; | ||
addPlugin(plugin: TypePlugin): void; | ||
addPlugin(plugin: InterfacePlugin): void; | ||
clear(): void; | ||
@@ -73,68 +75,2 @@ on<T extends keyof TypeBoardEventArgMap>(name: T, callback: (p: TypeBoardEventArgMap[T]) => void): void; | ||
declare class Context implements TypeContext { | ||
private _opts; | ||
private _ctx; | ||
private _transform; | ||
constructor(ctx: CanvasRenderingContext2D, opts: Options); | ||
resetSize(opts: TypeBoardSizeOptions): void; | ||
calcDeviceNum(num: number): number; | ||
calcScreenNum(num: number): number; | ||
getSize(): { | ||
width: number; | ||
height: number; | ||
contextWidth: number; | ||
contextHeight: number; | ||
devicePixelRatio: number; | ||
}; | ||
setTransform(config: Transform): void; | ||
getTransform(): { | ||
scale: number; | ||
scrollX: number; | ||
scrollY: number; | ||
}; | ||
setFillStyle(color: string | CanvasPattern | CanvasGradient): void; | ||
fill(fillRule?: CanvasFillRule | undefined): void; | ||
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean | undefined): void; | ||
rect(x: number, y: number, w: number, h: number): void; | ||
fillRect(x: number, y: number, w: number, h: number): void; | ||
clearRect(x: number, y: number, w: number, h: number): void; | ||
beginPath(): void; | ||
closePath(): void; | ||
lineTo(x: number, y: number): void; | ||
moveTo(x: number, y: number): void; | ||
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void; | ||
setLineWidth(w: number): number; | ||
setLineDash(nums: number[]): void; | ||
isPointInPath(x: number, y: number): boolean; | ||
isPointInPathWithoutScroll(x: number, y: number): boolean; | ||
setStrokeStyle(color: string): void; | ||
stroke(): void; | ||
translate(x: number, y: number): void; | ||
rotate(angle: number): void; | ||
drawImage(...args: any[]): void; | ||
createPattern(image: CanvasImageSource, repetition: string | null): CanvasPattern | null; | ||
measureText(text: string): TextMetrics; | ||
setTextAlign(align: CanvasTextAlign): void; | ||
fillText(text: string, x: number, y: number, maxWidth?: number | undefined): void; | ||
strokeText(text: string, x: number, y: number, maxWidth?: number | undefined): void; | ||
setFont(opts: { | ||
fontSize: number; | ||
fontFamily?: string; | ||
fontWeight?: 'bold'; | ||
}): void; | ||
setTextBaseline(baseline: CanvasTextBaseline): void; | ||
setGlobalAlpha(alpha: number): void; | ||
save(): void; | ||
restore(): void; | ||
scale(ratioX: number, ratioY: number): void; | ||
setShadowColor(color: string): void; | ||
setShadowOffsetX(offsetX: number): void; | ||
setShadowOffsetY(offsetY: number): void; | ||
setShadowBlur(blur: number): void; | ||
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean | undefined): void; | ||
private _doSize; | ||
private _doX; | ||
private _doY; | ||
} | ||
declare const _ctx: unique symbol; | ||
@@ -144,4 +80,2 @@ | ||
declare const _displayCtx: unique symbol; | ||
declare const _doMoveScroll: unique symbol; | ||
@@ -155,2 +89,6 @@ | ||
declare const _helperCanvas: unique symbol; | ||
declare const _helperCtx: unique symbol; | ||
declare const _initEvent: unique symbol; | ||
@@ -160,14 +98,4 @@ | ||
declare type Options = { | ||
width: number; | ||
height: number; | ||
contextWidth: number; | ||
contextHeight: number; | ||
devicePixelRatio: number; | ||
}; | ||
declare const _opts: unique symbol; | ||
declare const _originCtx: unique symbol; | ||
declare const _parsePrivateOptions: unique symbol; | ||
@@ -185,8 +113,2 @@ | ||
declare type Transform = { | ||
scale?: number; | ||
scrollX?: number; | ||
scrollY?: number; | ||
}; | ||
declare interface TypeBoardEventArgMap { | ||
@@ -193,0 +115,0 @@ 'doubleClick': TypePoint; |
@@ -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{c(o.next(t))}catch(t){r(t)}}function h(t){try{c(o.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,h)}c((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:h(0),throw:h(1),return:h(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function h(r){return function(h){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,h])}}}function h(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 c(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 a=window.Image;function l(t){return new Promise((function(e,i){var o=new a;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.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],h=t[t.length-4],c=t[t.length-3],a=t[t.length-2],l=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(h),this._doSize(c),this._doSize(a),this._doSize(l)):this._ctx.drawImage(i,this._doSize(h),this._doSize(c),this._doSize(a),this._doSize(l))},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,h){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o),n,r,s,h)},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 _(t){return'string'==typeof t&&/^(data:image\/)/.test(""+t)}var v={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 _(t)||d(t)},imageURL:d,imageBase64:_,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 S(t){void 0===t&&(t={});var e=t.borderColor,i=t.borderRadius,o=t.borderWidth;return!(t.hasOwnProperty('borderColor')&&!v.color(e))&&(!(t.hasOwnProperty('borderRadius')&&!v.number(i))&&!(t.hasOwnProperty('borderWidth')&&!v.number(o)))}var y={attrs:function(t){var e=t.x,i=t.y,o=t.w,n=t.h,r=t.angle;return!!(v.x(e)&&v.y(i)&&v.w(o)&&v.h(n)&&v.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,h=t.fontWeight,c=t.bgColor,a=t.strokeWidth,l=t.strokeColor;return!!v.text(e)&&(!!v.color(i)&&(!!v.fontSize(o)&&(!(t.hasOwnProperty('bgColor')&&!v.color(c))&&(!(t.hasOwnProperty('fontWeight')&&!v.fontWeight(h))&&(!(t.hasOwnProperty('lineHeight')&&!v.lineHeight(n))&&(!(t.hasOwnProperty('fontFamily')&&!v.fontFamily(r))&&(!(t.hasOwnProperty('textAlign')&&!v.textAlign(s))&&(!(t.hasOwnProperty('strokeWidth')&&!v.strokeWidth(a))&&(!(t.hasOwnProperty('strokeColor')&&!v.color(l))&&!!S(t))))))))))},rectDesc:function(t){var e=t.bgColor;return!(t.hasOwnProperty('bgColor')&&!v.color(e))&&!!S(t)},circleDesc:function(t){var e=t.bgColor,i=t.borderColor,o=t.borderWidth;return!(t.hasOwnProperty('bgColor')&&!v.color(e))&&(!(t.hasOwnProperty('borderColor')&&!v.color(i))&&!(t.hasOwnProperty('borderWidth')&&!v.number(o)))},imageDesc:function(t){var e=t.src;return!!v.imageSrc(e)},svgDesc:function(t){var e=t.svg;return!!v.svg(e)},htmlDesc:function(t){var e=t.html;return!!v.html(e)}},g={is:v,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:l,loadSVG:function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,c(t)];case 1:return[4,l(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,h(t,e)];case 1:return[4,l(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 h=document.createEvent('MouseEvents');h.initEvent('click',!0,!1),s.dispatchEvent(h)}},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},x=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 m=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}(),z=function(){function t(t,e){this._isMoving=!1,this._temp=new m,this._container=window,this._canvas=t,this._isMoving=!1,this._initEvent(),this._event=new x}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 b=function(){function e(t,e){this._opts=e,this._ctx=t,this._transform={scale:1,scrollX:0,scrollY:0}}return e.prototype.resetSize=function(e){this._opts=t(t({},this._opts),e)},e.prototype.calcDeviceNum=function(t){return t*this._opts.devicePixelRatio},e.prototype.calcScreenNum=function(t){return t/this._opts.devicePixelRatio},e.prototype.getSize=function(){return{width:this._opts.width,height:this._opts.height,contextWidth:this._opts.contextWidth,contextHeight:this._opts.contextHeight,devicePixelRatio:this._opts.devicePixelRatio}},e.prototype.setTransform=function(e){this._transform=t(t({},this._transform),e)},e.prototype.getTransform=function(){return{scale:this._transform.scale,scrollX:this._transform.scrollX,scrollY:this._transform.scrollY}},e.prototype.setFillStyle=function(t){this._ctx.fillStyle=t},e.prototype.fill=function(t){return this._ctx.fill(t||'nonzero')},e.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)},e.prototype.rect=function(t,e,i,o){return this._ctx.rect(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o))},e.prototype.fillRect=function(t,e,i,o){return this._ctx.fillRect(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o))},e.prototype.clearRect=function(t,e,i,o){return this._ctx.clearRect(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o))},e.prototype.beginPath=function(){return this._ctx.beginPath()},e.prototype.closePath=function(){return this._ctx.closePath()},e.prototype.lineTo=function(t,e){return this._ctx.lineTo(this._doSize(t),this._doSize(e))},e.prototype.moveTo=function(t,e){return this._ctx.moveTo(this._doSize(t),this._doSize(e))},e.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))},e.prototype.setLineWidth=function(t){return this._ctx.lineWidth=this._doSize(t)},e.prototype.setLineDash=function(t){var e=this;return this._ctx.setLineDash(t.map((function(t){return e._doSize(t)})))},e.prototype.isPointInPath=function(t,e){return this._ctx.isPointInPath(this._doX(t),this._doY(e))},e.prototype.isPointInPathWithoutScroll=function(t,e){return this._ctx.isPointInPath(this._doSize(t),this._doSize(e))},e.prototype.setStrokeStyle=function(t){this._ctx.strokeStyle=t},e.prototype.stroke=function(){return this._ctx.stroke()},e.prototype.translate=function(t,e){return this._ctx.translate(this._doSize(t),this._doSize(e))},e.prototype.rotate=function(t){return this._ctx.rotate(t)},e.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],h=t[t.length-4],c=t[t.length-3],a=t[t.length-2],l=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(h),this._doSize(c),this._doSize(a),this._doSize(l)):this._ctx.drawImage(i,this._doSize(h),this._doSize(c),this._doSize(a),this._doSize(l))},e.prototype.createPattern=function(t,e){return this._ctx.createPattern(t,e)},e.prototype.measureText=function(t){return this._ctx.measureText(t)},e.prototype.setTextAlign=function(t){this._ctx.textAlign=t},e.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))},e.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))},e.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(' ')},e.prototype.setTextBaseline=function(t){this._ctx.textBaseline=t},e.prototype.setGlobalAlpha=function(t){this._ctx.globalAlpha=t},e.prototype.save=function(){this._ctx.save()},e.prototype.restore=function(){this._ctx.restore()},e.prototype.scale=function(t,e){this._ctx.scale(t,e)},e.prototype.setShadowColor=function(t){this._ctx.shadowColor=t},e.prototype.setShadowOffsetX=function(t){this._ctx.shadowOffsetX=this._doSize(t)},e.prototype.setShadowOffsetY=function(t){this._ctx.shadowOffsetY=this._doSize(t)},e.prototype.setShadowBlur=function(t){this._ctx.shadowBlur=this._doSize(t)},e.prototype.ellipse=function(t,e,i,o,n,r,s,h){this._ctx.ellipse(this._doSize(t),this._doSize(e),this._doSize(i),this._doSize(o),n,r,s,h)},e.prototype._doSize=function(t){return this._opts.devicePixelRatio*t},e.prototype._doX=function(t){var e=this._transform,i=e.scale,o=(t-e.scrollX)/i;return this._doSize(o)},e.prototype._doY=function(t){var e=this._transform,i=e.scale,o=(t-e.scrollY)/i;return this._doSize(o)},e}(),P={lineWidth:12,color:'#a0a0a0'},C=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,M(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,M(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,h=0,c=0;t.left<=0&&t.right<=0&&(h=Math.max(r,i-(Math.abs(t.left)+Math.abs(t.right))))>=i&&(h=0),(t.top<=0||t.bottom<=0)&&(c=Math.max(r,o-(Math.abs(t.top)+Math.abs(t.bottom))))>=o&&(c=0);var a=0;h>0&&(a=h/2+(i-h)*Math.abs(t.left)/(Math.abs(t.left)+Math.abs(t.right)),a=Math.min(Math.max(0,a-h/2),i-h));var l=0;return c>0&&(l=c/2+(o-c)*Math.abs(t.top)/(Math.abs(t.top)+Math.abs(t.bottom)),l=Math.min(Math.max(0,l-c/2),o-c)),{lineSize:s,xSize:h,ySize:c,translateY:l,translateX:a,color:this._opts.scrollConfig.color}},e.prototype._doSize=function(t){return t*this._opts.devicePixelRatio},e.prototype._getOpts=function(e){var i=t({scrollConfig:P},e);return i.scrollConfig||(i.scrollConfig=P),i.scrollConfig.lineWidth>0||(i.scrollConfig.lineWidth=P.lineWidth),i.scrollConfig.lineWidth=Math.max(i.scrollConfig.lineWidth,P.lineWidth),!0!==g.color.isColorStr(i.scrollConfig.color)&&(i.scrollConfig.color=i.scrollConfig.color),i},e}();function M(t,e){var i=e.x,o=e.y,n=e.w,r=e.h,s=e.color,h=e.r;(n<2*(h=Math.min(h,n/2,r/2))||r<2*h)&&(h=0),t.beginPath(),t.moveTo(i+h,o),t.arcTo(i+n,o,i+n,o+r,h),t.arcTo(i+n,o+r,i,o+r,h),t.arcTo(i,o+r,i,o,h),t.arcTo(i,o,i+n,o,h),t.closePath(),t.fillStyle=s,t.fill()}var T=Symbol('_opts'),Y=Symbol('_ctx'),X=function(){function e(t,e){this[T]=e,this[Y]=t}return e.prototype.resetSize=function(e){this[T]=t(t({},this[T]),e)},e.prototype.calcScreen=function(){var t=this[Y].getTransform().scale,e=this[T],i=e.width,o=e.height,n=e.contextWidth,r=e.contextHeight,s=e.devicePixelRatio,h=!0,c=!0,a=!0,l=!0;n*t<=i&&(this[Y].setTransform({scrollX:(i-n*t)/2}),h=!1,c=!1),r*t<=o&&(this[Y].setTransform({scrollY:(o-r*t)/2}),a=!1,l=!1),n*t>=i&&this[Y].getTransform().scrollX>0&&(this[Y].setTransform({scrollX:0}),h=!1),r*t>=o&&this[Y].getTransform().scrollY>0&&(this[Y].setTransform({scrollY:0}),a=!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)}),c=!1),f<0&&Math.abs(f)>Math.abs(r*t-o)&&(this[Y].setTransform({scrollY:0-Math.abs(r*t-o)}),l=!1);var d=this[Y].getTransform(),_=d.scrollX,v=d.scrollY;return{size:{x:_*t,y:v*t,w:n*t,h:r*t},position:{top:v,bottom:o-(r*t+v),left:_,right:i-(n*t+_)},deviceSize:{x:_*s,y:v*s,w:n*s*t,h:r*s*t},width:this[T].width,height:this[T].height,devicePixelRatio:this[T].devicePixelRatio,canScrollYPrev:a,canScrollYNext:l,canScrollXPrev:h,canScrollXNext:c}},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}();function W(t){var e=document.createElement('canvas').getContext('2d');return{plugins:[],ctx:new b(e,{width:t.width,height:t.height,contextWidth:t.contextWidth,contextHeight:t.contextHeight,devicePixelRatio:t.devicePixelRatio||window.devicePixelRatio||1})}}var E,R=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}(),O=Symbol('_canvas'),k=Symbol('_displayCanvas'),D=Symbol('_mount'),A=Symbol('_opts'),L=Symbol('_hasRendered'),N=Symbol('_ctx'),H=Symbol('_displayCtx'),I=Symbol('_originCtx'),j=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=g.time.throttle,tt=function(){function e(t,e){this[E]=!1,this[Q]=new R(e),this[D]=t,this[O]=document.createElement('canvas'),this[k]=document.createElement('canvas'),this[D].appendChild(this[k]),this[A]=this[B](e),this[I]=this[O].getContext('2d'),this[H]=this[k].getContext('2d'),this[N]=new b(this[I],this[A]),this[K]=new X(this[N],this[A]),this[j]=new z(this[k],this[N]),this[V]=new C(this[H],{width:e.width,height:e.height,devicePixelRatio:e.devicePixelRatio||1,scrollConfig:e.scrollConfig}),this[F]()}return e.prototype.getDisplayContext=function(){return this[H]},e.prototype.getOriginContext=function(){return this[I]},e.prototype.getContext=function(){return this[N]},e.prototype.scale=function(t){t>0&&this[N].setTransform({scale:t});var e=this[K].calcScreen();return{position:e.position,size:e.size}},e.prototype.scrollX=function(t){this[j].setStatusMap({canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}),(t>=0||t<0)&&this[N].setTransform({scrollX:t});var e=this[K].calcScreen(),i=e.position,o=e.size,n=e.canScrollXNext,r=e.canScrollYNext,s=e.canScrollXPrev,h=e.canScrollYPrev;return this[j].setStatusMap({canScrollYPrev:h,canScrollYNext:r,canScrollXPrev:s,canScrollXNext:n}),{position:i,size:o}},e.prototype.scrollY=function(t){this[j].setStatusMap({canScrollYPrev:!0,canScrollYNext:!0,canScrollXPrev:!0,canScrollXNext:!0}),(t>=0||t<0)&&this[N].setTransform({scrollY:t});var e=this[K].calcScreen(),i=e.position,o=e.size,n=e.canScrollXNext,r=e.canScrollYNext,s=e.canScrollXPrev,h=e.canScrollYPrev;return this[j].setStatusMap({canScrollYPrev:h,canScrollYNext:r,canScrollXPrev:s,canScrollXNext:n}),{position:i,size:o}},e.prototype.getTransform=function(){return this[N].getTransform()},e.prototype.draw=function(){this.clear();var t=this[K].calcScreen(),e=t.position,i=t.deviceSize,o=t.size;return this[H].drawImage(this[O],i.x,i.y,i.w,i.h),!0===this[A].canScroll&&this[V].draw(e),{position:e,size:o}},e.prototype.addPlugin=function(t){this[Q].get('plugins').push(t)},e.prototype.clear=function(){this[H].clearRect(0,0,this[k].width,this[k].height)},e.prototype.on=function(t,e){this[j].on(t,e)},e.prototype.off=function(t,e){this[j].off(t,e)},e.prototype.getScreenInfo=function(){return this[K].calcScreen()},e.prototype.setCursor=function(t){this[k].style.cursor=t},e.prototype.resetCursor=function(){this[k].style.cursor='auto'},e.prototype.resetSize=function(e){this[A]=t(t({},this[A]),e),this[J](),this[N].resetSize(e),this[K].resetSize(e),this[V].resetSize({width:this[A].width,height:this[A].height,devicePixelRatio:this[A].devicePixelRatio}),this.draw()},e.prototype.getScrollLineWidth=function(){var t=0;return!0===this[A].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,h=this[A],c=h.width,a=h.height,l=h.contextWidth,u=h.contextHeight,p=h.devicePixelRatio;this[O].width=l*p,this[O].height=u*p,this[k].width=c*p,this[k].height=a*p,e=this[k],i={width:c+"px",height:a+"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[A].canScroll){this.on('wheelX',Z((function(e){t[G](e)}),16)),this.on('wheelY',Z((function(e){t[$](e)}),16));var e=null;this.on('moveStart',Z((function(i){t[V].isPointAtScrollX(i)?e='x':t[V].isPointAtScrollY(i)&&(e='y')}),16)),this.on('move',Z((function(i){e&&t[q](e,i)}),16)),this.on('moveEnd',Z((function(i){e&&t[q](e,i),e=null}),16))}},e.prototype[G]=function(t,e){var i=this[A].width,o=e;'number'==typeof o&&(o>0||o<=0)||(o=this[N].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[A].height,o=e;'number'==typeof o&&(o>0||o<=0)||(o=this[N].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 tt}(); | ||
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}(); |
{ | ||
"name": "@idraw/board", | ||
"version": "0.2.0-alpha.20", | ||
"version": "0.2.0-alpha.21", | ||
"description": "", | ||
@@ -13,3 +13,4 @@ "main": "dist/index.cjs.js", | ||
"files": [ | ||
"dist" | ||
"dist/*.ts", | ||
"dist/*.js" | ||
], | ||
@@ -27,6 +28,6 @@ "repository": { | ||
"devDependencies": { | ||
"@idraw/types": "^0.2.0-alpha.20" | ||
"@idraw/types": "^0.2.0-alpha.21" | ||
}, | ||
"dependencies": { | ||
"@idraw/util": "^0.2.0-alpha.20" | ||
"@idraw/util": "^0.2.0-alpha.21" | ||
}, | ||
@@ -36,3 +37,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "d2340084ef92bd3637e8c7727b31e875864f13c8" | ||
"gitHead": "befdf7cdb086bbe017de65ebcba8f2a438184a12" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
218538
4857
Updated@idraw/util@^0.2.0-alpha.21