vislite 0.2.0-alpha.8 → 0.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTHORS.txt +6 -6
- package/CHANGELOG +20 -2
- package/LICENSE +20 -20
- package/README.md +53 -53
- package/lib/Canvas/index.umd.js +86 -13
- package/lib/Canvas/index.umd.min.js +2 -2
- package/lib/Cardinal/index.umd.js +1 -1
- package/lib/Cardinal/index.umd.min.js +1 -1
- package/lib/Eoap/index.umd.js +1 -1
- package/lib/Eoap/index.umd.min.js +1 -1
- package/lib/Hermite/index.umd.js +1 -1
- package/lib/Hermite/index.umd.min.js +1 -1
- package/lib/Matrix4/index.umd.js +1 -1
- package/lib/Matrix4/index.umd.min.js +1 -1
- package/lib/Mercator/index.umd.js +1 -1
- package/lib/Mercator/index.umd.min.js +1 -1
- package/lib/OralCanvas/index.es.js +86 -13
- package/lib/OralCanvas/index.es.min.js +2 -2
- package/lib/OralWebGL/index.es.js +3 -1
- package/lib/OralWebGL/index.es.min.js +1 -1
- package/lib/SVG/index.umd.js +77 -61
- package/lib/SVG/index.umd.min.js +2 -2
- package/lib/WebGL/index.umd.js +1 -1
- package/lib/WebGL/index.umd.min.js +1 -1
- package/lib/animation/index.umd.js +1 -1
- package/lib/animation/index.umd.min.js +1 -1
- package/lib/getLoopColors/index.umd.js +1 -1
- package/lib/getLoopColors/index.umd.min.js +1 -1
- package/lib/index.umd.js +162 -73
- package/lib/index.umd.min.js +2 -2
- package/lib/rotate/index.umd.js +1 -1
- package/lib/rotate/index.umd.min.js +1 -1
- package/lib/ruler/index.umd.js +1 -1
- package/lib/ruler/index.umd.min.js +1 -1
- package/lib/viewHandler/index.umd.js +1 -1
- package/lib/viewHandler/index.umd.min.js +1 -1
- package/miniprogram/ui-canvas/index.json +4 -4
- package/miniprogram/ui-canvas/index.wxml +4 -4
- package/miniprogram/ui-canvas/index.wxss +5 -5
- package/package/Canvas/index.ts +1 -1
- package/package/Cardinal/index.ts +2 -2
- package/package/Eoap/index.ts +2 -2
- package/package/Hermite/index.ts +2 -2
- package/package/Matrix4/index.ts +2 -2
- package/package/OralCanvas/index.ts +1 -1
- package/package/OralWebGL/index.ts +1 -1
- package/package/SVG/index.ts +2 -2
- package/package/animation/index.ts +2 -2
- package/package/getLoopColors/index.ts +2 -2
- package/package/rotate/index.ts +2 -2
- package/package/ruler/index.ts +2 -2
- package/package.json +4 -4
- package/src/Matrix4/index.ts +76 -76
- package/src/Matrix4/move.ts +12 -12
- package/src/Matrix4/rotate.ts +15 -15
- package/src/Matrix4/scale.ts +11 -11
- package/src/Matrix4/transform.ts +64 -64
- package/src/animation.ts +99 -99
- package/src/common/canvas/arc.ts +50 -50
- package/src/common/canvas/config.ts +142 -61
- package/src/common/canvas/gradient.ts +29 -0
- package/src/common/canvas/index.ts +122 -82
- package/src/common/canvas/painter.ts +12 -0
- package/src/common/setStyle.ts +5 -5
- package/src/common/svg/config.ts +173 -128
- package/src/common/svg/index.ts +315 -266
- package/src/common/svg/tool.ts +43 -43
- package/src/getLoopColors.ts +42 -42
- package/src/interpolation/Cardinal.ts +91 -91
- package/src/interpolation/Hermite.ts +65 -65
- package/src/rotate.ts +7 -7
- package/src/ruler.ts +99 -99
- package/types/Canvas.d.ts +282 -221
- package/types/CanvasConfig.d.ts +3 -3
- package/types/Cardinal.d.ts +13 -13
- package/types/Gradient.d.ts +15 -0
- package/types/Hermite.d.ts +18 -18
- package/types/Matrix4.d.ts +42 -42
- package/types/SVG.d.ts +210 -210
- package/types/animation.d.ts +6 -6
- package/types/getLoopColors.d.ts +2 -2
- package/types/rotate.d.ts +2 -2
- package/types/ruler.d.ts +2 -2
- package/uni-app/ui-canvas.vue +22 -67
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.3.0-alpha.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
@@ -75,7 +75,14 @@ var initText = function (painter, config, x, y, deg) {
|
|
|
75
75
|
painter.beginPath();
|
|
76
76
|
painter.translate(x, y);
|
|
77
77
|
painter.rotate(deg);
|
|
78
|
-
painter.font =
|
|
78
|
+
painter.font =
|
|
79
|
+
config.fontStyle +
|
|
80
|
+
" " +
|
|
81
|
+
config.fontWeight +
|
|
82
|
+
" " +
|
|
83
|
+
config.fontSize +
|
|
84
|
+
"px " +
|
|
85
|
+
config.fontFamily;
|
|
79
86
|
return painter;
|
|
80
87
|
};
|
|
81
88
|
var initArc = function (painter, config, cx, cy, r1, r2, beginDeg, deg) {
|
|
@@ -97,17 +104,21 @@ var initArc = function (painter, config, cx, cy, r1, r2, beginDeg, deg) {
|
|
|
97
104
|
painter.beginPath();
|
|
98
105
|
painter.moveTo(begInnerX, begInnerY);
|
|
99
106
|
painter.arc(cx, cy, r1, beginA, endA, false);
|
|
100
|
-
if (config.arcEndCap
|
|
101
|
-
painter.lineTo(endOuterX, endOuterY);
|
|
102
|
-
else
|
|
107
|
+
if (config.arcEndCap == "round")
|
|
103
108
|
painter.arc((endInnerX + endOuterX) * 0.5, (endInnerY + endOuterY) * 0.5, r, endA - Math.PI, endA, true);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
painter.lineTo(begInnerX, begInnerY);
|
|
109
|
+
else if (config.arcEndCap == "-round")
|
|
110
|
+
painter.arc((endInnerX + endOuterX) * 0.5, (endInnerY + endOuterY) * 0.5, r, endA - Math.PI, endA, false);
|
|
107
111
|
else
|
|
112
|
+
painter.lineTo(endOuterX, endOuterY);
|
|
113
|
+
painter.arc(cx, cy, r2, endA, beginA, true);
|
|
114
|
+
if (config.arcStartCap == "round")
|
|
108
115
|
painter.arc((begInnerX + begOuterX) * 0.5, (begInnerY + begOuterY) * 0.5, r, beginA, beginA - Math.PI, true);
|
|
116
|
+
else if (config.arcStartCap == "-round")
|
|
117
|
+
painter.arc((begInnerX + begOuterX) * 0.5, (begInnerY + begOuterY) * 0.5, r, beginA, beginA - Math.PI, false);
|
|
118
|
+
else
|
|
119
|
+
painter.lineTo(begInnerX, begInnerY);
|
|
109
120
|
});
|
|
110
|
-
if (config.arcStartCap ==
|
|
121
|
+
if (config.arcStartCap == "butt")
|
|
111
122
|
painter.closePath();
|
|
112
123
|
return painter;
|
|
113
124
|
};
|
|
@@ -180,6 +191,9 @@ var Painter = (function () {
|
|
|
180
191
|
this.painter.setLineDash(value);
|
|
181
192
|
}
|
|
182
193
|
else if (key in this.__specialConfig) {
|
|
194
|
+
if (key == 'fontSize') {
|
|
195
|
+
value = Math.round(value);
|
|
196
|
+
}
|
|
183
197
|
this.__specialConfig[key] = value;
|
|
184
198
|
}
|
|
185
199
|
else if (key in this.__initConfig) {
|
|
@@ -323,6 +337,12 @@ var Painter = (function () {
|
|
|
323
337
|
this.painter.restore();
|
|
324
338
|
return this;
|
|
325
339
|
};
|
|
340
|
+
Painter.prototype.clip = function () {
|
|
341
|
+
if (this.__region)
|
|
342
|
+
this.__region.clip();
|
|
343
|
+
this.painter.clip();
|
|
344
|
+
return this;
|
|
345
|
+
};
|
|
326
346
|
Painter.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
|
|
327
347
|
if (this.__region)
|
|
328
348
|
this.__region.quadraticCurveTo(cpx, cpy, x, y);
|
|
@@ -422,19 +442,46 @@ function assemble (begin, end, step, count) {
|
|
|
422
442
|
};
|
|
423
443
|
}
|
|
424
444
|
|
|
445
|
+
var linearGradient = function (painter, x0, y0, x1, y1) {
|
|
446
|
+
var gradient = painter.createLinearGradient(x0, y0, x1, y1);
|
|
447
|
+
var enhanceGradient = {
|
|
448
|
+
"value": function () {
|
|
449
|
+
return gradient;
|
|
450
|
+
},
|
|
451
|
+
"setColor": function (stop, color) {
|
|
452
|
+
gradient.addColorStop(stop, color);
|
|
453
|
+
return enhanceGradient;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
return enhanceGradient;
|
|
457
|
+
};
|
|
458
|
+
var radialGradient = function (painter, cx, cy, r) {
|
|
459
|
+
var gradient = painter.createRadialGradient(cx, cy, 0, cx, cy, r);
|
|
460
|
+
var enhanceGradient = {
|
|
461
|
+
"value": function () {
|
|
462
|
+
return gradient;
|
|
463
|
+
},
|
|
464
|
+
"setColor": function (stop, color) {
|
|
465
|
+
gradient.addColorStop(stop, color);
|
|
466
|
+
return enhanceGradient;
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
return enhanceGradient;
|
|
470
|
+
};
|
|
471
|
+
|
|
425
472
|
var oldAttrName = {
|
|
426
473
|
"font-size": "fontSize",
|
|
427
474
|
"font-family": "fontFamily",
|
|
428
475
|
"font-weight": "fontWeight",
|
|
429
476
|
"font-style": "fontStyle",
|
|
430
477
|
"arc-start-cap": "arcStartCap",
|
|
431
|
-
"arc-end-cap": "arcEndCap"
|
|
478
|
+
"arc-end-cap": "arcEndCap",
|
|
432
479
|
};
|
|
433
480
|
var Canvas = (function (_super) {
|
|
434
481
|
__extends(Canvas, _super);
|
|
435
482
|
function Canvas(ViewCanvas, RegionCanvas) {
|
|
436
483
|
var _this = _super.call(this, ViewCanvas, {}, new Painter(RegionCanvas, {
|
|
437
|
-
willReadFrequently: true
|
|
484
|
+
willReadFrequently: true,
|
|
438
485
|
})) || this;
|
|
439
486
|
_this.name = "Canvas";
|
|
440
487
|
_this.__regionList = {};
|
|
@@ -453,7 +500,8 @@ var Canvas = (function (_super) {
|
|
|
453
500
|
if (regionName) {
|
|
454
501
|
if (this.__regionList[regionName] == undefined) {
|
|
455
502
|
var tempColor = this.__regionAssemble();
|
|
456
|
-
this.__regionList[regionName] =
|
|
503
|
+
this.__regionList[regionName] =
|
|
504
|
+
"rgb(" + tempColor[0] + "," + tempColor[1] + "," + tempColor[2] + ")";
|
|
457
505
|
}
|
|
458
506
|
this.__region.useConfig("fillStyle", this.__regionList[regionName]) &&
|
|
459
507
|
this.__region.useConfig("strokeStyle", this.__regionList[regionName]);
|
|
@@ -471,7 +519,14 @@ var Canvas = (function (_super) {
|
|
|
471
519
|
var currentRGBA = imgData.data;
|
|
472
520
|
var doit = function () {
|
|
473
521
|
for (var key in _this.__regionList) {
|
|
474
|
-
if ("rgb(" +
|
|
522
|
+
if ("rgb(" +
|
|
523
|
+
currentRGBA[0] +
|
|
524
|
+
"," +
|
|
525
|
+
currentRGBA[1] +
|
|
526
|
+
"," +
|
|
527
|
+
currentRGBA[2] +
|
|
528
|
+
")" ==
|
|
529
|
+
_this.__regionList[key]) {
|
|
475
530
|
resolve(key);
|
|
476
531
|
break;
|
|
477
532
|
}
|
|
@@ -493,6 +548,24 @@ var Canvas = (function (_super) {
|
|
|
493
548
|
if (isRegion === void 0) { isRegion = false; }
|
|
494
549
|
return isRegion ? this.__region.painter : this.painter;
|
|
495
550
|
};
|
|
551
|
+
Canvas.prototype.createLinearGradient = function (x0, y0, x1, y1) {
|
|
552
|
+
return linearGradient(this.painter, x0, y0, x1, y1);
|
|
553
|
+
};
|
|
554
|
+
Canvas.prototype.createRadialGradient = function (cx, cy, r) {
|
|
555
|
+
return radialGradient(this.painter, cx, cy, r);
|
|
556
|
+
};
|
|
557
|
+
Canvas.prototype.getColor = function (x, y) {
|
|
558
|
+
var currentRGBA = this.painter.getImageData(x - 0.5, y - 0.5, 1, 1).data;
|
|
559
|
+
return ("rgba(" +
|
|
560
|
+
currentRGBA[0] +
|
|
561
|
+
"," +
|
|
562
|
+
currentRGBA[1] +
|
|
563
|
+
"," +
|
|
564
|
+
currentRGBA[2] +
|
|
565
|
+
"," +
|
|
566
|
+
currentRGBA[3] +
|
|
567
|
+
")");
|
|
568
|
+
};
|
|
496
569
|
return Canvas;
|
|
497
570
|
}(Painter));
|
|
498
571
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.3.0-alpha.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* alpha:内测版本,仅供开发人员提供测试环境而发布,后续的修改可能极具破坏性,非有明确了解前请勿直接用于项目中
|
|
13
13
|
* beta:外测版本,正式发布前的确认测试,或者新功能紧急发布,一般可以直接用于实际项目,因为即使后续发现了问题,直接使用正式版即可,不会有破坏性
|
|
14
14
|
*/
|
|
15
|
-
var t=function(i,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e])},t(i,e)};var i=function(t,i,e,r,n){var o=Math.cos(e),s=Math.sin(e);return[+((r-t)*o-(n-i)*s+t).toFixed(7),+((r-t)*s+(n-i)*o+i).toFixed(7)]};var e=function(t,i,e,r,n){return t.beginPath(),t.translate(e,r),t.rotate(n),t.font=i.fontStyle+" "+i.fontWeight+" "+i.fontSize+"px "+i.fontFamily,t},r=function(t,e,r,n,o,s,a,h){if(o>s){var _=o;o=s,s=_}return a%=2*Math.PI,h>=1.999999*Math.PI||h<=1.999999*-Math.PI?h=2*Math.PI:h%=2*Math.PI,function(t,e,r,n,o,s,a){e<0&&(t+=e,e*=-1);var h,_=[];h=i(0,0,t,o,0),_[0]=h[0],_[1]=h[1],h=i(0,0,e,h[0],h[1]),_[2]=h[0],_[3]=h[1],h=i(0,0,t,s,0),_[4]=h[0],_[5]=h[1],h=i(0,0,e,h[0],h[1]),_[6]=h[0],_[7]=h[1],a(t,t+e,_[0]+r,_[1]+n,_[4]+r,_[5]+n,_[2]+r,_[3]+n,_[6]+r,_[7]+n,.5*(s-o))}(a,h,r,n,o,s,(function(i,a,h,_,l,p,f,u,c,g,
|
|
15
|
+
var t=function(i,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e])},t(i,e)};var i=function(t,i,e,r,n){var o=Math.cos(e),s=Math.sin(e);return[+((r-t)*o-(n-i)*s+t).toFixed(7),+((r-t)*s+(n-i)*o+i).toFixed(7)]};var e=function(t,i,e,r,n){return t.beginPath(),t.translate(e,r),t.rotate(n),t.font=i.fontStyle+" "+i.fontWeight+" "+i.fontSize+"px "+i.fontFamily,t},r=function(t,e,r,n,o,s,a,h){if(o>s){var _=o;o=s,s=_}return a%=2*Math.PI,h>=1.999999*Math.PI||h<=1.999999*-Math.PI?h=2*Math.PI:h%=2*Math.PI,function(t,e,r,n,o,s,a){e<0&&(t+=e,e*=-1);var h,_=[];h=i(0,0,t,o,0),_[0]=h[0],_[1]=h[1],h=i(0,0,e,h[0],h[1]),_[2]=h[0],_[3]=h[1],h=i(0,0,t,s,0),_[4]=h[0],_[5]=h[1],h=i(0,0,e,h[0],h[1]),_[6]=h[0],_[7]=h[1],a(t,t+e,_[0]+r,_[1]+n,_[4]+r,_[5]+n,_[2]+r,_[3]+n,_[6]+r,_[7]+n,.5*(s-o))}(a,h,r,n,o,s,(function(i,a,h,_,l,p,f,u,c,g,v){v<0&&(v=-v),t.beginPath(),t.moveTo(h,_),t.arc(r,n,o,i,a,!1),"round"==e.arcEndCap?t.arc(.5*(f+c),.5*(u+g),v,a-Math.PI,a,!0):"-round"==e.arcEndCap?t.arc(.5*(f+c),.5*(u+g),v,a-Math.PI,a,!1):t.lineTo(c,g),t.arc(r,n,s,a,i,!0),"round"==e.arcStartCap?t.arc(.5*(h+l),.5*(_+p),v,i,i-Math.PI,!0):"-round"==e.arcStartCap?t.arc(.5*(h+l),.5*(_+p),v,i,i-Math.PI,!1):t.lineTo(h,_)})),"butt"==e.arcStartCap&&t.closePath(),t},n=function(t,i,e,r){return t.beginPath(),t.moveTo(i+r,e),t.arc(i,e,r,0,2*Math.PI),t},o=function(t,i,e,r,n){return t.beginPath(),t.rect(i,e,r,n),t};function s(t,i,e,r,n){for(var o=0,s="",a=0;a<i.length;a++)t.measureText(s+i[a]).width>e?(n(s,((o+=1)-.5)*r),s=i[a]):a==i.length-1?(o+=1,n(s+i[a],(o-.5)*r)):s+=i[a];return o*r}var a=function(){function t(t,i,e){void 0===i&&(i={}),this.__region=null,this.__specialConfig={fontSize:16,fontFamily:"sans-serif",fontWeight:400,fontStyle:"normal",arcStartCap:"butt",arcEndCap:"butt"},this.__initConfig={fillStyle:"black",strokeStyle:"black",lineWidth:1,textAlign:"left",textBaseline:"middle",lineDash:[],shadowBlur:0,shadowColor:"black"},this.painter=t.getContext("2d",i),this.__region=e,this.painter.textBaseline="middle",this.painter.textAlign="left"}return t.prototype.useConfig=function(t,i){if(this.__region&&["fillStyle","strokeStyle","shadowBlur","shadowColor"].indexOf(t)<0&&this.__region.useConfig(t,i),"lineDash"==t)this.painter.setLineDash&&this.painter.setLineDash(i);else if(t in this.__specialConfig)"fontSize"==t&&(i=Math.round(i)),this.__specialConfig[t]=i;else{if(!(t in this.__initConfig))throw new Error("Illegal configuration item of painter : "+t+" !");this.painter[t]=i}return this},t.prototype.fillText=function(t,i,r,n){return void 0===n&&(n=0),this.__region&&this.__region.fillText(t,i,r,n),this.painter.save(),e(this.painter,this.__specialConfig,i,r,n).fillText(t,0,0),this.painter.restore(),this},t.prototype.strokeText=function(t,i,r,n){return void 0===n&&(n=0),this.__region&&this.__region.strokeText(t,i,r,n),this.painter.save(),e(this.painter,this.__specialConfig,i,r,n).strokeText(t,0,0),this.painter.restore(),this},t.prototype.fullText=function(t,i,r,n){return void 0===n&&(n=0),this.__region&&this.__region.fullText(t,i,r,n),this.painter.save(),e(this.painter,this.__specialConfig,i,r,n),this.painter.fillText(t,0,0),this.painter.strokeText(t,0,0),this.painter.restore(),this},t.prototype.fillTexts=function(t,i,r,n,o,a){var h=this;void 0===o&&(o=1.2),void 0===a&&(a=0),this.__region&&this.__region.fillTexts(t,i,r,n,o),this.painter.save(),e(this.painter,this.__specialConfig,i,r,a);var _=s(this.painter,t,n,this.__specialConfig.fontSize*o,(function(t,i){h.painter.fillText(t,0,i)}));return this.painter.restore(),_},t.prototype.strokeTexts=function(t,i,r,n,o,a){var h=this;void 0===o&&(o=1.2),void 0===a&&(a=0),this.__region&&this.__region.fillTexts(t,i,r,n,o),this.painter.save(),e(this.painter,this.__specialConfig,i,r,a);var _=s(this.painter,t,n,this.__specialConfig.fontSize*o,(function(t,i){h.painter.strokeText(t,0,i)}));return this.painter.restore(),_},t.prototype.fullTexts=function(t,i,r,n,o,a){var h=this;void 0===o&&(o=1.2),void 0===a&&(a=0),this.__region&&this.__region.fillTexts(t,i,r,n,o),this.painter.save(),e(this.painter,this.__specialConfig,i,r,a);var _=s(this.painter,t,n,this.__specialConfig.fontSize*o,(function(t,i){h.painter.fillText(t,0,i),h.painter.strokeText(t,0,i)}));return this.painter.restore(),_},t.prototype.beginPath=function(){return this.__region&&this.__region.beginPath(),this.painter.beginPath(),this},t.prototype.closePath=function(){return this.__region&&this.__region.closePath(),this.painter.closePath(),this},t.prototype.moveTo=function(t,i){return this.__region&&this.__region.moveTo(t,i),this.painter.moveTo(Math.round(t)+.5,Math.round(i)+.5),this},t.prototype.lineTo=function(t,i){return this.__region&&this.__region.lineTo(t,i),this.painter.lineTo(Math.round(t)+.5,Math.round(i)+.5),this},t.prototype.arc=function(t,i,e,r,n){return this.__region&&this.__region.arc(t,i,e,r,n),this.painter.arc(t,i,e,r,r+n,n<0),this},t.prototype.fill=function(){return this.__region&&this.__region.fill(),this.painter.fill(),this},t.prototype.stroke=function(){return this.__region&&this.__region.stroke(),this.painter.stroke(),this},t.prototype.full=function(){return this.__region&&this.__region.full(),this.painter.fill(),this.painter.stroke(),this},t.prototype.save=function(){return this.__region&&this.__region.save(),this.painter.save(),this},t.prototype.restore=function(){return this.__region&&this.__region.restore(),this.painter.restore(),this},t.prototype.clip=function(){return this.__region&&this.__region.clip(),this.painter.clip(),this},t.prototype.quadraticCurveTo=function(t,i,e,r){return this.__region&&this.__region.quadraticCurveTo(t,i,e,r),this.painter.quadraticCurveTo(t,i,e,r),this},t.prototype.bezierCurveTo=function(t,i,e,r,n,o){return this.__region&&this.__region.bezierCurveTo(t,i,e,r,n,o),this.painter.bezierCurveTo(t,i,e,r,n,o),this},t.prototype.clearRect=function(t,i,e,r){return this.__region&&this.__region.clearRect(t,i,e,r),this.painter.clearRect(t,i,e,r),this},t.prototype.fillArc=function(t,i,e,n,o,s){return this.__region&&this.__region.fillArc(t,i,e,n,o,s),r(this.painter,this.__specialConfig,t,i,e,n,o,s).fill(),this},t.prototype.strokeArc=function(t,i,e,n,o,s){return this.__region&&this.__region.strokeArc(t,i,e,n,o,s),r(this.painter,this.__specialConfig,t,i,e,n,o,s).stroke(),this},t.prototype.fullArc=function(t,i,e,n,o,s){return this.__region&&this.__region.fullArc(t,i,e,n,o,s),r(this.painter,this.__specialConfig,t,i,e,n,o,s),this.painter.fill(),this.painter.stroke(),this},t.prototype.fillCircle=function(t,i,e){return this.__region&&this.__region.fillCircle(t,i,e),n(this.painter,t,i,e).fill(),this},t.prototype.strokeCircle=function(t,i,e){return this.__region&&this.__region.strokeCircle(t,i,e),n(this.painter,t,i,e).stroke(),this},t.prototype.fullCircle=function(t,i,e){return this.__region&&this.__region.fullCircle(t,i,e),n(this.painter,t,i,e),this.painter.fill(),this.painter.stroke(),this},t.prototype.fillRect=function(t,i,e,r){return this.__region&&this.__region.fillRect(t,i,e,r),o(this.painter,t,i,e,r).fill(),this},t.prototype.strokeRect=function(t,i,e,r){return this.__region&&this.__region.strokeRect(t,i,e,r),o(this.painter,t,i,e,r).stroke(),this},t.prototype.fullRect=function(t,i,e,r){return this.__region&&this.__region.fullRect(t,i,e,r),o(this.painter,t,i,e,r),this.painter.fill(),this.painter.stroke(),this},t}();var h={"font-size":"fontSize","font-family":"fontFamily","font-weight":"fontWeight","font-style":"fontStyle","arc-start-cap":"arcStartCap","arc-end-cap":"arcEndCap"},_=function(i){function e(t,e){var r=i.call(this,t,{},new a(e,{willReadFrequently:!0}))||this;return r.name="Canvas",r.__regionList={},r.__regionAssemble=function(t,i,e,r){for(var n=[],o=0;o<r;o++)n[o]=t;return function(){for(var o=0;o<r;o++){if(n[o]<i){n[o]=+(n[o]+e).toFixed(7);break}o<r-1&&(n[o]=t)}return n}}(0,255,1,3),r.setRegion(""),r}return function(i,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=i}t(i,e),i.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,i),e.prototype.config=function(t){for(var i in t){var e=h[i]||i;this.useConfig(e,t[i])}return this},e.prototype.setRegion=function(t){if(t){if(null==this.__regionList[t]){var i=this.__regionAssemble();this.__regionList[t]="rgb("+i[0]+","+i[1]+","+i[2]+")"}this.__region.useConfig("fillStyle",this.__regionList[t])&&this.__region.useConfig("strokeStyle",this.__regionList[t])}else this.__region.useConfig("fillStyle","#000000")&&this.__region.useConfig("strokeStyle","#000000");return this},e.prototype.getRegion=function(t,i){var e=this;return new Promise((function(r,n){var o=e.__region.painter.getImageData(t-.5,i-.5,1,1),s=o.data,a=function(){for(var t in e.__regionList)if("rgb("+s[0]+","+s[1]+","+s[2]+")"==e.__regionList[t]){r(t);break}r("")};s?a():o.then((function(t){s=t,a()}))}))},e.prototype.getContext=function(t){return void 0===t&&(t=!1),t?this.__region.painter:this.painter},e.prototype.createLinearGradient=function(t,i,e,r){return function(t,i,e,r,n){var o=t.createLinearGradient(i,e,r,n),s={value:function(){return o},setColor:function(t,i){return o.addColorStop(t,i),s}};return s}(this.painter,t,i,e,r)},e.prototype.createRadialGradient=function(t,i,e){return function(t,i,e,r){var n=t.createRadialGradient(i,e,0,i,e,r),o={value:function(){return n},setColor:function(t,i){return n.addColorStop(t,i),o}};return o}(this.painter,t,i,e)},e.prototype.getColor=function(t,i){var e=this.painter.getImageData(t-.5,i-.5,1,1).data;return"rgba("+e[0]+","+e[1]+","+e[2]+","+e[3]+")"},e}(a);export{_ as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.3.0-alpha.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
@@ -26,6 +26,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
26
26
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
27
27
|
PERFORMANCE OF THIS SOFTWARE.
|
|
28
28
|
***************************************************************************** */
|
|
29
|
+
/* global Reflect, Promise */
|
|
30
|
+
|
|
29
31
|
|
|
30
32
|
function __spreadArray(to, from, pack) {
|
|
31
33
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
package/lib/SVG/index.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.3.0-alpha.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
@@ -117,22 +117,22 @@
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
var initText = function (el, config, x, y, deg) {
|
|
120
|
-
if (el.nodeName.toLowerCase() !==
|
|
121
|
-
throw new Error(
|
|
120
|
+
if (el.nodeName.toLowerCase() !== "text")
|
|
121
|
+
throw new Error("Need a <text> !");
|
|
122
122
|
setAttribute(el, "dy", {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
top: config["fontSize"] * 0.5,
|
|
124
|
+
middle: 0,
|
|
125
|
+
bottom: -config["fontSize"] * 0.5,
|
|
126
126
|
}[config.textBaseline]);
|
|
127
127
|
setStyle(el, {
|
|
128
128
|
"text-anchor": {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
left: "start",
|
|
130
|
+
right: "end",
|
|
131
|
+
center: "middle",
|
|
132
132
|
}[config.textAlign],
|
|
133
133
|
"dominant-baseline": "central",
|
|
134
|
-
"font-size": config[
|
|
135
|
-
"font-family": config[
|
|
134
|
+
"font-size": config["fontSize"] + "px",
|
|
135
|
+
"font-family": config["fontFamily"],
|
|
136
136
|
});
|
|
137
137
|
setAttribute(el, "x", x);
|
|
138
138
|
setAttribute(el, "y", y);
|
|
@@ -142,20 +142,20 @@
|
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
144
|
var initCircle = function (el, cx, cy, r) {
|
|
145
|
-
if (el.nodeName.toLowerCase() !==
|
|
146
|
-
throw new Error(
|
|
147
|
-
setAttribute(el,
|
|
148
|
-
setAttribute(el,
|
|
149
|
-
setAttribute(el,
|
|
145
|
+
if (el.nodeName.toLowerCase() !== "circle")
|
|
146
|
+
throw new Error("Need a <circle> !");
|
|
147
|
+
setAttribute(el, "cx", cx);
|
|
148
|
+
setAttribute(el, "cy", cy);
|
|
149
|
+
setAttribute(el, "r", r);
|
|
150
150
|
};
|
|
151
151
|
var initPath = function (el, path) {
|
|
152
|
-
if (el.nodeName.toLowerCase() !==
|
|
153
|
-
throw new Error(
|
|
154
|
-
setAttribute(el,
|
|
152
|
+
if (el.nodeName.toLowerCase() !== "path")
|
|
153
|
+
throw new Error("Need a <path> !");
|
|
154
|
+
setAttribute(el, "d", path);
|
|
155
155
|
};
|
|
156
156
|
var initRect = function (el, x, y, width, height) {
|
|
157
|
-
if (el.nodeName.toLowerCase() !==
|
|
158
|
-
throw new Error(
|
|
157
|
+
if (el.nodeName.toLowerCase() !== "rect")
|
|
158
|
+
throw new Error("Need a <rect> !");
|
|
159
159
|
if (height < 0) {
|
|
160
160
|
height *= -1;
|
|
161
161
|
y -= height;
|
|
@@ -164,14 +164,16 @@
|
|
|
164
164
|
width *= -1;
|
|
165
165
|
x -= width;
|
|
166
166
|
}
|
|
167
|
-
setAttribute(el,
|
|
168
|
-
setAttribute(el,
|
|
169
|
-
setAttribute(el,
|
|
170
|
-
setAttribute(el,
|
|
167
|
+
setAttribute(el, "x", x);
|
|
168
|
+
setAttribute(el, "y", y);
|
|
169
|
+
setAttribute(el, "width", width);
|
|
170
|
+
setAttribute(el, "height", height);
|
|
171
171
|
};
|
|
172
172
|
var initArc = function (el, config, cx, cy, r1, r2, beginDeg, deg) {
|
|
173
|
-
if (el.nodeName.toLowerCase() !==
|
|
174
|
-
throw new Error(
|
|
173
|
+
if (el.nodeName.toLowerCase() !== "path")
|
|
174
|
+
throw new Error("Need a <path> !");
|
|
175
|
+
beginDeg = (beginDeg / 180) * Math.PI;
|
|
176
|
+
deg = (deg / 180) * Math.PI;
|
|
175
177
|
beginDeg = beginDeg % (Math.PI * 2);
|
|
176
178
|
if (r1 > r2) {
|
|
177
179
|
var temp = r1;
|
|
@@ -185,27 +187,28 @@
|
|
|
185
187
|
deg = deg % (Math.PI * 2);
|
|
186
188
|
}
|
|
187
189
|
arc(beginDeg, deg, cx, cy, r1, r2, function (beginA, endA, begInnerX, begInnerY, begOuterX, begOuterY, endInnerX, endInnerY, endOuterX, endOuterY, r) {
|
|
188
|
-
var f =
|
|
190
|
+
var f = endA - beginA > Math.PI ? 1 : 0, d = "M" + begInnerX + " " + begInnerY;
|
|
189
191
|
if (r < 0)
|
|
190
192
|
r = -r;
|
|
191
193
|
d +=
|
|
192
194
|
"A" + r1 + " " + r1 + " 0 " + f + " 1 " + endInnerX + " " + endInnerY;
|
|
193
|
-
if (config
|
|
195
|
+
if (config.arcEndCap == "round")
|
|
194
196
|
d += "A" + r + " " + r + " " + " 0 1 0 " + endOuterX + " " + endOuterY;
|
|
195
|
-
else if (config
|
|
197
|
+
else if (config.arcEndCap == "-round")
|
|
196
198
|
d += "A" + r + " " + r + " " + " 0 1 1 " + endOuterX + " " + endOuterY;
|
|
197
199
|
else
|
|
198
200
|
d += "L" + endOuterX + " " + endOuterY;
|
|
199
|
-
d +=
|
|
200
|
-
|
|
201
|
+
d +=
|
|
202
|
+
"A" + r2 + " " + r2 + " 0 " + f + " 0 " + begOuterX + " " + begOuterY;
|
|
203
|
+
if (config.arcStartCap == "round")
|
|
201
204
|
d += "A" + r + " " + r + " " + " 0 1 0 " + begInnerX + " " + begInnerY;
|
|
202
|
-
else if (config
|
|
205
|
+
else if (config.arcStartCap == "-round")
|
|
203
206
|
d += "A" + r + " " + r + " " + " 0 1 1 " + begInnerX + " " + begInnerY;
|
|
204
207
|
else
|
|
205
208
|
d += "L" + begInnerX + " " + begInnerY;
|
|
206
|
-
if (config
|
|
209
|
+
if (config.arcStartCap == "butt")
|
|
207
210
|
d += "Z";
|
|
208
|
-
setAttribute(el,
|
|
211
|
+
setAttribute(el, "d", d);
|
|
209
212
|
});
|
|
210
213
|
};
|
|
211
214
|
|
|
@@ -221,29 +224,29 @@
|
|
|
221
224
|
"font-size": "fontSize",
|
|
222
225
|
"font-family": "fontFamily",
|
|
223
226
|
"arc-start-cap": "arcStartCap",
|
|
224
|
-
"arc-end-cap": "arcEndCap"
|
|
227
|
+
"arc-end-cap": "arcEndCap",
|
|
225
228
|
};
|
|
226
229
|
var SVG$1 = (function () {
|
|
227
230
|
function SVG(svg) {
|
|
228
231
|
this.name = "SVG";
|
|
229
232
|
this.__config = {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
fillStyle: "#000",
|
|
234
|
+
strokeStyle: "#000",
|
|
235
|
+
lineWidth: 1,
|
|
236
|
+
textAlign: "left",
|
|
237
|
+
textBaseline: "middle",
|
|
235
238
|
"font-size": 16,
|
|
236
239
|
"font-family": "sans-serif",
|
|
237
240
|
"arc-start-cap": "butt",
|
|
238
241
|
"arc-end-cap": "butt",
|
|
239
|
-
|
|
242
|
+
lineDash: [],
|
|
240
243
|
};
|
|
241
244
|
this.__path = "";
|
|
242
245
|
this.__currentPosition = [];
|
|
243
246
|
this.__svg = svg;
|
|
244
247
|
}
|
|
245
248
|
SVG.prototype.config = function (params) {
|
|
246
|
-
if (typeof params !==
|
|
249
|
+
if (typeof params !== "object") {
|
|
247
250
|
return this.__config[oldAttrName[params] || params];
|
|
248
251
|
}
|
|
249
252
|
else {
|
|
@@ -263,7 +266,7 @@
|
|
|
263
266
|
};
|
|
264
267
|
SVG.prototype.appendEl = function (el, context) {
|
|
265
268
|
context = context || this.__svg;
|
|
266
|
-
if (typeof el ==
|
|
269
|
+
if (typeof el == "string")
|
|
267
270
|
el = toNode(el);
|
|
268
271
|
context.appendChild(el);
|
|
269
272
|
this.__useEl = el;
|
|
@@ -271,14 +274,15 @@
|
|
|
271
274
|
};
|
|
272
275
|
SVG.prototype.appendBoard = function (el, context) {
|
|
273
276
|
var _el = el;
|
|
274
|
-
if (typeof el ==
|
|
275
|
-
_el =
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
277
|
+
if (typeof el == "string")
|
|
278
|
+
_el =
|
|
279
|
+
{
|
|
280
|
+
text: "text",
|
|
281
|
+
path: "path",
|
|
282
|
+
arc: "path",
|
|
283
|
+
circle: "circle",
|
|
284
|
+
rect: "rect",
|
|
285
|
+
}[el] || "";
|
|
282
286
|
if (_el == "")
|
|
283
287
|
throw new Error("Unsupported drawing method:" + el);
|
|
284
288
|
return this.appendEl(_el, context);
|
|
@@ -295,7 +299,7 @@
|
|
|
295
299
|
SVG.prototype.attr = function (params) {
|
|
296
300
|
if (!this.__useEl)
|
|
297
301
|
throw new Error("Currently, no node can be modified or viewed.");
|
|
298
|
-
if (typeof params !==
|
|
302
|
+
if (typeof params !== "object") {
|
|
299
303
|
return getAttribute(this.__useEl, params);
|
|
300
304
|
}
|
|
301
305
|
else {
|
|
@@ -406,17 +410,28 @@
|
|
|
406
410
|
return this;
|
|
407
411
|
};
|
|
408
412
|
SVG.prototype.arc = function (x, y, r, beginDeg, deg) {
|
|
409
|
-
var begPosition = rotate(x, y, beginDeg, x + r, y);
|
|
410
|
-
var endPosition = rotate(x, y, beginDeg + deg, x + r, y);
|
|
411
|
-
|
|
412
|
-
deg = deg / Math.PI * 180;
|
|
413
|
-
if (this.__path == '') {
|
|
413
|
+
var begPosition = rotate(x, y, (beginDeg / 180) * Math.PI, x + r, y);
|
|
414
|
+
var endPosition = rotate(x, y, ((beginDeg + deg) / 180) * Math.PI, x + r, y);
|
|
415
|
+
if (this.__path == "") {
|
|
414
416
|
this.__path += "M" + begPosition[0] + "," + begPosition[1];
|
|
415
417
|
}
|
|
416
|
-
else if (begPosition[0] != this.__currentPosition[0] ||
|
|
418
|
+
else if (begPosition[0] != this.__currentPosition[0] ||
|
|
419
|
+
begPosition[1] != this.__currentPosition[1]) {
|
|
417
420
|
this.__path += "L" + begPosition[0] + "," + begPosition[1];
|
|
418
421
|
}
|
|
419
|
-
this.__path +=
|
|
422
|
+
this.__path +=
|
|
423
|
+
"A" +
|
|
424
|
+
r +
|
|
425
|
+
"," +
|
|
426
|
+
r +
|
|
427
|
+
" 0 " +
|
|
428
|
+
(deg > 180 || deg < -180 ? 1 : 0) +
|
|
429
|
+
"," +
|
|
430
|
+
(deg > 0 ? 1 : 0) +
|
|
431
|
+
" " +
|
|
432
|
+
endPosition[0] +
|
|
433
|
+
"," +
|
|
434
|
+
endPosition[1];
|
|
420
435
|
return this;
|
|
421
436
|
};
|
|
422
437
|
SVG.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
|
|
@@ -424,7 +439,8 @@
|
|
|
424
439
|
return this;
|
|
425
440
|
};
|
|
426
441
|
SVG.prototype.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
427
|
-
this.__path +=
|
|
442
|
+
this.__path +=
|
|
443
|
+
"C" + cp1x + " " + cp1y + "," + cp2x + " " + cp2y + "," + x + " " + y;
|
|
428
444
|
return this;
|
|
429
445
|
};
|
|
430
446
|
return SVG;
|
package/lib/SVG/index.umd.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.
|
|
2
|
+
* VISLite JavaScript Library v0.3.0-alpha.0
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* alpha:内测版本,仅供开发人员提供测试环境而发布,后续的修改可能极具破坏性,非有明确了解前请勿直接用于项目中
|
|
13
13
|
* beta:外测版本,正式发布前的确认测试,或者新功能紧急发布,一般可以直接用于实际项目,因为即使后续发现了问题,直接使用正式版即可,不会有破坏性
|
|
14
14
|
*/
|
|
15
|
-
var t,e;t=this,e=function(){"use strict";var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)},e=["href","title","show","type","role","actuate"],i=function(t,i,n){e.indexOf(i)>-1?t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:"+i,n+""):t.setAttribute(i,n+"")},n=i;function o(t,e){i(t,"stroke",e.strokeStyle),i(t,"fill",e.fillStyle),i(t,"stroke-dasharray",e.lineDash.join(","))}function r(t,e){i(t,"fill",e.fillStyle)}function s(t,e){i(t,"stroke",e.strokeStyle),i(t,"fill","none"),i(t,"stroke-dasharray",e.lineDash.join(","))}var h=function(t,e,i,n,o){var r=Math.cos(i),s=Math.sin(i);return[+((n-t)*r-(o-e)*s+t).toFixed(7),+((n-t)*s+(o-e)*r+e).toFixed(7)]},u=function(t,e,i,o,r){if("text"!==t.nodeName.toLowerCase())throw new Error("Need a <text> !");n(t,"dy",{top:.5*e
|
|
15
|
+
var t,e;t=this,e=function(){"use strict";var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)},e=["href","title","show","type","role","actuate"],i=function(t,i,n){e.indexOf(i)>-1?t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:"+i,n+""):t.setAttribute(i,n+"")},n=i;function o(t,e){i(t,"stroke",e.strokeStyle),i(t,"fill",e.fillStyle),i(t,"stroke-dasharray",e.lineDash.join(","))}function r(t,e){i(t,"fill",e.fillStyle)}function s(t,e){i(t,"stroke",e.strokeStyle),i(t,"fill","none"),i(t,"stroke-dasharray",e.lineDash.join(","))}var h=function(t,e,i,n,o){var r=Math.cos(i),s=Math.sin(i);return[+((n-t)*r-(o-e)*s+t).toFixed(7),+((n-t)*s+(o-e)*r+e).toFixed(7)]},u=function(t,e,i,o,r){if("text"!==t.nodeName.toLowerCase())throw new Error("Need a <text> !");n(t,"dy",{top:.5*e.fontSize,middle:0,bottom:.5*-e.fontSize}[e.textBaseline]),function(t,e){for(var i in e)t.style[i]=e[i]}(t,{"text-anchor":{left:"start",right:"end",center:"middle"}[e.textAlign],"dominant-baseline":"central","font-size":e.fontSize+"px","font-family":e.fontFamily}),n(t,"x",i),n(t,"y",o),"number"==typeof r&&n(t,"transform","rotate("+(r%=360)+","+i+","+o+")")},_=function(t,e,i,o){if("circle"!==t.nodeName.toLowerCase())throw new Error("Need a <circle> !");n(t,"cx",e),n(t,"cy",i),n(t,"r",o)},c=function(t,e){if("path"!==t.nodeName.toLowerCase())throw new Error("Need a <path> !");n(t,"d",e)},a=function(t,e,i,o,r){if("rect"!==t.nodeName.toLowerCase())throw new Error("Need a <rect> !");r<0&&(i-=r*=-1),o<0&&(e-=o*=-1),n(t,"x",e),n(t,"y",i),n(t,"width",o),n(t,"height",r)},f=function(t,e,i,o,r,s,u,_){if("path"!==t.nodeName.toLowerCase())throw new Error("Need a <path> !");if(u=u/180*Math.PI,_=_/180*Math.PI,u%=2*Math.PI,r>s){var c=r;r=s,s=c}_>=1.999999*Math.PI||_<=1.999999*-Math.PI?_=1.999999*Math.PI:_%=2*Math.PI,function(t,e,i,n,o,r,s){e<0&&(t+=e,e*=-1);var u,_=[];u=h(0,0,t,o,0),_[0]=u[0],_[1]=u[1],u=h(0,0,e,u[0],u[1]),_[2]=u[0],_[3]=u[1],u=h(0,0,t,r,0),_[4]=u[0],_[5]=u[1],u=h(0,0,e,u[0],u[1]),_[6]=u[0],_[7]=u[1],s(t,t+e,_[0]+i,_[1]+n,_[4]+i,_[5]+n,_[2]+i,_[3]+n,_[6]+i,_[7]+n,.5*(r-o))}(u,_,i,o,r,s,(function(i,o,h,u,_,c,a,f,l,p,d){var y=o-i>Math.PI?1:0,E="M"+h+" "+u;d<0&&(d=-d),E+="A"+r+" "+r+" 0 "+y+" 1 "+a+" "+f,"round"==e.arcEndCap?E+="A"+d+" "+d+" 0 1 0 "+l+" "+p:"-round"==e.arcEndCap?E+="A"+d+" "+d+" 0 1 1 "+l+" "+p:E+="L"+l+" "+p,E+="A"+s+" "+s+" 0 "+y+" 0 "+_+" "+c,"round"==e.arcStartCap?E+="A"+d+" "+d+" 0 1 0 "+h+" "+u:"-round"==e.arcStartCap?E+="A"+d+" "+d+" 0 1 1 "+h+" "+u:E+="L"+h+" "+u,"butt"==e.arcStartCap&&(E+="Z"),n(t,"d",E)}))};function l(t,e,i,n,o){var r=Math.cos(i),s=Math.sin(i);return[(n-t)*r-(o-e)*s+t,(n-t)*s+(o-e)*r+e]}var p={"font-size":"fontSize","font-family":"fontFamily","arc-start-cap":"arcStartCap","arc-end-cap":"arcEndCap"},d=function(){function t(t){this.name="SVG",this.__config={fillStyle:"#000",strokeStyle:"#000",lineWidth:1,textAlign:"left",textBaseline:"middle","font-size":16,"font-family":"sans-serif","arc-start-cap":"butt","arc-end-cap":"butt",lineDash:[]},this.__path="",this.__currentPosition=[],this.__svg=t}return t.prototype.config=function(t){if("object"!=typeof t)return this.__config[p[t]||t];for(var e in t){var i=p[e]||e;this.__config[i]=t[e]}return this},t.prototype.useEl=function(t){return this.__useEl=t,this},t.prototype.getEl=function(){return this.__useEl},t.prototype.appendEl=function(t,e){var i;return e=e||this.__svg,"string"==typeof t&&(i=t,t=document.createElementNS("http://www.w3.org/2000/svg",i)),e.appendChild(t),this.__useEl=t,this},t.prototype.appendBoard=function(t,e){var i=t;if("string"==typeof t&&(i={text:"text",path:"path",arc:"path",circle:"circle",rect:"rect"}[t]||""),""==i)throw new Error("Unsupported drawing method:"+t);return this.appendEl(i,e)},t.prototype.remove=function(){if(!this.__useEl)throw new Error("Currently, no node can be deleted.");return this.__useEl.parentNode.removeChild(this.__useEl),this},t.prototype.attr=function(t){if(!this.__useEl)throw new Error("Currently, no node can be modified or viewed.");if("object"!=typeof t)return function(t,i){return e.indexOf(i)>-1&&(i="xlink:"+i),t.getAttribute(i)}(this.__useEl,t);for(var i in t)n(this.__useEl,i,t[i]);return this},t.prototype.fillText=function(t,e,i,n){return void 0===n&&(n=0),u(this.__useEl,this.__config,e,i,n),this.__useEl.textContent=t,r(this.__useEl,this.__config),this},t.prototype.strokeText=function(t,e,i,n){return void 0===n&&(n=0),u(this.__useEl,this.__config,e,i,n),this.__useEl.textContent=t,s(this.__useEl,this.__config),this},t.prototype.fullText=function(t,e,i,n){return void 0===n&&(n=0),u(this.__useEl,this.__config,e,i,n),this.__useEl.textContent=t,o(this.__useEl,this.__config),this},t.prototype.fillArc=function(t,e,i,n,o,s){return f(this.__useEl,this.__config,t,e,i,n,o,s),r(this.__useEl,this.__config),this},t.prototype.strokeArc=function(t,e,i,n,o,r){return f(this.__useEl,this.__config,t,e,i,n,o,r),s(this.__useEl,this.__config),this},t.prototype.fullArc=function(t,e,i,n,r,s){return f(this.__useEl,this.__config,t,e,i,n,r,s),o(this.__useEl,this.__config),this},t.prototype.fillCircle=function(t,e,i){return _(this.__useEl,t,e,i),r(this.__useEl,this.__config),this},t.prototype.strokeCircle=function(t,e,i){return _(this.__useEl,t,e,i),s(this.__useEl,this.__config),this},t.prototype.fullCircle=function(t,e,i){return _(this.__useEl,t,e,i),o(this.__useEl,this.__config),this},t.prototype.fillRect=function(t,e,i,n){return a(this.__useEl,t,e,i,n),r(this.__useEl,this.__config),this},t.prototype.strokeRect=function(t,e,i,n){return a(this.__useEl,t,e,i,n),s(this.__useEl,this.__config),this},t.prototype.fullRect=function(t,e,i,n){return a(this.__useEl,t,e,i,n),o(this.__useEl,this.__config),this},t.prototype.beginPath=function(){return this.__currentPosition=[],this.__path="",this},t.prototype.closePath=function(){return this.__path+="Z",this},t.prototype.moveTo=function(t,e){return this.__currentPosition=[t,e],this.__path+="M"+t+" "+e,this},t.prototype.lineTo=function(t,e){return this.__currentPosition=[t,e],this.__path+=(""==this.__path?"M":"L")+t+" "+e,this},t.prototype.fill=function(){return c(this.__useEl,this.__path),r(this.__useEl,this.__config),this},t.prototype.stroke=function(){return c(this.__useEl,this.__path),s(this.__useEl,this.__config),this},t.prototype.full=function(){return c(this.__useEl,this.__path),o(this.__useEl,this.__config),this},t.prototype.arc=function(t,e,i,n,o){var r=l(t,e,n/180*Math.PI,t+i,e),s=l(t,e,(n+o)/180*Math.PI,t+i,e);return""==this.__path?this.__path+="M"+r[0]+","+r[1]:r[0]==this.__currentPosition[0]&&r[1]==this.__currentPosition[1]||(this.__path+="L"+r[0]+","+r[1]),this.__path+="A"+i+","+i+" 0 "+(o>180||o<-180?1:0)+","+(o>0?1:0)+" "+s[0]+","+s[1],this},t.prototype.quadraticCurveTo=function(t,e,i,n){return this.__path+="Q"+t+" "+e+","+i+" "+n,this},t.prototype.bezierCurveTo=function(t,e,i,n,o,r){return this.__path+="C"+t+" "+e+","+i+" "+n+","+o+" "+r,this},t}();return function(e){function i(t){if(!t)throw new Error("VISLite SVG:The mount point requires an HTMLElement type but encountered null.");var i=t.clientWidth,n=t.clientHeight,o=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.appendChild(o),o.setAttribute("width",i+""),o.setAttribute("height",n+""),o.setAttribute("viewBox","0 0 "+i+" "+n),e.call(this,o)||this}return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}(i,e),i}(d)},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).VISLite_SVG=e();
|
package/lib/WebGL/index.umd.js
CHANGED