zydx-plus 1.32.293 → 1.32.294
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/package.json +1 -1
- package/src/components/flip/src/flip.vue +198 -87
- package/src/index.js +1 -1
package/package.json
CHANGED
|
@@ -11,7 +11,19 @@
|
|
|
11
11
|
<div class="wrap-can" ref="wrapCan">
|
|
12
12
|
<canvas @click.stop="turnText" class="wrap-can-one" @mousedown.stop="mouseDown" @mousemove.stop="mouseMove" :id="id"></canvas>
|
|
13
13
|
<canvas :id="`${id}2`"></canvas>
|
|
14
|
-
<div
|
|
14
|
+
<div
|
|
15
|
+
v-show="state === 'text'&&textY2>0&&textX2>0"
|
|
16
|
+
class="text-frame"
|
|
17
|
+
@mousedown.stop="textMouseDown"
|
|
18
|
+
@dblclick="textDblclick"
|
|
19
|
+
:style="{
|
|
20
|
+
top: textY2/sratio + 'px',
|
|
21
|
+
left: textX2/sratio + 'px',
|
|
22
|
+
'min-height': textHeight +'px',
|
|
23
|
+
border: `1px dashed ${color}`,
|
|
24
|
+
'min-width': textWidth + 'px',
|
|
25
|
+
cursor: contenteditable? 'text': 'move'
|
|
26
|
+
}">
|
|
15
27
|
<div class="text-input" ref="textInput" :style="{'font-size': fontSize + 'px',color: color}" :contenteditable="contenteditable"></div>
|
|
16
28
|
</div>
|
|
17
29
|
</div>
|
|
@@ -172,7 +184,12 @@ export default {
|
|
|
172
184
|
pointsSelect: [],
|
|
173
185
|
checkDrawing: false,
|
|
174
186
|
checkX: 0,
|
|
175
|
-
checkY: 0
|
|
187
|
+
checkY: 0,
|
|
188
|
+
textWidth: 0,
|
|
189
|
+
textHeight: 0,
|
|
190
|
+
textDownX: 0,
|
|
191
|
+
textDownY: 0,
|
|
192
|
+
textMoveStart: false,
|
|
176
193
|
}
|
|
177
194
|
},
|
|
178
195
|
props: {
|
|
@@ -246,21 +263,35 @@ export default {
|
|
|
246
263
|
emits: ['flip','updateData'],
|
|
247
264
|
mounted() {
|
|
248
265
|
this.id = 'canvas-wrap' + Math.random().toString(36).substr(2)
|
|
266
|
+
window.addEventListener('keydown', this.handleKeyEvent)
|
|
249
267
|
// 在画板以外松开鼠标后冻结画笔
|
|
250
268
|
document.onmouseup = () => {
|
|
251
269
|
if (this.isDrawing || this.checkDrawing) this.mouseUp()
|
|
270
|
+
this.textMoveStart = false
|
|
252
271
|
}
|
|
253
272
|
},
|
|
273
|
+
beforeDestroy() {
|
|
274
|
+
window.removeEventListener('keydown', this.handleKeyEvent)
|
|
275
|
+
},
|
|
254
276
|
methods: {
|
|
277
|
+
handleKeyEvent(e) {
|
|
278
|
+
const {key} = e
|
|
279
|
+
if (key === 'Backspace' || key === 'Delete') {
|
|
280
|
+
this.backward()
|
|
281
|
+
}
|
|
282
|
+
},
|
|
255
283
|
empty() {
|
|
284
|
+
this.setShow = false
|
|
256
285
|
this.points = []
|
|
257
286
|
this.clearRect(true)
|
|
258
287
|
},
|
|
259
288
|
preserve() {
|
|
289
|
+
this.setShow = false
|
|
260
290
|
this.$emit('updateData', this.points)
|
|
261
291
|
},
|
|
262
292
|
// 后退
|
|
263
293
|
backward() {
|
|
294
|
+
this.setShow = false
|
|
264
295
|
if(this.points.length === 0) return
|
|
265
296
|
if(this.points[this.points.length - 1].type === 'line') {
|
|
266
297
|
const id = this.points[this.points.length - 1].id
|
|
@@ -283,7 +314,7 @@ export default {
|
|
|
283
314
|
// 画笔
|
|
284
315
|
brush() {
|
|
285
316
|
this.state = 'brush'
|
|
286
|
-
this.setShow =
|
|
317
|
+
this.setShow = true
|
|
287
318
|
this.top = 60
|
|
288
319
|
},
|
|
289
320
|
// 文字字号
|
|
@@ -293,34 +324,38 @@ export default {
|
|
|
293
324
|
// 矩形
|
|
294
325
|
rectangleTap() {
|
|
295
326
|
this.state = 'rectangle'
|
|
296
|
-
this.setShow =
|
|
327
|
+
this.setShow = true
|
|
297
328
|
this.top = 60*3
|
|
298
329
|
},
|
|
299
330
|
// 圆形
|
|
300
331
|
circularTap() {
|
|
301
332
|
this.state = 'circular'
|
|
302
|
-
this.setShow =
|
|
333
|
+
this.setShow = true
|
|
303
334
|
this.top = 60*4
|
|
304
335
|
},
|
|
305
336
|
// 直线
|
|
306
337
|
straightTap() {
|
|
307
338
|
this.state = 'straight'
|
|
308
|
-
this.setShow =
|
|
339
|
+
this.setShow = true
|
|
309
340
|
this.top = 60*5
|
|
310
341
|
},
|
|
311
342
|
// 箭头
|
|
312
343
|
arrowTap() {
|
|
313
344
|
this.state = 'arrow'
|
|
314
|
-
this.setShow =
|
|
345
|
+
this.setShow = true
|
|
315
346
|
this.top = 60*6
|
|
316
347
|
},
|
|
348
|
+
// 文字
|
|
317
349
|
textTap() {
|
|
318
350
|
this.state = 'text'
|
|
319
|
-
this.setShow =
|
|
351
|
+
this.setShow = true
|
|
320
352
|
this.top = 60*2
|
|
321
353
|
this.textStart = true
|
|
322
354
|
this.textX2 = 0
|
|
323
355
|
this.textY2 = 0
|
|
356
|
+
this.textWidth = 100
|
|
357
|
+
this.textHeight = this.fontSize + 1
|
|
358
|
+
this.$refs.textInput.innerText = ''
|
|
324
359
|
},
|
|
325
360
|
flipTool() {
|
|
326
361
|
this.setShow = false
|
|
@@ -355,36 +390,42 @@ export default {
|
|
|
355
390
|
if (this.points[i].index === this.pageIndex) {
|
|
356
391
|
const x1 = this.points[i].x*this.scales/this.points[i].scale
|
|
357
392
|
const y1 = this.points[i].y*this.scales/this.points[i].scale
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
const
|
|
362
|
-
const
|
|
363
|
-
const
|
|
364
|
-
const
|
|
365
|
-
const
|
|
366
|
-
const
|
|
367
|
-
if(a
|
|
368
|
-
|
|
393
|
+
// 判断点击的是否是圆
|
|
394
|
+
if(this.points[i]?.type === 'circular') {
|
|
395
|
+
const x2 = this.points[i].x*this.scales/this.points[i].scale + this.points[i].width*this.scales/this.points[i].scale
|
|
396
|
+
const y2 = this.points[i].y*this.scales/this.points[i].scale + this.points[i].width*this.scales/this.points[i].scale
|
|
397
|
+
const a = Math.sqrt(Math.pow(x1-obj.x,1.65)+Math.pow(y1-obj.y,1.65))
|
|
398
|
+
const b = Math.sqrt(Math.pow(x2-obj.x,1.65)+Math.pow(y2-obj.y,1.65))
|
|
399
|
+
const c = Math.sqrt(Math.pow(x1-obj.x,1.65)+Math.pow(y2-obj.y,1.65))
|
|
400
|
+
const d = Math.sqrt(Math.pow(x2-obj.x,1.65)+Math.pow(y1-obj.y,1.65))
|
|
401
|
+
const e = this.points[i].width*this.scales/this.points[i].scale/2
|
|
402
|
+
if(a <= e || b <= e || c <= e || d <= e) {
|
|
403
|
+
this.pointsSelect.push(this.points[i])
|
|
404
|
+
this.circularProcessing(this.points[i],{x:0,y:0})
|
|
405
|
+
this.points.splice(i,1)
|
|
369
406
|
}
|
|
370
407
|
}
|
|
371
|
-
if(this.points[i]
|
|
372
|
-
|
|
373
|
-
|
|
408
|
+
if(this.points[i]?.type === 'text') {
|
|
409
|
+
// 取最长的一行文字
|
|
410
|
+
let len = 0
|
|
411
|
+
this.points[i].text.forEach(item => {
|
|
412
|
+
if(item.length > len) len = item.length
|
|
413
|
+
})
|
|
414
|
+
const x2 = this.points[i].x*this.scales/this.points[i].scale + len*this.points[i].size*this.sratio
|
|
415
|
+
const y2 = this.points[i].y*this.scales/this.points[i].scale + len*this.points[i].size*this.sratio
|
|
374
416
|
if(obj.x >= x1 && obj.x <= x2 && obj.y >= y1 && obj.y <= y2) {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
console.log(this.points[i])
|
|
417
|
+
this.state = 'text'
|
|
418
|
+
this.textX2 = x1
|
|
419
|
+
this.textY2 = y1
|
|
420
|
+
this.textWidth = 'auto'
|
|
421
|
+
this.color = this.points[i].color
|
|
422
|
+
this.textHeight = this.points[i].text.length*this.points[i].size + 1
|
|
423
|
+
this.$refs.textInput.innerText = this.points[i].text.join('\n')
|
|
424
|
+
this.points.splice(i,1)
|
|
425
|
+
this.clearRect()
|
|
385
426
|
}
|
|
386
427
|
}
|
|
387
|
-
if(this.points[i]
|
|
428
|
+
if(this.points[i]?.type === 'rectangle') {
|
|
388
429
|
const x2 = this.points[i].x*this.scales/this.points[i].scale + this.points[i].width*this.scales/this.points[i].scale
|
|
389
430
|
const y2 = this.points[i].y*this.scales/this.points[i].scale + this.points[i].height*this.scales/this.points[i].scale
|
|
390
431
|
if(obj.x >= x1 && obj.x <= x2 && obj.y >= y1 && obj.y <= y2) {
|
|
@@ -393,7 +434,7 @@ export default {
|
|
|
393
434
|
this.points.splice(i,1)
|
|
394
435
|
}
|
|
395
436
|
}
|
|
396
|
-
if(this.points[i]
|
|
437
|
+
if(this.points[i]?.type === 'line') {
|
|
397
438
|
const x2 = this.points[i+1]?this.points[i+1].x*this.scales/this.points[i].scale:0
|
|
398
439
|
const y2 = this.points[i+1]?this.points[i+1].y*this.scales/this.points[i].scale:0
|
|
399
440
|
const x3 = obj.x
|
|
@@ -402,27 +443,47 @@ export default {
|
|
|
402
443
|
const b = Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2))
|
|
403
444
|
const c = Math.sqrt(Math.pow(x1-x3,2)+Math.pow(y1-y3,2))
|
|
404
445
|
const d = Math.sqrt(Math.pow(x2-x3,2)+Math.pow(y2-y3,2))
|
|
405
|
-
if(a/b <=
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
this.
|
|
410
|
-
this.points.
|
|
411
|
-
|
|
446
|
+
if(a/b <= 5 && c <= b && d <= b) {
|
|
447
|
+
const id = this.points[i].id
|
|
448
|
+
for(let j=0; j<this.points.length; j++) {
|
|
449
|
+
if(this.points[j].id === id) {
|
|
450
|
+
this.pointsSelect.push(this.points[j])
|
|
451
|
+
this.lineProcessing(this.points[j],this.points[j+1],{x:0,y:0})
|
|
452
|
+
this.points.splice(j,1)
|
|
453
|
+
j--
|
|
412
454
|
}
|
|
413
455
|
}
|
|
414
456
|
}
|
|
415
457
|
}
|
|
458
|
+
if(this.points[i]?.type === 'straight' || this.points[i]?.type === 'arrow') {
|
|
459
|
+
const x2 = this.points[i].x2*this.scales/this.points[i].scale
|
|
460
|
+
const y2 = this.points[i].y2*this.scales/this.points[i].scale
|
|
461
|
+
const x3 = obj.x
|
|
462
|
+
const y3 = obj.y
|
|
463
|
+
const a = Math.abs((x1-x2)*(y1-y3)-(x1-x3)*(y1-y2))
|
|
464
|
+
const b = Math.sqrt(Math.pow(x1-x2,2)+Math.pow(y1-y2,2))
|
|
465
|
+
const c = Math.sqrt(Math.pow(x1-x3,2)+Math.pow(y1-y3,2))
|
|
466
|
+
const d = Math.sqrt(Math.pow(x2-x3,2)+Math.pow(y2-y3,2))
|
|
467
|
+
if(a/b <= 5 && c <= b && d <= b) {
|
|
468
|
+
this.pointsSelect.push(this.points[i])
|
|
469
|
+
if(this.points[i].type === 'straight') {
|
|
470
|
+
this.straightProcessing(this.points[i],{x:0,y:0})
|
|
471
|
+
}else {
|
|
472
|
+
this.arrowProcessing(this.points[i],{x:0,y:0})
|
|
473
|
+
}
|
|
474
|
+
this.points.splice(i,1)
|
|
475
|
+
}
|
|
476
|
+
}
|
|
416
477
|
}
|
|
417
478
|
}
|
|
418
479
|
},
|
|
419
480
|
checkMove(e) {
|
|
481
|
+
if(this.pointsSelect.length === 0) return
|
|
420
482
|
let obj = {
|
|
421
483
|
x: e.offsetX*this.sratio - this.checkX,
|
|
422
484
|
y: e.offsetY*this.sratio - this.checkY
|
|
423
485
|
}
|
|
424
486
|
this.clearRect()
|
|
425
|
-
console.log(this.pointsSelect)
|
|
426
487
|
for(let i=0; i<this.pointsSelect.length; i++) {
|
|
427
488
|
if(this.pointsSelect[i].type === 'line') {
|
|
428
489
|
this.lineProcessing(this.pointsSelect[i],this.pointsSelect[i+1],obj)
|
|
@@ -430,6 +491,15 @@ export default {
|
|
|
430
491
|
if(this.pointsSelect[i].type === 'rectangle') {
|
|
431
492
|
this.rectangleProcessing(this.pointsSelect[i],obj)
|
|
432
493
|
}
|
|
494
|
+
if(this.pointsSelect[i].type === 'straight') {
|
|
495
|
+
this.straightProcessing(this.pointsSelect[i],obj)
|
|
496
|
+
}
|
|
497
|
+
if(this.pointsSelect[i].type === 'arrow') {
|
|
498
|
+
this.arrowProcessing(this.pointsSelect[i],obj)
|
|
499
|
+
}
|
|
500
|
+
if(this.pointsSelect[i].type === 'circular') {
|
|
501
|
+
this.circularProcessing(this.pointsSelect[i],obj)
|
|
502
|
+
}
|
|
433
503
|
}
|
|
434
504
|
},
|
|
435
505
|
checkUp(e) {
|
|
@@ -440,6 +510,10 @@ export default {
|
|
|
440
510
|
for(let i=0; i<this.pointsSelect.length; i++) {
|
|
441
511
|
this.pointsSelect[i].x = this.pointsSelect[i].x + obj.x
|
|
442
512
|
this.pointsSelect[i].y = this.pointsSelect[i].y + obj.y
|
|
513
|
+
if(this.pointsSelect[i].type === 'straight' || this.pointsSelect[i].type === 'arrow') {
|
|
514
|
+
this.pointsSelect[i].x2 = this.pointsSelect[i].x2 + obj.x
|
|
515
|
+
this.pointsSelect[i].y2 = this.pointsSelect[i].y2 + obj.y
|
|
516
|
+
}
|
|
443
517
|
this.points.push(this.pointsSelect[i])
|
|
444
518
|
}
|
|
445
519
|
},
|
|
@@ -449,7 +523,7 @@ export default {
|
|
|
449
523
|
e.preventDefault()
|
|
450
524
|
if(this.state === null) {
|
|
451
525
|
this.checkDrawing = true
|
|
452
|
-
|
|
526
|
+
this.checkDown(e)
|
|
453
527
|
return
|
|
454
528
|
}
|
|
455
529
|
this.isDrawing = true
|
|
@@ -459,11 +533,24 @@ export default {
|
|
|
459
533
|
}
|
|
460
534
|
this.drawStart(obj)
|
|
461
535
|
},
|
|
536
|
+
textDblclick() {
|
|
537
|
+
if(!this.contenteditable) this.contenteditable = true
|
|
538
|
+
},
|
|
539
|
+
textMouseDown(e) {
|
|
540
|
+
e = e || event
|
|
541
|
+
this.textDownX = e.offsetX
|
|
542
|
+
this.textDownY = e.offsetY
|
|
543
|
+
this.textMoveStart = true
|
|
544
|
+
},
|
|
462
545
|
mouseMove (e) {
|
|
463
546
|
e = e || event
|
|
464
547
|
e.preventDefault()
|
|
548
|
+
if(this.textMoveStart) {
|
|
549
|
+
this.textX2 = e.offsetX*this.sratio - this.textDownX
|
|
550
|
+
this.textY2 = e.offsetY*this.sratio - this.textDownY
|
|
551
|
+
}
|
|
465
552
|
if(this.state === null) {
|
|
466
|
-
|
|
553
|
+
if(this.checkDrawing) this.checkMove(e)
|
|
467
554
|
return
|
|
468
555
|
}
|
|
469
556
|
if (this.isDrawing) {
|
|
@@ -479,7 +566,7 @@ export default {
|
|
|
479
566
|
e.preventDefault()
|
|
480
567
|
if(this.state === null) {
|
|
481
568
|
this.checkDrawing = false
|
|
482
|
-
|
|
569
|
+
this.checkUp(e)
|
|
483
570
|
return
|
|
484
571
|
}
|
|
485
572
|
let obj = {
|
|
@@ -560,6 +647,7 @@ export default {
|
|
|
560
647
|
this.ctx.fillStyle = this.color;
|
|
561
648
|
this.ctx.fillText(arr[i],this.textX2,this.textY2 + this.fontSize*this.sratio*i + this.fontSize*this.sratio);
|
|
562
649
|
this.ctx.stroke()
|
|
650
|
+
this.ctx.closePath()
|
|
563
651
|
}
|
|
564
652
|
this.points.push({
|
|
565
653
|
x: this.textX2,
|
|
@@ -603,6 +691,7 @@ export default {
|
|
|
603
691
|
arrowY = obj.y + botY;
|
|
604
692
|
this.ctx.lineTo(arrowX, arrowY)
|
|
605
693
|
this.ctx.stroke()
|
|
694
|
+
this.ctx.closePath()
|
|
606
695
|
if(type === 'end') {
|
|
607
696
|
this.points.push({
|
|
608
697
|
x: this.textX,
|
|
@@ -633,6 +722,7 @@ export default {
|
|
|
633
722
|
this.ctx.moveTo(this.textX, this.textY)
|
|
634
723
|
this.ctx.lineTo(obj.x, obj.y)
|
|
635
724
|
this.ctx.stroke()
|
|
725
|
+
this.ctx.closePath()
|
|
636
726
|
if(type === 'end') {
|
|
637
727
|
this.points.push({
|
|
638
728
|
x: this.textX,
|
|
@@ -664,6 +754,7 @@ export default {
|
|
|
664
754
|
this.ctx.moveTo(obj.x,this.textY)
|
|
665
755
|
this.ctx.arc(this.textX, this.textY, obj.x-this.textX, 0, 2 * Math.PI, false);
|
|
666
756
|
this.ctx.stroke()
|
|
757
|
+
this.ctx.closePath()
|
|
667
758
|
if(type === 'end') {
|
|
668
759
|
this.points.push({
|
|
669
760
|
x: this.textX,
|
|
@@ -692,6 +783,7 @@ export default {
|
|
|
692
783
|
this.ctx.strokeStyle = this.color
|
|
693
784
|
this.ctx.rect(this.textX, this.textY, obj.x-this.textX, obj.y-this.textY);
|
|
694
785
|
this.ctx.stroke()
|
|
786
|
+
this.ctx.closePath()
|
|
695
787
|
if(type === 'end') {
|
|
696
788
|
this.points.push({
|
|
697
789
|
x: this.textX,
|
|
@@ -746,12 +838,65 @@ export default {
|
|
|
746
838
|
this.ctx.stroke()
|
|
747
839
|
this.ctx.closePath()
|
|
748
840
|
},
|
|
749
|
-
rectangleProcessing(data,v
|
|
841
|
+
rectangleProcessing(data,v) {
|
|
750
842
|
this.ctx.beginPath()
|
|
751
843
|
this.ctx.lineWidth = data.border * this.sratio
|
|
752
844
|
this.ctx.strokeStyle = data.color
|
|
753
845
|
this.ctx.strokeRect(data.x*this.scales/data.scale + v.x, data.y*this.scales/data.scale + v.y, data.width*this.scales/data.scale, data.height*this.scales/data.scale);
|
|
754
846
|
this.ctx.stroke()
|
|
847
|
+
this.ctx.closePath()
|
|
848
|
+
},
|
|
849
|
+
circularProcessing(data,v) {
|
|
850
|
+
this.ctx.beginPath()
|
|
851
|
+
this.ctx.lineWidth = data.border * this.sratio
|
|
852
|
+
this.ctx.strokeStyle = data.color
|
|
853
|
+
this.ctx.arc(data.x*this.scales/data.scale + v.x, data.y*this.scales/data.scale + v.y, data.width*this.scales/data.scale, 0, 2 * Math.PI, false);
|
|
854
|
+
this.ctx.stroke()
|
|
855
|
+
this.ctx.closePath()
|
|
856
|
+
},
|
|
857
|
+
straightProcessing(data,v) {
|
|
858
|
+
this.ctx.beginPath()
|
|
859
|
+
this.ctx.lineWidth = data.border * this.sratio
|
|
860
|
+
this.ctx.strokeStyle = data.color
|
|
861
|
+
this.ctx.moveTo(data.x*this.scales/data.scale + v.x, data.y*this.scales/data.scale + v.y)
|
|
862
|
+
this.ctx.lineTo(data.x2*this.scales/data.scale + v.x, data.y2*this.scales/data.scale + v.y)
|
|
863
|
+
this.ctx.stroke()
|
|
864
|
+
this.ctx.closePath()
|
|
865
|
+
},
|
|
866
|
+
arrowProcessing(data,v) {
|
|
867
|
+
const angle = Math.atan2(data.y*this.scales/data.scale - data.y2*this.scales/data.scale, data.x*this.scales/data.scale - data.x2*this.scales/data.scale) * 180 / Math.PI
|
|
868
|
+
const angle1 = (angle + 20) * Math.PI / 180
|
|
869
|
+
const angle2 = (angle - 20) * Math.PI / 180
|
|
870
|
+
const topX = 30 * Math.cos(angle1)
|
|
871
|
+
const topY = 30 * Math.sin(angle1)
|
|
872
|
+
const botX = 30 * Math.cos(angle2)
|
|
873
|
+
const botY = 30 * Math.sin(angle2)
|
|
874
|
+
this.ctx.beginPath();
|
|
875
|
+
this.ctx.lineWidth = data.border * this.sratio
|
|
876
|
+
this.ctx.strokeStyle = data.color
|
|
877
|
+
let arrowX, arrowY
|
|
878
|
+
this.ctx.moveTo(data.x2*this.scales/data.scale + v.x, data.y2*this.scales/data.scale + v.y);
|
|
879
|
+
this.ctx.lineTo(data.x*this.scales/data.scale + v.x, data.y*this.scales/data.scale + v.y);
|
|
880
|
+
arrowX = data.x2*this.scales/data.scale + topX + v.x
|
|
881
|
+
arrowY = data.y2*this.scales/data.scale + topY + v.y
|
|
882
|
+
this.ctx.moveTo(arrowX, arrowY);
|
|
883
|
+
this.ctx.lineTo(data.x2*this.scales/data.scale + v.x, data.y2*this.scales/data.scale + v.y)
|
|
884
|
+
arrowX = data.x2*this.scales/data.scale + botX + v.x;
|
|
885
|
+
arrowY = data.y2*this.scales/data.scale + botY + v.y;
|
|
886
|
+
this.ctx.lineTo(arrowX, arrowY)
|
|
887
|
+
this.ctx.stroke()
|
|
888
|
+
this.ctx.closePath()
|
|
889
|
+
},
|
|
890
|
+
textProcessing(data,v) {
|
|
891
|
+
const arr = data.text
|
|
892
|
+
for(let i = 0; i < arr.length; i++) {
|
|
893
|
+
this.ctx.beginPath();
|
|
894
|
+
this.ctx.font = `${data.size*this.sratio}px 黑体`;
|
|
895
|
+
this.ctx.fillStyle = data.color;
|
|
896
|
+
this.ctx.fillText(arr[i],data.x*this.scales/data.scale + v.x,data.y*this.scales/data.scale + v.y + data.size*this.sratio*i + data.size*this.sratio);
|
|
897
|
+
this.ctx.stroke()
|
|
898
|
+
this.ctx.closePath()
|
|
899
|
+
}
|
|
755
900
|
},
|
|
756
901
|
// 处理数据
|
|
757
902
|
processing() {
|
|
@@ -764,52 +909,16 @@ export default {
|
|
|
764
909
|
this.rectangleProcessing(this.points[i],{x:0,y:0})
|
|
765
910
|
}
|
|
766
911
|
if(this.points[i].type === 'circular') {
|
|
767
|
-
this.
|
|
768
|
-
this.ctx.lineWidth = this.points[i].border * this.sratio
|
|
769
|
-
this.ctx.strokeStyle = this.points[i].color
|
|
770
|
-
this.ctx.arc(this.points[i].x*this.scales/this.points[i].scale, this.points[i].y*this.scales/this.points[i].scale, this.points[i].width*this.scales/this.points[i].scale, 0, 2 * Math.PI, false);
|
|
771
|
-
this.ctx.stroke()
|
|
912
|
+
this.circularProcessing(this.points[i],{x:0,y:0})
|
|
772
913
|
}
|
|
773
914
|
if(this.points[i].type === 'straight') {
|
|
774
|
-
this.
|
|
775
|
-
this.ctx.lineWidth = this.points[i].border * this.sratio
|
|
776
|
-
this.ctx.strokeStyle = this.points[i].color
|
|
777
|
-
this.ctx.moveTo(this.points[i].x*this.scales/this.points[i].scale, this.points[i].y*this.scales/this.points[i].scale)
|
|
778
|
-
this.ctx.lineTo(this.points[i].x2*this.scales/this.points[i].scale, this.points[i].y2*this.scales/this.points[i].scale)
|
|
779
|
-
this.ctx.stroke()
|
|
915
|
+
this.straightProcessing(this.points[i],{x:0,y:0})
|
|
780
916
|
}
|
|
781
917
|
if(this.points[i].type === 'arrow') {
|
|
782
|
-
|
|
783
|
-
const angle1 = (angle + 20) * Math.PI / 180
|
|
784
|
-
const angle2 = (angle - 20) * Math.PI / 180
|
|
785
|
-
const topX = 30 * Math.cos(angle1)
|
|
786
|
-
const topY = 30 * Math.sin(angle1)
|
|
787
|
-
const botX = 30 * Math.cos(angle2)
|
|
788
|
-
const botY = 30 * Math.sin(angle2)
|
|
789
|
-
this.ctx.beginPath();
|
|
790
|
-
this.ctx.lineWidth = this.points[i].border * this.sratio
|
|
791
|
-
this.ctx.strokeStyle = this.points[i].color
|
|
792
|
-
let arrowX, arrowY
|
|
793
|
-
this.ctx.moveTo(this.points[i].x2*this.scales/this.points[i].scale, this.points[i].y2*this.scales/this.points[i].scale);
|
|
794
|
-
this.ctx.lineTo(this.points[i].x*this.scales/this.points[i].scale, this.points[i].y*this.scales/this.points[i].scale);
|
|
795
|
-
arrowX = this.points[i].x2*this.scales/this.points[i].scale + topX
|
|
796
|
-
arrowY = this.points[i].y2*this.scales/this.points[i].scale + topY
|
|
797
|
-
this.ctx.moveTo(arrowX, arrowY);
|
|
798
|
-
this.ctx.lineTo(this.points[i].x2*this.scales/this.points[i].scale, this.points[i].y2*this.scales/this.points[i].scale)
|
|
799
|
-
arrowX = this.points[i].x2*this.scales/this.points[i].scale + botX;
|
|
800
|
-
arrowY = this.points[i].y2*this.scales/this.points[i].scale + botY;
|
|
801
|
-
this.ctx.lineTo(arrowX, arrowY)
|
|
802
|
-
this.ctx.stroke();
|
|
918
|
+
this.arrowProcessing(this.points[i],{x:0,y:0})
|
|
803
919
|
}
|
|
804
920
|
if(this.points[i].type === 'text') {
|
|
805
|
-
|
|
806
|
-
for(let j = 0; j < arr.length; j++) {
|
|
807
|
-
this.ctx.beginPath();
|
|
808
|
-
this.ctx.font = `${this.points[i].size*this.sratio}px 黑体`;
|
|
809
|
-
this.ctx.fillStyle = this.points[i].color;
|
|
810
|
-
this.ctx.fillText(arr[j],this.points[i].x*this.scales/this.points[i].scale,this.points[i].y*this.scales/this.points[i].scale + this.points[i].size*this.sratio*j + this.points[i].size*this.sratio);
|
|
811
|
-
this.ctx.stroke();
|
|
812
|
-
}
|
|
921
|
+
this.textProcessing(this.points[i],{x:0,y:0})
|
|
813
922
|
}
|
|
814
923
|
}
|
|
815
924
|
}
|
|
@@ -926,7 +1035,9 @@ export default {
|
|
|
926
1035
|
position: absolute;
|
|
927
1036
|
z-index: 10;
|
|
928
1037
|
display: inline-block;
|
|
929
|
-
|
|
1038
|
+
line-height: 1.1;
|
|
1039
|
+
user-select: none;
|
|
1040
|
+
transition: all 0s;
|
|
930
1041
|
}
|
|
931
1042
|
.text-input{
|
|
932
1043
|
width: 100%;
|