vislite 0.7.1-alpha.0 → 0.7.1

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 (64) hide show
  1. package/CHANGELOG +181 -177
  2. package/lib/Buffer/index.umd.js +2 -2
  3. package/lib/Buffer/index.umd.min.js +2 -2
  4. package/lib/Canvas/index.umd.js +19 -13
  5. package/lib/Canvas/index.umd.min.js +3 -3
  6. package/lib/Cardinal/index.umd.js +2 -2
  7. package/lib/Cardinal/index.umd.min.js +2 -2
  8. package/lib/Eoap/index.umd.js +2 -2
  9. package/lib/Eoap/index.umd.min.js +2 -2
  10. package/lib/Geometry/index.umd.js +2 -2
  11. package/lib/Geometry/index.umd.min.js +2 -2
  12. package/lib/Hermite/index.umd.js +2 -2
  13. package/lib/Hermite/index.umd.min.js +2 -2
  14. package/lib/Matrix4/index.umd.js +2 -2
  15. package/lib/Matrix4/index.umd.min.js +2 -2
  16. package/lib/Mercator/index.umd.js +2 -2
  17. package/lib/Mercator/index.umd.min.js +2 -2
  18. package/lib/OralCanvas/index.es.js +11 -7
  19. package/lib/OralCanvas/index.es.min.js +3 -3
  20. package/lib/OralWebGL/index.es.js +2 -2
  21. package/lib/OralWebGL/index.es.min.js +2 -2
  22. package/lib/SVG/index.umd.js +2 -2
  23. package/lib/SVG/index.umd.min.js +2 -2
  24. package/lib/Shader/index.umd.js +2 -2
  25. package/lib/Shader/index.umd.min.js +2 -2
  26. package/lib/Texture/index.umd.js +2 -2
  27. package/lib/Texture/index.umd.min.js +2 -2
  28. package/lib/TreeLayout/index.umd.js +2 -2
  29. package/lib/TreeLayout/index.umd.min.js +2 -2
  30. package/lib/WebGL/index.umd.js +2 -2
  31. package/lib/WebGL/index.umd.min.js +2 -2
  32. package/lib/animation/index.umd.js +2 -2
  33. package/lib/animation/index.umd.min.js +2 -2
  34. package/lib/formatColor/index.umd.js +2 -2
  35. package/lib/formatColor/index.umd.min.js +2 -2
  36. package/lib/getLoopColors/index.umd.js +2 -2
  37. package/lib/getLoopColors/index.umd.min.js +2 -2
  38. package/lib/getWebGLContext/index.umd.js +2 -2
  39. package/lib/getWebGLContext/index.umd.min.js +2 -2
  40. package/lib/index.umd.js +19 -13
  41. package/lib/index.umd.min.js +3 -3
  42. package/lib/move/index.umd.js +2 -2
  43. package/lib/move/index.umd.min.js +2 -2
  44. package/lib/resizeObserver/index.umd.js +2 -2
  45. package/lib/resizeObserver/index.umd.min.js +2 -2
  46. package/lib/rotate/index.umd.js +2 -2
  47. package/lib/rotate/index.umd.min.js +2 -2
  48. package/lib/ruler/index.umd.js +2 -2
  49. package/lib/ruler/index.umd.min.js +2 -2
  50. package/lib/scale/index.umd.js +2 -2
  51. package/lib/scale/index.umd.min.js +2 -2
  52. package/lib/throttle/index.umd.js +2 -2
  53. package/lib/throttle/index.umd.min.js +2 -2
  54. package/lib/viewHandler/index.umd.js +2 -2
  55. package/lib/viewHandler/index.umd.min.js +2 -2
  56. package/package.json +70 -70
  57. package/src/Canvas.ts +72 -70
  58. package/src/Geometry.ts +125 -126
  59. package/src/common/canvas/index.ts +183 -177
  60. package/src/common/canvas/painter.ts +419 -419
  61. package/src/common/webgl/shader.ts +75 -75
  62. package/types/Object3D.d.ts +114 -114
  63. package/types/Shader.d.ts +23 -23
  64. package/uni-app/ui-canvas.vue +281 -237
@@ -1,237 +1,281 @@
1
- <template>
2
- <view :class="cover || isH5 ? 'cover-view' : 'normal-view'" :style="{ display: 'inline-block' }">
3
- <view v-if="!cover && !isH5" :class="'view-img view-' + uniqueid" @touchstart="doitstart">
4
- <image
5
- :style="{ width: width + 'px', height: height + 'px' }"
6
- :src="viewImg"
7
- ></image>
8
- </view>
9
-
10
- <!-- #ifdef MP-ALIPAY -->
11
- <canvas
12
- class="painter"
13
- :id="'painter-' + uniqueid"
14
- @touchstart="doitstart"
15
- :style="[{ width: width + 'px', height: height + 'px'}, cover || isH5 ? {} : {position: 'fixed', left: '50000px'}]"
16
- ></canvas>
17
- <canvas
18
- v-if="region"
19
- class="region"
20
- :id="'region-' + uniqueid"
21
- :style="{ width: width + 'px', height: height + 'px', position: 'fixed', left: '50000px' }"
22
- ></canvas>
23
- <!-- #endif -->
24
- <!-- #ifdef MP-WEIXIN -->
25
- <canvas
26
- class="painter"
27
- canvas-id="painter"
28
- @touchstart="doitstart"
29
- :style="[{ width: width + 'px', height: height + 'px'}, cover || isH5 ? {} : {position: 'fixed', left: '50000px'}]"
30
- ></canvas>
31
- <canvas
32
- v-if="region"
33
- class="region"
34
- canvas-id="region"
35
- :style="{ width: width + 'px', height: height + 'px', position: 'fixed', left: '50000px' }"
36
- ></canvas>
37
- <!-- #endif -->
38
- <!-- #ifndef MP-WEIXIN||MP-ALIPAY -->
39
- <canvas
40
- class="painter"
41
- :canvas-id="'painter-' + uniqueid"
42
- @touchstart="doitstart"
43
- :style="[{ width: width + 'px', height: height + 'px'}, cover || isH5 ? {} : {position: 'fixed', left: '50000px'}]"
44
- ></canvas>
45
- <canvas
46
- v-if="region"
47
- class="region"
48
- :canvas-id="'region-' + uniqueid"
49
- :style="{ width: width + 'px', height: height + 'px', position: 'fixed', left: '50000px' }"
50
- ></canvas>
51
- <!-- #endif -->
52
- </view>
53
- </template>
54
- <script>
55
- import OralCanvas from "../lib/OralCanvas/index.es.js";
56
- export default {
57
- data() {
58
- return {
59
- uniqueid: (Math.random() * 10000).toFixed(0),
60
- help: {},
61
- viewImg: "",
62
- // #ifdef H5
63
- isH5: true,
64
- // #endif
65
- // #ifndef H5
66
- isH5: false,
67
- // #endif
68
- };
69
- },
70
- props: {
71
- width: {
72
- type: Number,
73
- default: 300,
74
- },
75
- height: {
76
- type: Number,
77
- default: 150,
78
- },
79
- touchstart: {
80
- type: Function,
81
- default: () => {},
82
- },
83
- cover: {
84
- type: Boolean,
85
- default: true,
86
- },
87
- region: {
88
- type: Boolean,
89
- default: true,
90
- },
91
- },
92
- methods: {
93
- fetch() {
94
- let painter, region, painterid, regionid;
95
- // #ifdef MP-WEIXIN
96
- painter = uni.createCanvasContext("painter", this);
97
- if (this.region) region = uni.createCanvasContext("region", this);
98
- painterid = "painter";
99
- regionid = "region";
100
- // #endif
101
- // #ifndef MP-WEIXIN
102
- painter = uni.createCanvasContext("painter-" + this.uniqueid, this);
103
- if (this.region)
104
- region = uni.createCanvasContext("region-" + this.uniqueid, this);
105
- painterid = "painter-" + this.uniqueid;
106
- regionid = "region-" + this.uniqueid;
107
- // #endif
108
-
109
- let _this = this;
110
- this.help.instance = new OralCanvas(
111
- {
112
- getContext() {
113
- return painter;
114
- },
115
- },
116
- _this.region
117
- ? {
118
- getContext() {
119
- // #ifdef MP-ALIPAY
120
- let getImageData = region.getImageData;
121
- // #endif
122
- region.getImageData = (x, y, width, height) => {
123
- return new Promise((resolve, reject) => {
124
- let options = {
125
- x,
126
- y,
127
- width,
128
- height,
129
- canvasId: regionid,
130
- success: function success(res) {
131
- resolve(res.data);
132
- },
133
- fail: function fail(error) {
134
- reject(error);
135
- },
136
- };
137
-
138
- // #ifdef MP-ALIPAY
139
- getImageData(options);
140
- // #endif
141
- // #ifndef MP-ALIPAY
142
- uni.canvasGetImageData(options, _this);
143
- // #endif
144
- });
145
- };
146
- return region;
147
- },
148
- }
149
- : null
150
- );
151
- this.help.instance.draw = (reserve = false, callback = () => {}) => {
152
- painter.draw(reserve, () => {
153
- // 如果不使用原生渲染
154
- if (!this.cover && !this.isH5) {
155
- uni.canvasToTempFilePath(
156
- {
157
- canvasId: painterid,
158
- success: (e) => {
159
- this.viewImg = e.tempFilePath;
160
- if (_this.region) region.draw(reserve);
161
- callback();
162
- },
163
- },
164
- // #ifndef MP-ALIPAY
165
- this
166
- // #endif
167
- );
168
- } else {
169
- if (_this.region) region.draw(reserve);
170
- callback();
171
- }
172
- });
173
- };
174
- return new Promise((resolve, reject) => {
175
- this.help.instance.toDataURL = () => {
176
- return new Promise((resolveUrl) => {
177
- uni.canvasToTempFilePath(
178
- {
179
- canvasId: painterid,
180
- success: function (e) {
181
- resolveUrl(e.tempFilePath);
182
- },
183
- },
184
- // #ifndef MP-ALIPAY
185
- this
186
- // #endif
187
- );
188
- });
189
- };
190
-
191
- resolve(this.help.instance);
192
- });
193
- },
194
- doit(event, doback) {
195
- let doRun = (x, y) => {
196
- this.help.instance.getRegion(x, y).then((regionName) => {
197
- // 兼容旧语法
198
- if (typeof doback == "function") doback(regionName);
199
-
200
- this.$emit("dotouchstart", {
201
- name: regionName,
202
- x: x,
203
- y: y,
204
- });
205
- });
206
- };
207
-
208
- if (this.cover || this.isH5) {
209
- let x = event.touches[0].x;
210
- let y = event.touches[0].y;
211
- doRun(x, y);
212
- } else {
213
- uni
214
- .createSelectorQuery()
215
- .selectViewport()
216
- .scrollOffset()
217
- .exec((ret) => {
218
- uni
219
- .createSelectorQuery()
220
- .in(this)
221
- .select(".view-" + this.uniqueid)
222
- .boundingClientRect((data) => {
223
- doRun(
224
- event.touches[0].pageX - data.left - ret[0].scrollLeft,
225
- event.touches[0].pageY - data.top - ret[0].scrollTop
226
- );
227
- })
228
- .exec();
229
- });
230
- }
231
- },
232
- doitstart(event) {
233
- this.doit(event, this.touchstart);
234
- },
235
- },
236
- };
237
- </script>
1
+ <template>
2
+ <view
3
+ :class="cover || isH5 ? 'cover-view' : 'normal-view'"
4
+ :style="{ display: 'inline-block' }"
5
+ >
6
+ <view
7
+ v-if="!cover && !isH5"
8
+ :class="'view-img view-' + uniqueid"
9
+ @touchstart="doitstart"
10
+ >
11
+ <image
12
+ :style="{ width: width + 'px', height: height + 'px' }"
13
+ :src="viewImg"
14
+ ></image>
15
+ </view>
16
+
17
+ <!-- #ifdef MP-ALIPAY -->
18
+ <canvas
19
+ :width="2 * width + 'px'"
20
+ :height="2 * height + 'px'"
21
+ class="painter"
22
+ :id="'painter-' + uniqueid"
23
+ @touchstart="doitstart"
24
+ :style="[
25
+ { width: width + 'px', height: height + 'px' },
26
+ cover || isH5 ? {} : { position: 'fixed', left: '50000px' },
27
+ ]"
28
+ ></canvas>
29
+ <canvas
30
+ v-if="region"
31
+ class="region"
32
+ :id="'region-' + uniqueid"
33
+ :style="{
34
+ width: width + 'px',
35
+ height: height + 'px',
36
+ position: 'fixed',
37
+ left: '50000px',
38
+ }"
39
+ ></canvas>
40
+ <!-- #endif -->
41
+ <!-- #ifdef MP-WEIXIN -->
42
+ <canvas
43
+ class="painter"
44
+ canvas-id="painter"
45
+ @touchstart="doitstart"
46
+ :style="[
47
+ { width: width + 'px', height: height + 'px' },
48
+ cover || isH5 ? {} : { position: 'fixed', left: '50000px' },
49
+ ]"
50
+ ></canvas>
51
+ <canvas
52
+ v-if="region"
53
+ class="region"
54
+ canvas-id="region"
55
+ :style="{
56
+ width: width + 'px',
57
+ height: height + 'px',
58
+ position: 'fixed',
59
+ left: '50000px',
60
+ }"
61
+ ></canvas>
62
+ <!-- #endif -->
63
+ <!-- #ifndef MP-WEIXIN||MP-ALIPAY -->
64
+ <canvas
65
+ class="painter"
66
+ :canvas-id="'painter-' + uniqueid"
67
+ @touchstart="doitstart"
68
+ :style="[
69
+ { width: width + 'px', height: height + 'px' },
70
+ cover || isH5 ? {} : { position: 'fixed', left: '50000px' },
71
+ ]"
72
+ ></canvas>
73
+ <canvas
74
+ v-if="region"
75
+ class="region"
76
+ :canvas-id="'region-' + uniqueid"
77
+ :style="{
78
+ width: width + 'px',
79
+ height: height + 'px',
80
+ position: 'fixed',
81
+ left: '50000px',
82
+ }"
83
+ ></canvas>
84
+ <!-- #endif -->
85
+ </view>
86
+ </template>
87
+ <script>
88
+ import OralCanvas from "../lib/OralCanvas/index.es.js";
89
+ export default {
90
+ data() {
91
+ return {
92
+ uniqueid: (Math.random() * 10000).toFixed(0),
93
+ help: {},
94
+ viewImg: "",
95
+ // #ifdef H5
96
+ isH5: true,
97
+ // #endif
98
+ // #ifndef H5
99
+ isH5: false,
100
+ // #endif
101
+ };
102
+ },
103
+ props: {
104
+ width: {
105
+ type: Number,
106
+ default: 300,
107
+ },
108
+ height: {
109
+ type: Number,
110
+ default: 150,
111
+ },
112
+ touchstart: {
113
+ type: Function,
114
+ default: () => {},
115
+ },
116
+ cover: {
117
+ type: Boolean,
118
+ default: true,
119
+ },
120
+ region: {
121
+ type: Boolean,
122
+ default: true,
123
+ },
124
+ },
125
+ methods: {
126
+ fetch() {
127
+ let painter, region, painterid, regionid;
128
+ // #ifdef MP-WEIXIN
129
+ painter = uni.createCanvasContext("painter", this);
130
+ if (this.region) region = uni.createCanvasContext("region", this);
131
+ painterid = "painter";
132
+ regionid = "region";
133
+ // #endif
134
+ // #ifndef MP-WEIXIN
135
+ painter = uni.createCanvasContext("painter-" + this.uniqueid, this);
136
+ if (this.region)
137
+ region = uni.createCanvasContext("region-" + this.uniqueid, this);
138
+ painterid = "painter-" + this.uniqueid;
139
+ regionid = "region-" + this.uniqueid;
140
+ // #endif
141
+
142
+ // #ifdef MP-ALIPAY
143
+ painter.scale(2, 2);
144
+ // #endif
145
+
146
+ let scaleSize = 1;
147
+
148
+ // #ifdef MP-ALIPAY
149
+ scaleSize = 2;
150
+ // #endif
151
+
152
+ let _this = this;
153
+ this.help.instance = new OralCanvas(
154
+ {
155
+ getContext() {
156
+ return painter;
157
+ },
158
+ },
159
+ _this.region
160
+ ? {
161
+ getContext() {
162
+ // #ifdef MP-ALIPAY
163
+ let getImageData = region.getImageData;
164
+ // #endif
165
+ region.getImageData = (x, y, width, height) => {
166
+ return new Promise((resolve, reject) => {
167
+ let options = {
168
+ x,
169
+ y,
170
+ width,
171
+ height,
172
+ canvasId: regionid,
173
+ success: function success(res) {
174
+ resolve(res.data);
175
+ },
176
+ fail: function fail(error) {
177
+ reject(error);
178
+ },
179
+ };
180
+
181
+ // #ifdef MP-ALIPAY
182
+ getImageData(options);
183
+ // #endif
184
+ // #ifndef MP-ALIPAY
185
+ uni.canvasGetImageData(options, _this);
186
+ // #endif
187
+ });
188
+ };
189
+ return region;
190
+ },
191
+ }
192
+ : null,
193
+ scaleSize
194
+ );
195
+ this.help.instance.draw = (reserve = false, callback = () => {}) => {
196
+ painter.draw(reserve, () => {
197
+ // 如果不使用原生渲染
198
+ if (!this.cover && !this.isH5) {
199
+ uni.canvasToTempFilePath(
200
+ {
201
+ canvasId: painterid,
202
+ success: (e) => {
203
+ this.viewImg = e.tempFilePath;
204
+ if (_this.region) region.draw(reserve);
205
+ callback();
206
+ },
207
+ },
208
+ // #ifndef MP-ALIPAY
209
+ this
210
+ // #endif
211
+ );
212
+ } else {
213
+ if (_this.region) region.draw(reserve);
214
+ callback();
215
+ }
216
+ });
217
+ };
218
+ return new Promise((resolve, reject) => {
219
+ this.help.instance.toDataURL = () => {
220
+ return new Promise((resolveUrl) => {
221
+ uni.canvasToTempFilePath(
222
+ {
223
+ canvasId: painterid,
224
+ success: function (e) {
225
+ resolveUrl(e.tempFilePath);
226
+ },
227
+ },
228
+ // #ifndef MP-ALIPAY
229
+ this
230
+ // #endif
231
+ );
232
+ });
233
+ };
234
+
235
+ resolve(this.help.instance);
236
+ });
237
+ },
238
+ doit(event, doback) {
239
+ let doRun = (x, y) => {
240
+ this.help.instance.getRegion(x, y).then((regionName) => {
241
+ // 兼容旧语法
242
+ if (typeof doback == "function") doback(regionName);
243
+
244
+ this.$emit("dotouchstart", {
245
+ name: regionName,
246
+ x: x,
247
+ y: y,
248
+ });
249
+ });
250
+ };
251
+
252
+ if (this.cover || this.isH5) {
253
+ let x = event.touches[0].x;
254
+ let y = event.touches[0].y;
255
+ doRun(x, y);
256
+ } else {
257
+ uni
258
+ .createSelectorQuery()
259
+ .selectViewport()
260
+ .scrollOffset()
261
+ .exec((ret) => {
262
+ uni
263
+ .createSelectorQuery()
264
+ .in(this)
265
+ .select(".view-" + this.uniqueid)
266
+ .boundingClientRect((data) => {
267
+ doRun(
268
+ event.touches[0].pageX - data.left - ret[0].scrollLeft,
269
+ event.touches[0].pageY - data.top - ret[0].scrollTop
270
+ );
271
+ })
272
+ .exec();
273
+ });
274
+ }
275
+ },
276
+ doitstart(event) {
277
+ this.doit(event, this.touchstart);
278
+ },
279
+ },
280
+ };
281
+ </script>