vislite 0.4.1-alpha.0 → 0.4.1-alpha.2

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 (55) hide show
  1. package/CHANGELOG +21 -7
  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 +48 -35
  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/Hermite/index.umd.js +2 -2
  11. package/lib/Hermite/index.umd.min.js +2 -2
  12. package/lib/Matrix4/index.umd.js +2 -2
  13. package/lib/Matrix4/index.umd.min.js +2 -2
  14. package/lib/Mercator/index.umd.js +2 -2
  15. package/lib/Mercator/index.umd.min.js +2 -2
  16. package/lib/OralCanvas/index.es.js +35 -29
  17. package/lib/OralCanvas/index.es.min.js +3 -3
  18. package/lib/OralWebGL/index.es.js +22 -16
  19. package/lib/OralWebGL/index.es.min.js +3 -3
  20. package/lib/SVG/index.umd.js +2 -2
  21. package/lib/SVG/index.umd.min.js +2 -2
  22. package/lib/Shader/index.umd.js +2 -2
  23. package/lib/Shader/index.umd.min.js +2 -2
  24. package/lib/Texture/index.umd.js +2 -2
  25. package/lib/Texture/index.umd.min.js +2 -2
  26. package/lib/WebGL/index.umd.js +39 -26
  27. package/lib/WebGL/index.umd.min.js +3 -3
  28. package/lib/animation/index.umd.js +2 -2
  29. package/lib/animation/index.umd.min.js +2 -2
  30. package/lib/getLoopColors/index.umd.js +2 -2
  31. package/lib/getLoopColors/index.umd.min.js +2 -2
  32. package/lib/getWebGLContext/index.umd.js +2 -2
  33. package/lib/getWebGLContext/index.umd.min.js +2 -2
  34. package/lib/index.umd.js +178 -89
  35. package/lib/index.umd.min.js +3 -3
  36. package/lib/rotate/index.umd.js +2 -2
  37. package/lib/rotate/index.umd.min.js +2 -2
  38. package/lib/ruler/index.umd.js +95 -32
  39. package/lib/ruler/index.umd.min.js +3 -3
  40. package/lib/viewHandler/index.umd.js +2 -2
  41. package/lib/viewHandler/index.umd.min.js +2 -2
  42. package/miniprogram/ui-canvas/index.js +23 -15
  43. package/miniprogram/ui-canvas/index.wxml +1 -1
  44. package/package.json +1 -1
  45. package/src/Canvas.ts +13 -6
  46. package/src/WebGL.ts +19 -10
  47. package/src/common/canvas/index.ts +36 -29
  48. package/src/common/canvas/texts.ts +1 -1
  49. package/src/common/webgl/index.ts +24 -18
  50. package/src/ruler.ts +126 -37
  51. package/types/CanvasOption.d.ts +8 -0
  52. package/types/WebGLOption.d.ts +8 -0
  53. package/types/index.d.ts +5 -2
  54. package/types/ruler.d.ts +6 -1
  55. package/uni-app/ui-canvas.vue +25 -15
package/src/WebGL.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  import WebGLType from '../types/WebGL'
2
2
  import OralWebGL from './common/webgl/index'
3
+ import WebGLOptionType from '../types/WebGLOption'
3
4
 
4
5
  class WebGL extends OralWebGL implements WebGLType {
5
- constructor(el: HTMLElement | null) {
6
+ constructor(el: HTMLElement | null, option: WebGLOptionType = {}) {
6
7
  if (!el) {
7
8
  throw new Error("VISLite WebGL:The mount point requires an HTMLElement type but encountered null.")
8
9
  }
9
10
 
11
+ if (!('region' in option)) option.region = true
12
+
10
13
  let width = el.clientWidth, height = el.clientHeight
11
14
 
12
15
  let ViewCanvas: HTMLCanvasElement, RegionCanvas: HTMLCanvasElement
@@ -22,12 +25,16 @@ class WebGL extends OralWebGL implements WebGLType {
22
25
  // 否则就初始化
23
26
  else {
24
27
 
25
- RegionCanvas = document.createElement('canvas')
26
- el.appendChild(RegionCanvas)
28
+ if (option.region) {
29
+
30
+ RegionCanvas = document.createElement('canvas')
31
+ el.appendChild(RegionCanvas)
32
+
33
+ RegionCanvas.style.position = 'absolute'
34
+ RegionCanvas.style.zIndex = "-1"
35
+ RegionCanvas.style.opacity = "0"
27
36
 
28
- RegionCanvas.style.position = 'absolute'
29
- RegionCanvas.style.zIndex = "-1"
30
- RegionCanvas.style.opacity = "0"
37
+ }
31
38
 
32
39
  ViewCanvas = document.createElement('canvas')
33
40
  el.appendChild(ViewCanvas)
@@ -40,11 +47,13 @@ class WebGL extends OralWebGL implements WebGLType {
40
47
  // 设置画布大小
41
48
  for (let canvas of [ViewCanvas, RegionCanvas]) {
42
49
 
43
- canvas.style.width = width + "px"
44
- canvas.setAttribute('width', width + "")
50
+ if (canvas) {
51
+ canvas.style.width = width + "px"
52
+ canvas.setAttribute('width', width + "")
45
53
 
46
- canvas.style.height = height + "px"
47
- canvas.setAttribute('height', height + "")
54
+ canvas.style.height = height + "px"
55
+ canvas.setAttribute('height', height + "")
56
+ }
48
57
  }
49
58
 
50
59
  super(ViewCanvas, RegionCanvas)
@@ -27,9 +27,9 @@ class Canvas extends PainterRender {
27
27
  super(
28
28
  ViewCanvas,
29
29
  {},
30
- new PainterRender(RegionCanvas, {
30
+ RegionCanvas ? new PainterRender(RegionCanvas, {
31
31
  willReadFrequently: true,
32
- })
32
+ }) : null
33
33
  )
34
34
 
35
35
  this.setRegion("")
@@ -46,18 +46,20 @@ class Canvas extends PainterRender {
46
46
 
47
47
  // 设置当前绘制区域名称
48
48
  setRegion(regionName: string | number) {
49
- if (regionName) {
50
- if (this.__regionList[regionName] == undefined) {
51
- let tempColor = this.__regionAssemble()
52
- this.__regionList[regionName] =
53
- "rgb(" + tempColor[0] + "," + tempColor[1] + "," + tempColor[2] + ")"
54
- }
49
+ if (this.__region) {
50
+ if (regionName) {
51
+ if (this.__regionList[regionName] == undefined) {
52
+ let tempColor = this.__regionAssemble()
53
+ this.__regionList[regionName] =
54
+ "rgb(" + tempColor[0] + "," + tempColor[1] + "," + tempColor[2] + ")"
55
+ }
55
56
 
56
- this.__region.useConfig("fillStyle", this.__regionList[regionName]) &&
57
- this.__region.useConfig("strokeStyle", this.__regionList[regionName])
58
- } else {
59
- this.__region.useConfig("fillStyle", "#000000") &&
60
- this.__region.useConfig("strokeStyle", "#000000")
57
+ this.__region.useConfig("fillStyle", this.__regionList[regionName]) &&
58
+ this.__region.useConfig("strokeStyle", this.__regionList[regionName])
59
+ } else {
60
+ this.__region.useConfig("fillStyle", "#000000") &&
61
+ this.__region.useConfig("strokeStyle", "#000000")
62
+ }
61
63
  }
62
64
  return this
63
65
  }
@@ -65,26 +67,31 @@ class Canvas extends PainterRender {
65
67
  // 获取当前事件触发的区域名称
66
68
  getRegion(x: number, y: number): Promise<string> {
67
69
  return new Promise((resolve, reject) => {
68
- let imgData = this.__region.painter.getImageData(x - 0.5, y - 0.5, 1, 1)
70
+ let imgData = this.__region ? this.__region.painter.getImageData(x - 0.5, y - 0.5, 1, 1) : {
71
+ data: [0, 0, 0, 0]
72
+ }
69
73
 
70
74
  // 获取点击点的颜色
71
75
  let currentRGBA = imgData.data
72
76
 
73
77
  let doit = () => {
74
- // 查找当前点击的区域
75
- for (let key in this.__regionList) {
76
- if (
77
- "rgb(" +
78
- currentRGBA[0] +
79
- "," +
80
- currentRGBA[1] +
81
- "," +
82
- currentRGBA[2] +
83
- ")" ==
84
- this.__regionList[key]
85
- ) {
86
- resolve(key)
87
- break
78
+ if (this.__region) {
79
+
80
+ // 查找当前点击的区域
81
+ for (let key in this.__regionList) {
82
+ if (
83
+ "rgb(" +
84
+ currentRGBA[0] +
85
+ "," +
86
+ currentRGBA[1] +
87
+ "," +
88
+ currentRGBA[2] +
89
+ ")" ==
90
+ this.__regionList[key]
91
+ ) {
92
+ resolve(key)
93
+ break
94
+ }
88
95
  }
89
96
  }
90
97
 
@@ -121,7 +128,7 @@ class Canvas extends PainterRender {
121
128
 
122
129
  // 获取原始画笔
123
130
  getContext(isRegion = false) {
124
- return isRegion ? this.__region.painter : this.painter
131
+ return isRegion ? (this.__region ? this.__region.painter : null) : this.painter
125
132
  }
126
133
 
127
134
  // 线性渐变
@@ -2,7 +2,7 @@ export default function (painter: CanvasRenderingContext2D, contents: string, wi
2
2
 
3
3
  let lineNumber = 0, content = ""
4
4
  for (let i = 0; i < contents.length; i++) {
5
- if (painter.measureText(content + contents[i]).width > width) {
5
+ if (painter.measureText(content + contents[i]).width > width || /\n$/.test(content)) {
6
6
  lineNumber += 1
7
7
  doback(content, (lineNumber - 0.5) * height)
8
8
 
@@ -45,11 +45,13 @@ class WebGL {
45
45
  this.__unique = new Date().valueOf()
46
46
 
47
47
  this.painter = getWebGLContext(ViewCanvas, scale)
48
- this.__regionPainter = getWebGLContext(RegionCanvas, scale, {
48
+ if (RegionCanvas) {
49
+ this.__regionPainter = getWebGLContext(RegionCanvas, scale, {
49
50
 
50
- // 如果不设置,涉及到缓冲区的情况可能无法获取颜色
51
- // preserveDrawingBuffer: true
52
- })
51
+ // 如果不设置,涉及到缓冲区的情况可能无法获取颜色
52
+ // preserveDrawingBuffer: true
53
+ })
54
+ }
53
55
 
54
56
  let proportion = this.painter.canvas.width / this.painter.canvas.height
55
57
 
@@ -88,8 +90,10 @@ class WebGL {
88
90
  review(isUpdateRegion = false) {
89
91
 
90
92
  if (isUpdateRegion) {
91
- this.__regionPainter.clearColor(1, 1, 1, 1)
92
- this.__regionPainter.clear(this.__regionPainter.COLOR_BUFFER_BIT)
93
+ if (this.__regionPainter) {
94
+ this.__regionPainter.clearColor(1, 1, 1, 1)
95
+ this.__regionPainter.clear(this.__regionPainter.COLOR_BUFFER_BIT)
96
+ }
93
97
  } else {
94
98
  this.painter.clearColor(1, 1, 1, 1)
95
99
  this.painter.clear(this.painter.COLOR_BUFFER_BIT)
@@ -119,20 +123,22 @@ class WebGL {
119
123
  for (let index = 0; index < object3D.mesh.length; index++) {
120
124
 
121
125
  if (isUpdateRegion) {
122
- // 区域上
123
- doDraw("painter" + this.__unique, this.__regionPainter, {
124
- geometry: object3D.mesh[index].geometry,
125
- material: {
126
- color: {
127
- r: this.__regionColor[0],
128
- g: this.__regionColor[1],
129
- b: this.__regionColor[2],
130
- alpha: this.__regionColor[3]
126
+ if (this.__regionPainter) {
127
+ // 区域上
128
+ doDraw("painter" + this.__unique, this.__regionPainter, {
129
+ geometry: object3D.mesh[index].geometry,
130
+ material: {
131
+ color: {
132
+ r: this.__regionColor[0],
133
+ g: this.__regionColor[1],
134
+ b: this.__regionColor[2],
135
+ alpha: this.__regionColor[3]
136
+ }
131
137
  }
132
- }
133
- }, meshWorld, globalWorld)
138
+ }, meshWorld, globalWorld)
134
139
 
135
- this.__getColor = getColorFactory(this.__regionPainter)
140
+ this.__getColor = getColorFactory(this.__regionPainter)
141
+ }
136
142
  } else {
137
143
  // 画布上
138
144
  doDraw("region" + this.__unique, this.painter, object3D.mesh[index], meshWorld, globalWorld)
package/src/ruler.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  // 刻度尺刻度求解
2
2
 
3
+ import { rulerOptionType } from '../types/ruler'
4
+
3
5
  // 需要注意的是,实际的间距个数可能是 num-1 或 num 或 num+1 或 1
4
- export default function (maxValue: number, minValue: number, num: number) {
6
+ export default function (maxValue: number, minValue: number, num: number, option?: rulerOptionType) {
5
7
 
6
8
  // 如果最大值最小值反了
7
9
  if (maxValue < minValue) {
@@ -57,43 +59,130 @@ export default function (maxValue: number, minValue: number, num: number) {
57
59
 
58
60
 
59
61
  // 求解出 -100 ~ 100 的最佳间距值 后直接转换原来的倍数
60
- let distance100 = Math.ceil((maxValue - minValue) * times100 / num)
61
-
62
- // 校对一下
63
- distance100 = {
64
- 3: 2,
65
- 4: 5,
66
- 6: 5,
67
- 7: 5,
68
- 8: 10,
69
- 9: 10,
70
- 11: 10,
71
- 12: 10,
72
- 13: 15,
73
- 14: 15,
74
- 16: 15,
75
- 17: 15,
76
- 18: 20,
77
- 19: 20,
78
- 21: 20,
79
- 22: 20,
80
- 23: 25,
81
- 24: 25,
82
- 26: 25,
83
- 27: 25
84
- }[distance100] || distance100
85
-
86
- let distance = distance100 / times100
87
-
88
- // 最小值,也就是起点
89
- let begin = Math.floor(minValue / distance) * distance
90
-
91
- let rulerArray = []
92
- // 获取最终的刻度尺数组
93
- rulerArray.push(begin)
94
- for (let index = 1; rulerArray[rulerArray.length - 1] < maxValue; index++) {
95
- rulerArray.push(begin + distance * index)
62
+ let distance100_oral = Math.ceil((maxValue - minValue) * times100 / num)
63
+
64
+ let getResult = (changValue: number) => {
65
+ // 校对一下
66
+ let distance100 = {
67
+ 3: 2,
68
+ 4: 5,
69
+ 6: 5,
70
+ 7: 5,
71
+ 8: 10,
72
+ 9: 10,
73
+ 11: 10,
74
+ 12: 10,
75
+ 13: 15,
76
+ 14: 15,
77
+ 16: 15,
78
+ 17: 15,
79
+ 18: 20,
80
+ 19: 20,
81
+ 21: 20,
82
+ 22: 20,
83
+ 23: 25,
84
+ 24: 25,
85
+ 26: 25,
86
+ 27: 25
87
+ }[distance100_oral + changValue] || (distance100_oral + changValue)
88
+
89
+ let distance = distance100 / times100
90
+
91
+ // 最小值,也就是起点
92
+ let begin = Math.floor(minValue / distance) * distance
93
+
94
+ let rulerArray = []
95
+ // 获取最终的刻度尺数组
96
+ rulerArray.push(begin)
97
+ for (let index = 1; rulerArray[rulerArray.length - 1] < maxValue; index++) {
98
+ rulerArray.push(begin + distance * index)
99
+ }
100
+
101
+ return rulerArray
96
102
  }
97
103
 
104
+ let rulerArray = getResult(0)
105
+
106
+ let balanceMax = () => {
107
+ let rulerArray_temp = []
108
+
109
+ let changeDist = rulerArray[rulerArray.length - 1] - option.max
110
+ for (let index = 0; index < rulerArray.length; index++) {
111
+ if (index + 1 < rulerArray.length && rulerArray[index + 1] - changeDist < minValue) {
112
+ // 多余的
113
+ } else {
114
+ rulerArray_temp.push(rulerArray[index] - changeDist)
115
+ }
116
+ }
117
+
118
+ return rulerArray_temp
119
+ }
120
+
121
+ let balanceMin = () => {
122
+ let rulerArray_temp = []
123
+
124
+ let changeDist = rulerArray[0] - option.min
125
+ for (let index = 0; index < rulerArray.length; index++) {
126
+ rulerArray_temp[index] = rulerArray[index] - changeDist
127
+ if (maxValue <= rulerArray_temp[index]) break
128
+ }
129
+
130
+ return rulerArray_temp
131
+ }
132
+
133
+ if (option) {
134
+
135
+ // 上下界限制
136
+ if ('max' in option && 'min' in option && option.max >= maxValue && option.min <= minValue) {
137
+
138
+ let isAnswer = () => {
139
+
140
+ // 先判断原始的是否可行
141
+ if (rulerArray[0] >= option.min && rulerArray[rulerArray.length - 1] <= option.max) return true
142
+
143
+ // 再判断max调整是否可行
144
+ let rulerArray_max = balanceMax()
145
+ if (rulerArray_max[0] >= option.min && rulerArray_max[rulerArray_max.length - 1] <= option.max) {
146
+ rulerArray = rulerArray_max
147
+ return true
148
+ }
149
+
150
+ // 再判断max调整是否可行
151
+ let rulerArray_min = balanceMin()
152
+ if (rulerArray_min[0] >= option.min && rulerArray_min[rulerArray_max.length - 1] <= option.max) {
153
+ rulerArray = rulerArray_min
154
+ return true
155
+ }
156
+
157
+ }
158
+
159
+ if (isAnswer()) return rulerArray
160
+
161
+ for (let changValue = 1; changValue < 100; changValue++) {
162
+
163
+ rulerArray = getResult(changValue)
164
+ if (isAnswer()) return rulerArray
165
+
166
+ rulerArray = getResult(-changValue)
167
+ if (isAnswer()) return rulerArray
168
+
169
+ }
170
+ }
171
+
172
+ // 单界限制
173
+ if ('max' in option && option.max >= maxValue) {
174
+
175
+ // 上越界了
176
+ if (option.max < rulerArray[rulerArray.length - 1]) {
177
+ rulerArray = balanceMax()
178
+ }
179
+ } else if ('min' in option && option.min <= minValue) {
180
+
181
+ // 下越界了
182
+ if (option.min > rulerArray[0]) {
183
+ rulerArray = balanceMin()
184
+ }
185
+ }
186
+ }
98
187
  return rulerArray
99
188
  }
@@ -0,0 +1,8 @@
1
+ export default interface CanvasOptionType {
2
+
3
+ /**
4
+ * 是否支持区域管理,默认true
5
+ */
6
+ region?: boolean
7
+
8
+ }
@@ -0,0 +1,8 @@
1
+ export default interface WebGLOptionType {
2
+
3
+ /**
4
+ * 是否支持区域管理,默认true
5
+ */
6
+ region?: boolean
7
+
8
+ }
package/types/index.d.ts CHANGED
@@ -12,6 +12,9 @@ import SVGType from './SVG'
12
12
  import CanvasType from './Canvas'
13
13
  import WebGLType from './WebGL'
14
14
 
15
+ import CanvasOptionType from './CanvasOption'
16
+ import WebGLOptionType from './WebGLOption'
17
+
15
18
  import getWebGLContextType from './getWebGLContext'
16
19
  import ShaderType from './Shader'
17
20
  import BufferType from './Buffer'
@@ -39,10 +42,10 @@ interface NewSVGType extends SVGType {
39
42
  new(el: HTMLElement | null): this
40
43
  }
41
44
  interface NewCanvasType extends CanvasType {
42
- new(el: HTMLElement | null): this
45
+ new(el: HTMLElement | null, option?: CanvasOptionType): this
43
46
  }
44
47
  interface NewWebGLType extends WebGLType {
45
- new(el: HTMLElement | null): this
48
+ new(el: HTMLElement | null, option?: WebGLOptionType): this
46
49
  }
47
50
 
48
51
  // WebGL
package/types/ruler.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ export interface rulerOptionType {
2
+ max?: number
3
+ min?: number
4
+ }
5
+
1
6
  export default interface rulerType {
2
- (maxValue: number, minValue: number, num: number): number[]
7
+ (maxValue: number, minValue: number, num: number, option: rulerOptionType): number[]
3
8
  }
@@ -7,17 +7,19 @@
7
7
  <!-- #ifdef MP-ALIPAY -->
8
8
  <canvas class="painter" :id="'painter-' + uniqueid" @touchstart="doitstart"
9
9
  :style="{ width: width + 'px', height: height + 'px' }"></canvas>
10
- <canvas class="region" :id="'region-' + uniqueid" :style="{ width: width + 'px', height: height + 'px' }"></canvas>
10
+ <canvas v-if="region" class="region" :id="'region-' + uniqueid"
11
+ :style="{ width: width + 'px', height: height + 'px' }"></canvas>
11
12
  <!-- #endif -->
12
13
  <!-- #ifdef MP-WEIXIN -->
13
14
  <canvas class="painter" canvas-id="painter" @touchstart="doitstart"
14
15
  :style="{ width: width + 'px', height: height + 'px' }"></canvas>
15
- <canvas class="region" canvas-id="region" :style="{ width: width + 'px', height: height + 'px' }"></canvas>
16
+ <canvas v-if="region" class="region" canvas-id="region"
17
+ :style="{ width: width + 'px', height: height + 'px' }"></canvas>
16
18
  <!-- #endif -->
17
19
  <!-- #ifndef MP-WEIXIN||MP-ALIPAY -->
18
20
  <canvas class="painter" :canvas-id="'painter-' + uniqueid" @touchstart="doitstart"
19
21
  :style="{ width: width + 'px', height: height + 'px' }"></canvas>
20
- <canvas class="region" :canvas-id="'region-' + uniqueid"
22
+ <canvas v-if="region" class="region" :canvas-id="'region-' + uniqueid"
21
23
  :style="{ width: width + 'px', height: height + 'px' }"></canvas>
22
24
  <!-- #endif -->
23
25
  </view>
@@ -55,19 +57,23 @@ export default {
55
57
  type: Boolean,
56
58
  default: true,
57
59
  },
60
+ region: {
61
+ type: Boolean,
62
+ default: true,
63
+ },
58
64
  },
59
65
  methods: {
60
66
  fetch() {
61
67
  let painter, region, painterid, regionid;
62
68
  // #ifdef MP-WEIXIN
63
69
  painter = uni.createCanvasContext("painter", this);
64
- region = uni.createCanvasContext("region", this);
70
+ if (this.region) region = uni.createCanvasContext("region", this);
65
71
  painterid = "painter";
66
72
  regionid = "region";
67
73
  // #endif
68
74
  // #ifndef MP-WEIXIN
69
75
  painter = uni.createCanvasContext("painter-" + this.uniqueid, this);
70
- region = uni.createCanvasContext("region-" + this.uniqueid, this);
76
+ if (this.region) region = uni.createCanvasContext("region-" + this.uniqueid, this);
71
77
  painterid = "painter-" + this.uniqueid;
72
78
  regionid = "region-" + this.uniqueid;
73
79
  // #endif
@@ -79,7 +85,7 @@ export default {
79
85
  return painter;
80
86
  },
81
87
  },
82
- {
88
+ _this.region ? {
83
89
  getContext() {
84
90
  // #ifdef MP-ALIPAY
85
91
  let getImageData = region.getImageData;
@@ -110,26 +116,30 @@ export default {
110
116
  };
111
117
  return region;
112
118
  },
113
- }
119
+ } : null
114
120
  );
115
- this.help.instance.draw = () => {
116
- painter.draw();
117
- region.draw();
121
+ this.help.instance.draw = (reserve = false, callback = () => { }) => {
122
+ painter.draw(reserve, () => {
118
123
 
119
- // 如果不使用原生渲染
120
- if (!this.cover && !this.isH5) {
121
- setTimeout(() => {
124
+ // 如果不使用原生渲染
125
+ if (!this.cover && !this.isH5) {
122
126
  uni.canvasToTempFilePath(
123
127
  {
124
128
  canvasId: painterid,
125
129
  success: (e) => {
126
130
  this.viewImg = e.tempFilePath;
131
+ if (_this.region) region.draw(reserve);
132
+ callback();
127
133
  },
128
134
  },
129
135
  this
130
136
  );
131
- }, 300);
132
- }
137
+ } else {
138
+ if (_this.region) region.draw(reserve);
139
+ callback();
140
+ }
141
+ });
142
+
133
143
  };
134
144
  return new Promise((resolve, reject) => {
135
145
  this.help.instance.toDataURL = () => {