vislite 0.5.0 → 0.5.2-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.
Files changed (157) hide show
  1. package/.editorconfig +18 -18
  2. package/AUTHORS.txt +6 -6
  3. package/CHANGELOG +5 -0
  4. package/LICENSE +20 -20
  5. package/README.md +69 -69
  6. package/miniprogram/ui-canvas/index.js +107 -107
  7. package/miniprogram/ui-canvas/index.json +4 -4
  8. package/miniprogram/ui-canvas/index.wxml +4 -4
  9. package/miniprogram/ui-canvas/index.wxss +5 -5
  10. package/package/Buffer/index.ts +2 -2
  11. package/package/Canvas/index.ts +2 -2
  12. package/package/Cardinal/index.ts +2 -2
  13. package/package/Eoap/index.ts +2 -2
  14. package/package/Hermite/index.ts +2 -2
  15. package/package/Matrix4/index.ts +2 -2
  16. package/package/Mercator/index.ts +2 -2
  17. package/package/OralCanvas/index.ts +2 -2
  18. package/package/OralWebGL/index.ts +2 -2
  19. package/package/SVG/index.ts +2 -2
  20. package/package/Shader/index.ts +39 -39
  21. package/package/Texture/index.ts +2 -2
  22. package/package/TreeLayout/index.ts +2 -2
  23. package/package/WebGL/index.ts +2 -2
  24. package/package/animation/index.ts +2 -2
  25. package/package/formatColor/index.ts +2 -2
  26. package/package/getLoopColors/index.ts +2 -2
  27. package/package/getWebGLContext/index.ts +39 -39
  28. package/package/resizeObserver/index.ts +2 -2
  29. package/package/rotate/index.ts +2 -2
  30. package/package/ruler/index.ts +2 -2
  31. package/package/throttle/index.ts +2 -2
  32. package/package/viewHandler/index.ts +2 -2
  33. package/package.json +1 -1
  34. package/src/Canvas.ts +67 -67
  35. package/src/Matrix4/move.ts +12 -12
  36. package/src/Matrix4/rotate.ts +15 -15
  37. package/src/Matrix4/scale.ts +11 -11
  38. package/src/Matrix4/transform.ts +64 -64
  39. package/src/SVG.ts +24 -24
  40. package/src/WebGL.ts +66 -66
  41. package/src/animation.ts +98 -98
  42. package/src/common/assemble.ts +22 -22
  43. package/src/common/canvas/arc.ts +50 -50
  44. package/src/common/canvas/config.ts +158 -158
  45. package/src/common/canvas/gradient.ts +29 -29
  46. package/src/common/canvas/index.ts +168 -168
  47. package/src/common/canvas/painter.ts +426 -426
  48. package/src/common/canvas/texts.ts +18 -18
  49. package/src/common/mergeOption.ts +6 -6
  50. package/src/common/setStyle.ts +5 -5
  51. package/src/common/svg/config.ts +174 -174
  52. package/src/common/svg/tool.ts +44 -44
  53. package/src/common/tree/index.ts +25 -25
  54. package/src/common/tree/toInnerTree.ts +56 -56
  55. package/src/common/tree/toPlainTree.ts +131 -131
  56. package/src/common/webgl/buffer.ts +79 -79
  57. package/src/common/webgl/doDraw.ts +108 -108
  58. package/src/common/webgl/getColorFactory.ts +26 -26
  59. package/src/common/webgl/getShader.ts +48 -48
  60. package/src/common/webgl/getTexture.ts +11 -11
  61. package/src/common/webgl/getWebGLContext.ts +27 -27
  62. package/src/common/webgl/index.ts +223 -223
  63. package/src/common/webgl/shader.ts +75 -75
  64. package/src/common/webgl/texture.ts +96 -96
  65. package/src/formatColor.ts +44 -44
  66. package/src/getLoopColors.ts +42 -42
  67. package/src/interpolation/Cardinal.ts +110 -110
  68. package/src/interpolation/Hermite.ts +65 -65
  69. package/src/resizeObserver.ts +36 -36
  70. package/src/ruler.ts +188 -188
  71. package/src/shader/fsColor.c +7 -7
  72. package/src/shader/fsColors.c +7 -7
  73. package/src/shader/fsCube.c +8 -8
  74. package/src/shader/fsImage.c +8 -8
  75. package/src/shader/vsColor.c +17 -17
  76. package/src/shader/vsColors.c +13 -13
  77. package/src/shader/vsCube.c +13 -13
  78. package/src/shader/vsImage.c +13 -13
  79. package/src/throttle.ts +51 -51
  80. package/src/viewHandler.ts +158 -158
  81. package/types/Buffer.d.ts +23 -23
  82. package/types/Canvas.d.ts +300 -300
  83. package/types/CanvasOption.d.ts +7 -7
  84. package/types/Cardinal.d.ts +13 -13
  85. package/types/Gradient.d.ts +14 -14
  86. package/types/Hermite.d.ts +18 -18
  87. package/types/Object3D.d.ts +114 -114
  88. package/types/SVGConfig.d.ts +76 -76
  89. package/types/Scene3D.d.ts +6 -6
  90. package/types/Shader.d.ts +21 -21
  91. package/types/Texture.d.ts +16 -16
  92. package/types/Tree.d.ts +69 -69
  93. package/types/TreeConfig.d.ts +24 -24
  94. package/types/TreeOption.d.ts +48 -48
  95. package/types/WebGL.d.ts +38 -38
  96. package/types/WebGLOption.d.ts +7 -7
  97. package/types/animation.d.ts +6 -6
  98. package/types/formatColor.d.ts +2 -2
  99. package/types/getLoopColors.d.ts +2 -2
  100. package/types/getWebGLContext.d.ts +2 -2
  101. package/types/painterConfig.d.ts +2 -2
  102. package/types/resizeObserver.d.ts +2 -2
  103. package/types/ruler.d.ts +7 -7
  104. package/types/throttle.d.ts +4 -4
  105. package/types/throttleOption.d.ts +21 -21
  106. package/types/viewHandler.d.ts +13 -13
  107. package/uni-app/ui-canvas.vue +226 -222
  108. package/lib/Buffer/index.umd.js +0 -55
  109. package/lib/Buffer/index.umd.min.js +0 -11
  110. package/lib/Canvas/index.umd.js +0 -721
  111. package/lib/Canvas/index.umd.min.js +0 -11
  112. package/lib/Cardinal/index.umd.js +0 -112
  113. package/lib/Cardinal/index.umd.min.js +0 -11
  114. package/lib/Eoap/index.umd.js +0 -53
  115. package/lib/Eoap/index.umd.min.js +0 -11
  116. package/lib/Geometry/index.umd.js +0 -205
  117. package/lib/Geometry/index.umd.min.js +0 -11
  118. package/lib/Hermite/index.umd.js +0 -55
  119. package/lib/Hermite/index.umd.min.js +0 -11
  120. package/lib/Matrix4/index.umd.js +0 -146
  121. package/lib/Matrix4/index.umd.min.js +0 -11
  122. package/lib/Mercator/index.umd.js +0 -39
  123. package/lib/Mercator/index.umd.min.js +0 -11
  124. package/lib/OralCanvas/index.es.js +0 -657
  125. package/lib/OralCanvas/index.es.min.js +0 -11
  126. package/lib/OralWebGL/index.es.js +0 -611
  127. package/lib/OralWebGL/index.es.min.js +0 -11
  128. package/lib/SVG/index.umd.js +0 -475
  129. package/lib/SVG/index.umd.min.js +0 -11
  130. package/lib/Shader/index.umd.js +0 -134
  131. package/lib/Shader/index.umd.min.js +0 -11
  132. package/lib/Texture/index.umd.js +0 -72
  133. package/lib/Texture/index.umd.min.js +0 -11
  134. package/lib/TreeLayout/index.umd.js +0 -430
  135. package/lib/TreeLayout/index.umd.min.js +0 -11
  136. package/lib/WebGL/index.umd.js +0 -684
  137. package/lib/WebGL/index.umd.min.js +0 -11
  138. package/lib/animation/index.umd.js +0 -91
  139. package/lib/animation/index.umd.min.js +0 -11
  140. package/lib/formatColor/index.umd.js +0 -59
  141. package/lib/formatColor/index.umd.min.js +0 -11
  142. package/lib/getLoopColors/index.umd.js +0 -55
  143. package/lib/getLoopColors/index.umd.min.js +0 -11
  144. package/lib/getWebGLContext/index.umd.js +0 -65
  145. package/lib/getWebGLContext/index.umd.min.js +0 -11
  146. package/lib/index.umd.js +0 -2834
  147. package/lib/index.umd.min.js +0 -11
  148. package/lib/resizeObserver/index.umd.js +0 -48
  149. package/lib/resizeObserver/index.umd.min.js +0 -11
  150. package/lib/rotate/index.umd.js +0 -27
  151. package/lib/rotate/index.umd.min.js +0 -11
  152. package/lib/ruler/index.umd.js +0 -145
  153. package/lib/ruler/index.umd.min.js +0 -11
  154. package/lib/throttle/index.umd.js +0 -70
  155. package/lib/throttle/index.umd.min.js +0 -11
  156. package/lib/viewHandler/index.umd.js +0 -139
  157. package/lib/viewHandler/index.umd.min.js +0 -11
@@ -1,475 +0,0 @@
1
- /*!
2
- * VISLite JavaScript Library v0.5.0
3
- * git+https://github.com/oi-contrib/VISLite.git
4
- *
5
- * Copyright zxl20070701
6
- * Released under the MIT license
7
- * https://zxl20070701.github.io/notebook/home.html
8
- *
9
- * Publish Date: Sat Sep 30 2023 19:14:04 GMT+0800 (中国标准时间)
10
- */
11
- (function (global, factory) {
12
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
13
- typeof define === 'function' && define.amd ? define(factory) :
14
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.VISLite_SVG = factory());
15
- })(this, (function () { 'use strict';
16
-
17
- /******************************************************************************
18
- Copyright (c) Microsoft Corporation.
19
-
20
- Permission to use, copy, modify, and/or distribute this software for any
21
- purpose with or without fee is hereby granted.
22
-
23
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
24
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
25
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
26
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
27
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
28
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
29
- PERFORMANCE OF THIS SOFTWARE.
30
- ***************************************************************************** */
31
- /* global Reflect, Promise, SuppressedError, Symbol */
32
-
33
- var extendStatics = function(d, b) {
34
- extendStatics = Object.setPrototypeOf ||
35
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
37
- return extendStatics(d, b);
38
- };
39
-
40
- function __extends(d, b) {
41
- if (typeof b !== "function" && b !== null)
42
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
43
- extendStatics(d, b);
44
- function __() { this.constructor = d; }
45
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
46
- }
47
-
48
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
49
- var e = new Error(message);
50
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
51
- };
52
-
53
- var XLINK_ATTRIBUTE = ["href", "title", "show", "type", "role", "actuate"];
54
-
55
- function toNode(tagname) {
56
- return document.createElementNS('http://www.w3.org/2000/svg', tagname);
57
- }
58
- var _setAttribute = function (el, key, value) {
59
- if (XLINK_ATTRIBUTE.indexOf(key) > -1) {
60
- el.setAttributeNS("http://www.w3.org/1999/xlink", 'xlink:' + key, value + "");
61
- }
62
- else {
63
- el.setAttribute(key, value + "");
64
- }
65
- };
66
- var setAttribute = _setAttribute;
67
- function getAttribute(el, key) {
68
- if (XLINK_ATTRIBUTE.indexOf(key) > -1)
69
- key = 'xlink:' + key;
70
- return el.getAttribute(key);
71
- }
72
- function full(el, config) {
73
- _setAttribute(el, "stroke", config.strokeStyle);
74
- _setAttribute(el, "fill", config.fillStyle);
75
- _setAttribute(el, "stroke-dasharray", config.lineDash.join(','));
76
- }
77
- function fill(el, config) {
78
- _setAttribute(el, "fill", config.fillStyle);
79
- }
80
- function stroke(el, config) {
81
- _setAttribute(el, "stroke", config.strokeStyle);
82
- _setAttribute(el, "fill", "none");
83
- _setAttribute(el, "stroke-dasharray", config.lineDash.join(','));
84
- }
85
-
86
- function setStyle (el, styles) {
87
- for (var key in styles) {
88
- el.style[key] = styles[key];
89
- }
90
- }
91
-
92
- var rotate$1 = function (cx, cy, deg, x, y) {
93
- var cos = Math.cos(deg), sin = Math.sin(deg);
94
- return [
95
- +((x - cx) * cos - (y - cy) * sin + cx).toFixed(7),
96
- +((x - cx) * sin + (y - cy) * cos + cy).toFixed(7)
97
- ];
98
- };
99
- function arc (beginA, rotateA, cx, cy, r1, r2, doback) {
100
- if (rotateA < 0) {
101
- beginA += rotateA;
102
- rotateA *= -1;
103
- }
104
- var temp = [], p;
105
- p = rotate$1(0, 0, beginA, r1, 0);
106
- temp[0] = p[0];
107
- temp[1] = p[1];
108
- p = rotate$1(0, 0, rotateA, p[0], p[1]);
109
- temp[2] = p[0];
110
- temp[3] = p[1];
111
- p = rotate$1(0, 0, beginA, r2, 0);
112
- temp[4] = p[0];
113
- temp[5] = p[1];
114
- p = rotate$1(0, 0, rotateA, p[0], p[1]);
115
- temp[6] = p[0];
116
- temp[7] = p[1];
117
- doback(beginA, beginA + rotateA, temp[0] + cx, temp[1] + cy, temp[4] + cx, temp[5] + cy, temp[2] + cx, temp[3] + cy, temp[6] + cx, temp[7] + cy, (r2 - r1) * 0.5);
118
- }
119
-
120
- var initText = function (el, config, x, y, deg) {
121
- if (el.nodeName.toLowerCase() !== "text")
122
- throw new Error("Need a <text> !");
123
- setAttribute(el, "dy", {
124
- top: config["fontSize"] * 0.5,
125
- middle: 0,
126
- bottom: -config["fontSize"] * 0.5,
127
- }[config.textBaseline]);
128
- setStyle(el, {
129
- "text-anchor": {
130
- left: "start",
131
- right: "end",
132
- center: "middle",
133
- }[config.textAlign],
134
- "dominant-baseline": "central",
135
- "font-size": config["fontSize"] + "px",
136
- "font-family": config["fontFamily"],
137
- });
138
- setAttribute(el, "x", x);
139
- setAttribute(el, "y", y);
140
- if (typeof deg == "number") {
141
- deg = deg % 360;
142
- setAttribute(el, "transform", "rotate(" + deg + "," + x + "," + y + ")");
143
- }
144
- };
145
- var initCircle = function (el, cx, cy, r) {
146
- if (el.nodeName.toLowerCase() !== "circle")
147
- throw new Error("Need a <circle> !");
148
- setAttribute(el, "cx", cx);
149
- setAttribute(el, "cy", cy);
150
- setAttribute(el, "r", r);
151
- };
152
- var initPath = function (el, path) {
153
- if (el.nodeName.toLowerCase() !== "path")
154
- throw new Error("Need a <path> !");
155
- setAttribute(el, "d", path);
156
- };
157
- var initRect = function (el, x, y, width, height) {
158
- if (el.nodeName.toLowerCase() !== "rect")
159
- throw new Error("Need a <rect> !");
160
- if (height < 0) {
161
- height *= -1;
162
- y -= height;
163
- }
164
- if (width < 0) {
165
- width *= -1;
166
- x -= width;
167
- }
168
- setAttribute(el, "x", x);
169
- setAttribute(el, "y", y);
170
- setAttribute(el, "width", width);
171
- setAttribute(el, "height", height);
172
- };
173
- var initArc = function (el, config, cx, cy, r1, r2, beginDeg, deg) {
174
- if (el.nodeName.toLowerCase() !== "path")
175
- throw new Error("Need a <path> !");
176
- beginDeg = (beginDeg / 180) * Math.PI;
177
- deg = (deg / 180) * Math.PI;
178
- beginDeg = beginDeg % (Math.PI * 2);
179
- if (r1 > r2) {
180
- var temp = r1;
181
- r1 = r2;
182
- r2 = temp;
183
- }
184
- if (deg >= Math.PI * 1.999999 || deg <= -Math.PI * 1.999999) {
185
- deg = Math.PI * 1.999999;
186
- }
187
- else {
188
- deg = deg % (Math.PI * 2);
189
- }
190
- arc(beginDeg, deg, cx, cy, r1, r2, function (beginA, endA, begInnerX, begInnerY, begOuterX, begOuterY, endInnerX, endInnerY, endOuterX, endOuterY, r) {
191
- var f = endA - beginA > Math.PI ? 1 : 0, d = "M" + begInnerX + " " + begInnerY;
192
- if (r < 0)
193
- r = -r;
194
- d +=
195
- "A" + r1 + " " + r1 + " 0 " + f + " 1 " + endInnerX + " " + endInnerY;
196
- if (config.arcEndCap == "round")
197
- d += "A" + r + " " + r + " " + " 0 1 0 " + endOuterX + " " + endOuterY;
198
- else if (config.arcEndCap == "-round")
199
- d += "A" + r + " " + r + " " + " 0 1 1 " + endOuterX + " " + endOuterY;
200
- else
201
- d += "L" + endOuterX + " " + endOuterY;
202
- d +=
203
- "A" + r2 + " " + r2 + " 0 " + f + " 0 " + begOuterX + " " + begOuterY;
204
- if (config.arcStartCap == "round")
205
- d += "A" + r + " " + r + " " + " 0 1 0 " + begInnerX + " " + begInnerY;
206
- else if (config.arcStartCap == "-round")
207
- d += "A" + r + " " + r + " " + " 0 1 1 " + begInnerX + " " + begInnerY;
208
- else
209
- d += "L" + begInnerX + " " + begInnerY;
210
- if (config.arcStartCap == "butt")
211
- d += "Z";
212
- setAttribute(el, "d", d);
213
- });
214
- };
215
-
216
- function rotate (cx, cy, deg, x, y) {
217
- var cos = Math.cos(deg), sin = Math.sin(deg);
218
- return [
219
- (x - cx) * cos - (y - cy) * sin + cx,
220
- (x - cx) * sin + (y - cy) * cos + cy
221
- ];
222
- }
223
-
224
- var oldAttrName = {
225
- "font-size": "fontSize",
226
- "font-family": "fontFamily",
227
- "arc-start-cap": "arcStartCap",
228
- "arc-end-cap": "arcEndCap",
229
- };
230
- var SVG$1 = (function () {
231
- function SVG(svg) {
232
- this.name = "SVG";
233
- this.__config = {
234
- fillStyle: "#000",
235
- strokeStyle: "#000",
236
- lineWidth: 1,
237
- textAlign: "left",
238
- textBaseline: "middle",
239
- "fontSize": 16,
240
- "fontFamily": "sans-serif",
241
- "arcStartCap": "butt",
242
- "arcEndCap": "butt",
243
- lineDash: [],
244
- };
245
- this.__path = "";
246
- this.__currentPosition = [];
247
- this.__svg = svg;
248
- }
249
- SVG.prototype.config = function (params) {
250
- if (typeof params !== "object") {
251
- return this.__config[oldAttrName[params] || params];
252
- }
253
- else {
254
- for (var key in params) {
255
- var _key = oldAttrName[key] || key;
256
- this.__config[_key] = params[key];
257
- }
258
- }
259
- return this;
260
- };
261
- SVG.prototype.useEl = function (el) {
262
- this.__useEl = el;
263
- return this;
264
- };
265
- SVG.prototype.getEl = function () {
266
- return this.__useEl;
267
- };
268
- SVG.prototype.appendEl = function (el, context) {
269
- context = context || this.__svg;
270
- if (typeof el == "string")
271
- el = toNode(el);
272
- context.appendChild(el);
273
- this.__useEl = el;
274
- return this;
275
- };
276
- SVG.prototype.appendBoard = function (el, context) {
277
- var _el = el;
278
- if (typeof el == "string")
279
- _el =
280
- {
281
- text: "text",
282
- path: "path",
283
- arc: "path",
284
- circle: "circle",
285
- rect: "rect",
286
- }[el] || "";
287
- if (_el == "")
288
- throw new Error("Unsupported drawing method:" + el);
289
- return this.appendEl(_el, context);
290
- };
291
- SVG.prototype.remove = function () {
292
- if (!this.__useEl) {
293
- throw new Error("Currently, no node can be deleted.");
294
- }
295
- else {
296
- this.__useEl.parentNode.removeChild(this.__useEl);
297
- }
298
- return this;
299
- };
300
- SVG.prototype.attr = function (params) {
301
- if (!this.__useEl)
302
- throw new Error("Currently, no node can be modified or viewed.");
303
- if (typeof params !== "object") {
304
- return getAttribute(this.__useEl, params);
305
- }
306
- else {
307
- for (var key in params) {
308
- setAttribute(this.__useEl, key, params[key]);
309
- }
310
- return this;
311
- }
312
- };
313
- SVG.prototype.fillText = function (text, x, y, deg) {
314
- if (deg === void 0) { deg = 0; }
315
- initText(this.__useEl, this.__config, x, y, deg);
316
- this.__useEl.textContent = text;
317
- fill(this.__useEl, this.__config);
318
- return this;
319
- };
320
- SVG.prototype.strokeText = function (text, x, y, deg) {
321
- if (deg === void 0) { deg = 0; }
322
- initText(this.__useEl, this.__config, x, y, deg);
323
- this.__useEl.textContent = text;
324
- stroke(this.__useEl, this.__config);
325
- return this;
326
- };
327
- SVG.prototype.fullText = function (text, x, y, deg) {
328
- if (deg === void 0) { deg = 0; }
329
- initText(this.__useEl, this.__config, x, y, deg);
330
- this.__useEl.textContent = text;
331
- full(this.__useEl, this.__config);
332
- return this;
333
- };
334
- SVG.prototype.fillArc = function (cx, cy, r1, r2, beginDeg, deg) {
335
- initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
336
- fill(this.__useEl, this.__config);
337
- return this;
338
- };
339
- SVG.prototype.strokeArc = function (cx, cy, r1, r2, beginDeg, deg) {
340
- initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
341
- stroke(this.__useEl, this.__config);
342
- return this;
343
- };
344
- SVG.prototype.fullArc = function (cx, cy, r1, r2, beginDeg, deg) {
345
- initArc(this.__useEl, this.__config, cx, cy, r1, r2, beginDeg, deg);
346
- full(this.__useEl, this.__config);
347
- return this;
348
- };
349
- SVG.prototype.fillCircle = function (cx, cy, r) {
350
- initCircle(this.__useEl, cx, cy, r);
351
- fill(this.__useEl, this.__config);
352
- return this;
353
- };
354
- SVG.prototype.strokeCircle = function (cx, cy, r) {
355
- initCircle(this.__useEl, cx, cy, r);
356
- stroke(this.__useEl, this.__config);
357
- return this;
358
- };
359
- SVG.prototype.fullCircle = function (cx, cy, r) {
360
- initCircle(this.__useEl, cx, cy, r);
361
- full(this.__useEl, this.__config);
362
- return this;
363
- };
364
- SVG.prototype.fillRect = function (x, y, width, height) {
365
- initRect(this.__useEl, x, y, width, height);
366
- fill(this.__useEl, this.__config);
367
- return this;
368
- };
369
- SVG.prototype.strokeRect = function (x, y, width, height) {
370
- initRect(this.__useEl, x, y, width, height);
371
- stroke(this.__useEl, this.__config);
372
- return this;
373
- };
374
- SVG.prototype.fullRect = function (x, y, width, height) {
375
- initRect(this.__useEl, x, y, width, height);
376
- full(this.__useEl, this.__config);
377
- return this;
378
- };
379
- SVG.prototype.beginPath = function () {
380
- this.__currentPosition = [];
381
- this.__path = "";
382
- return this;
383
- };
384
- SVG.prototype.closePath = function () {
385
- this.__path += "Z";
386
- return this;
387
- };
388
- SVG.prototype.moveTo = function (x, y) {
389
- this.__currentPosition = [x, y];
390
- this.__path += "M" + x + " " + y;
391
- return this;
392
- };
393
- SVG.prototype.lineTo = function (x, y) {
394
- this.__currentPosition = [x, y];
395
- this.__path += (this.__path == "" ? "M" : "L") + x + " " + y;
396
- return this;
397
- };
398
- SVG.prototype.fill = function () {
399
- initPath(this.__useEl, this.__path);
400
- fill(this.__useEl, this.__config);
401
- return this;
402
- };
403
- SVG.prototype.stroke = function () {
404
- initPath(this.__useEl, this.__path);
405
- stroke(this.__useEl, this.__config);
406
- return this;
407
- };
408
- SVG.prototype.full = function () {
409
- initPath(this.__useEl, this.__path);
410
- full(this.__useEl, this.__config);
411
- return this;
412
- };
413
- SVG.prototype.arc = function (x, y, r, beginDeg, deg) {
414
- var begPosition = rotate(x, y, (beginDeg / 180) * Math.PI, x + r, y);
415
- var endPosition = rotate(x, y, ((beginDeg + deg) / 180) * Math.PI, x + r, y);
416
- if (this.__path == "") {
417
- this.__path += "M" + begPosition[0] + "," + begPosition[1];
418
- }
419
- else if (begPosition[0] != this.__currentPosition[0] ||
420
- begPosition[1] != this.__currentPosition[1]) {
421
- this.__path += "L" + begPosition[0] + "," + begPosition[1];
422
- }
423
- this.__path +=
424
- "A" +
425
- r +
426
- "," +
427
- r +
428
- " 0 " +
429
- (deg > 180 || deg < -180 ? 1 : 0) +
430
- "," +
431
- (deg > 0 ? 1 : 0) +
432
- " " +
433
- endPosition[0] +
434
- "," +
435
- endPosition[1];
436
- return this;
437
- };
438
- SVG.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
439
- this.__path += "Q" + cpx + " " + cpy + "," + x + " " + y;
440
- return this;
441
- };
442
- SVG.prototype.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
443
- this.__path +=
444
- "C" + cp1x + " " + cp1y + "," + cp2x + " " + cp2y + "," + x + " " + y;
445
- return this;
446
- };
447
- SVG.prototype.bind = function (eventType, callback) {
448
- this.__useEl.addEventListener(eventType, function (event) {
449
- callback.call(this, event, this);
450
- }, false);
451
- return this;
452
- };
453
- return SVG;
454
- }());
455
-
456
- var SVG = (function (_super) {
457
- __extends(SVG, _super);
458
- function SVG(el) {
459
- if (!el) {
460
- throw new Error("VISLite SVG:The mount point requires an HTMLElement type but encountered null.");
461
- }
462
- var width = el.clientWidth, height = el.clientHeight;
463
- var ViewSVG = document.createElementNS("http://www.w3.org/2000/svg", 'svg');
464
- el.appendChild(ViewSVG);
465
- ViewSVG.setAttribute("width", width + "");
466
- ViewSVG.setAttribute("height", height + "");
467
- ViewSVG.setAttribute("viewBox", "0 0 " + width + " " + height);
468
- return _super.call(this, ViewSVG) || this;
469
- }
470
- return SVG;
471
- }(SVG$1));
472
-
473
- return SVG;
474
-
475
- }));
@@ -1,11 +0,0 @@
1
- /*!
2
- * VISLite JavaScript Library v0.5.0
3
- * git+https://github.com/oi-contrib/VISLite.git
4
- *
5
- * Copyright zxl20070701
6
- * Released under the MIT license
7
- * https://zxl20070701.github.io/notebook/home.html
8
- *
9
- * Publish Date: Sat Sep 30 2023 19:14:04 GMT+0800 (中国标准时间)
10
- */
11
- 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)};"function"==typeof SuppressedError&&SuppressedError;var 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 r(t,e){i(t,"stroke",e.strokeStyle),i(t,"fill",e.fillStyle),i(t,"stroke-dasharray",e.lineDash.join(","))}function o(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,r){var o=Math.cos(i),s=Math.sin(i);return[+((n-t)*o-(r-e)*s+t).toFixed(7),+((n-t)*s+(r-e)*o+e).toFixed(7)]},u=function(t,e,i,r,o){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",r),"number"==typeof o&&n(t,"transform","rotate("+(o%=360)+","+i+","+r+")")},_=function(t,e,i,r){if("circle"!==t.nodeName.toLowerCase())throw new Error("Need a <circle> !");n(t,"cx",e),n(t,"cy",i),n(t,"r",r)},c=function(t,e){if("path"!==t.nodeName.toLowerCase())throw new Error("Need a <path> !");n(t,"d",e)},a=function(t,e,i,r,o){if("rect"!==t.nodeName.toLowerCase())throw new Error("Need a <rect> !");o<0&&(i-=o*=-1),r<0&&(e-=r*=-1),n(t,"x",e),n(t,"y",i),n(t,"width",r),n(t,"height",o)},f=function(t,e,i,r,o,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,o>s){var c=o;o=s,s=c}_>=1.999999*Math.PI||_<=1.999999*-Math.PI?_=1.999999*Math.PI:_%=2*Math.PI,function(t,e,i,n,r,o,s){e<0&&(t+=e,e*=-1);var u,_=[];u=h(0,0,t,r,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,o,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*(o-r))}(u,_,i,r,o,s,(function(i,r,h,u,_,c,a,f,l,p,d){var y=r-i>Math.PI?1:0,E="M"+h+" "+u;d<0&&(d=-d),E+="A"+o+" "+o+" 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,r){var o=Math.cos(i),s=Math.sin(i);return[(n-t)*o-(r-e)*s+t,(n-t)*s+(r-e)*o+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",fontSize:16,fontFamily:"sans-serif",arcStartCap:"butt",arcEndCap:"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,o(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,r(this.__useEl,this.__config),this},t.prototype.fillArc=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.strokeArc=function(t,e,i,n,r,o){return f(this.__useEl,this.__config,t,e,i,n,r,o),s(this.__useEl,this.__config),this},t.prototype.fullArc=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.fillCircle=function(t,e,i){return _(this.__useEl,t,e,i),o(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),r(this.__useEl,this.__config),this},t.prototype.fillRect=function(t,e,i,n){return a(this.__useEl,t,e,i,n),o(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),r(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),o(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),r(this.__useEl,this.__config),this},t.prototype.arc=function(t,e,i,n,r){var o=l(t,e,n/180*Math.PI,t+i,e),s=l(t,e,(n+r)/180*Math.PI,t+i,e);return""==this.__path?this.__path+="M"+o[0]+","+o[1]:o[0]==this.__currentPosition[0]&&o[1]==this.__currentPosition[1]||(this.__path+="L"+o[0]+","+o[1]),this.__path+="A"+i+","+i+" 0 "+(r>180||r<-180?1:0)+","+(r>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,r,o){return this.__path+="C"+t+" "+e+","+i+" "+n+","+r+" "+o,this},t.prototype.bind=function(t,e){return this.__useEl.addEventListener(t,(function(t){e.call(this,t,this)}),!1),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,r=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.appendChild(r),r.setAttribute("width",i+""),r.setAttribute("height",n+""),r.setAttribute("viewBox","0 0 "+i+" "+n),e.call(this,r)||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();
@@ -1,134 +0,0 @@
1
- /*!
2
- * VISLite JavaScript Library v0.5.0
3
- * git+https://github.com/oi-contrib/VISLite.git
4
- *
5
- * Copyright zxl20070701
6
- * Released under the MIT license
7
- * https://zxl20070701.github.io/notebook/home.html
8
- *
9
- * Publish Date: Sat Sep 30 2023 19:14:04 GMT+0800 (中国标准时间)
10
- */
11
- (function (global, factory) {
12
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
13
- typeof define === 'function' && define.amd ? define(factory) :
14
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.VISLite_Shader = factory());
15
- })(this, (function () { 'use strict';
16
-
17
- /******************************************************************************
18
- Copyright (c) Microsoft Corporation.
19
-
20
- Permission to use, copy, modify, and/or distribute this software for any
21
- purpose with or without fee is hereby granted.
22
-
23
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
24
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
25
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
26
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
27
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
28
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
29
- PERFORMANCE OF THIS SOFTWARE.
30
- ***************************************************************************** */
31
- /* global Reflect, Promise, SuppressedError, Symbol */
32
-
33
- var extendStatics = function(d, b) {
34
- extendStatics = Object.setPrototypeOf ||
35
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
36
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
37
- return extendStatics(d, b);
38
- };
39
-
40
- function __extends(d, b) {
41
- if (typeof b !== "function" && b !== null)
42
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
43
- extendStatics(d, b);
44
- function __() { this.constructor = d; }
45
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
46
- }
47
-
48
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
49
- var e = new Error(message);
50
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
51
- };
52
-
53
- var loadShader = function (painter, type, source) {
54
- var shader = painter.createShader(type);
55
- if (shader == null)
56
- throw new Error('Unable to create shader!');
57
- painter.shaderSource(shader, source);
58
- painter.compileShader(shader);
59
- if (!painter.getShaderParameter(shader, painter.COMPILE_STATUS))
60
- throw new Error('Failed to compile shader:' + painter.getShaderInfoLog(shader));
61
- return shader;
62
- };
63
- var useShader = function (painter, vshaderSource, fshaderSource) {
64
- var vertexShader = loadShader(painter, painter.VERTEX_SHADER, vshaderSource);
65
- var fragmentShader = loadShader(painter, painter.FRAGMENT_SHADER, fshaderSource);
66
- var glProgram = painter.createProgram();
67
- painter.attachShader(glProgram, vertexShader);
68
- painter.attachShader(glProgram, fragmentShader);
69
- painter.linkProgram(glProgram);
70
- if (!painter.getProgramParameter(glProgram, painter.LINK_STATUS))
71
- throw new Error('Failed to link program: ' + painter.getProgramInfoLog(glProgram));
72
- return glProgram;
73
- };
74
- var ShaderObject = (function () {
75
- function ShaderObject(painter) {
76
- this.__painter = painter;
77
- }
78
- ShaderObject.prototype.use = function () {
79
- this.__painter.useProgram(this.program);
80
- return this;
81
- };
82
- ShaderObject.prototype.compile = function (vshaderSource, fshaderSource) {
83
- this.program = useShader(this.__painter, vshaderSource, fshaderSource);
84
- return this;
85
- };
86
- return ShaderObject;
87
- }());
88
-
89
- var vsColor = "attribute vec4 a_position;\nuniform mat4 u_matrix;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n\n // 把原生的WebGL使用的左手坐标系变成了右手坐标系\n temp.z = -1.0 * temp.z;\n\n // 表示眼睛距离vec4(0.0,0.0,1.0)的距离\n float dist = 4.0;\n\n // 使用投影直接计算\n // 为保证纹理和相对位置正确\n // x、y、z的改变满足线性变换\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n}";
90
-
91
- var vsColors = "attribute vec4 a_position;\nuniform mat4 u_matrix;\nattribute vec4 a_color;\nvarying vec4 v_color;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n temp.z = -1.0 * temp.z;\n float dist = 4.0;\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n\n v_color = a_color;\n}";
92
-
93
- var vsImage = "attribute vec4 a_position;\nuniform mat4 u_matrix;\nattribute vec2 a_textcoord;\nvarying vec2 v_textcoord;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n temp.z = -1.0 * temp.z;\n float dist = 4.0;\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n\n v_textcoord = a_textcoord;\n}";
94
-
95
- var vsCube = "attribute vec4 a_position;\nuniform mat4 u_matrix;\nattribute vec4 a_normal;\nvarying vec3 v_normal;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n temp.z = -1.0 * temp.z;\n float dist = 4.0;\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n\n v_normal = normalize(vec3(a_normal));\n}";
96
-
97
- var fsColor = "precision mediump float;\n\nuniform vec4 u_color;\n\nvoid main()\n{\n gl_FragColor = u_color;\n}";
98
-
99
- var fsColors = "precision mediump float;\n\nvarying vec4 v_color;\n\nvoid main()\n{\n gl_FragColor = v_color;\n}";
100
-
101
- var fsImage = "precision mediump float;\n\nuniform sampler2D u_sampler;\nvarying vec2 v_textcoord;\n\nvoid main()\n{\n gl_FragColor = texture2D(u_sampler, v_textcoord);\n}";
102
-
103
- var fsCube = "precision mediump float;\n\nvarying vec3 v_normal;\nuniform samplerCube u_texture;\n\nvoid main()\n{\n gl_FragColor = textureCube(u_texture, normalize(v_normal));\n}";
104
-
105
- var Shader = (function (_super) {
106
- __extends(Shader, _super);
107
- function Shader() {
108
- return _super !== null && _super.apply(this, arguments) || this;
109
- }
110
- Shader.prototype.compile = function (arg1, arg2) {
111
- if (arg2) {
112
- _super.prototype.compile.call(this, arg1, arg2);
113
- }
114
- else {
115
- _super.prototype.compile.call(this, {
116
- "color": vsColor,
117
- "colors": vsColors,
118
- "image": vsImage,
119
- "cube": vsCube
120
- }[arg1], {
121
- "color": fsColor,
122
- "colors": fsColors,
123
- "image": fsImage,
124
- "cube": fsCube
125
- }[arg1]);
126
- }
127
- return this;
128
- };
129
- return Shader;
130
- }(ShaderObject));
131
-
132
- return Shader;
133
-
134
- }));
@@ -1,11 +0,0 @@
1
- /*!
2
- * VISLite JavaScript Library v0.5.0
3
- * git+https://github.com/oi-contrib/VISLite.git
4
- *
5
- * Copyright zxl20070701
6
- * Released under the MIT license
7
- * https://zxl20070701.github.io/notebook/home.html
8
- *
9
- * Publish Date: Sat Sep 30 2023 19:14:04 GMT+0800 (中国标准时间)
10
- */
11
- var t,n;t=this,n=function(){"use strict";var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};"function"==typeof SuppressedError&&SuppressedError;var n=function(t,n,e){var o=t.createShader(n);if(null==o)throw new Error("Unable to create shader!");if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new Error("Failed to compile shader:"+t.getShaderInfoLog(o));return o},e=function(){function t(t){this.__painter=t}return t.prototype.use=function(){return this.__painter.useProgram(this.program),this},t.prototype.compile=function(t,e){return this.program=function(t,e,o){var r=n(t,t.VERTEX_SHADER,e),i=n(t,t.FRAGMENT_SHADER,o),a=t.createProgram();if(t.attachShader(a,r),t.attachShader(a,i),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new Error("Failed to link program: "+t.getProgramInfoLog(a));return a}(this.__painter,t,e),this},t}(),o=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}(e,n),e.prototype.compile=function(t,e){return e?n.prototype.compile.call(this,t,e):n.prototype.compile.call(this,{color:"attribute vec4 a_position;\nuniform mat4 u_matrix;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n\n // 把原生的WebGL使用的左手坐标系变成了右手坐标系\n temp.z = -1.0 * temp.z;\n\n // 表示眼睛距离vec4(0.0,0.0,1.0)的距离\n float dist = 4.0;\n\n // 使用投影直接计算\n // 为保证纹理和相对位置正确\n // x、y、z的改变满足线性变换\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n}",colors:"attribute vec4 a_position;\nuniform mat4 u_matrix;\nattribute vec4 a_color;\nvarying vec4 v_color;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n temp.z = -1.0 * temp.z;\n float dist = 4.0;\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n\n v_color = a_color;\n}",image:"attribute vec4 a_position;\nuniform mat4 u_matrix;\nattribute vec2 a_textcoord;\nvarying vec2 v_textcoord;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n temp.z = -1.0 * temp.z;\n float dist = 4.0;\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n\n v_textcoord = a_textcoord;\n}",cube:"attribute vec4 a_position;\nuniform mat4 u_matrix;\nattribute vec4 a_normal;\nvarying vec3 v_normal;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n temp.z = -1.0 * temp.z;\n float dist = 4.0;\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n\n v_normal = normalize(vec3(a_normal));\n}"}[t],{color:"precision mediump float;\n\nuniform vec4 u_color;\n\nvoid main()\n{\n gl_FragColor = u_color;\n}",colors:"precision mediump float;\n\nvarying vec4 v_color;\n\nvoid main()\n{\n gl_FragColor = v_color;\n}",image:"precision mediump float;\n\nuniform sampler2D u_sampler;\nvarying vec2 v_textcoord;\n\nvoid main()\n{\n gl_FragColor = texture2D(u_sampler, v_textcoord);\n}",cube:"precision mediump float;\n\nvarying vec3 v_normal;\nuniform samplerCube u_texture;\n\nvoid main()\n{\n gl_FragColor = textureCube(u_texture, normalize(v_normal));\n}"}[t]),this},e}(e);return o},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).VISLite_Shader=n();