|
@@ -6,7 +6,7 @@
|
|
|
|
|
|
<script>
|
|
|
|
|
|
-let speed = 10
|
|
|
+let speed = 20
|
|
|
|
|
|
export default {
|
|
|
props: {
|
|
@@ -26,38 +26,52 @@ export default {
|
|
|
let devicePixelRatio = window.devicePixelRatio || 1
|
|
|
let lineTxt = [
|
|
|
{
|
|
|
- posi: [180, 150],
|
|
|
- val: 1600
|
|
|
- },
|
|
|
- {
|
|
|
- posi: [340, 290],
|
|
|
- val: 1800
|
|
|
- },
|
|
|
- {
|
|
|
- posi: [490, 150],
|
|
|
- val: 800
|
|
|
- },
|
|
|
- {
|
|
|
- posi: [580, 290],
|
|
|
- val: 1800
|
|
|
- },
|
|
|
- {
|
|
|
- posi: [700, 150],
|
|
|
- val: 1000
|
|
|
- }, {
|
|
|
- posi: [660, 290],
|
|
|
- val: 2200
|
|
|
- }, {
|
|
|
- posi: [820, 290],
|
|
|
- val: 3000
|
|
|
+ posi: [840, 290],
|
|
|
+ val: '3.2米',
|
|
|
+ guideLine: [{
|
|
|
+ type: 'm',
|
|
|
+ val: [790, 320]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'l',
|
|
|
+ val: [800, 280]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'l',
|
|
|
+ val: [815, 280]
|
|
|
+ } ]
|
|
|
},
|
|
|
{
|
|
|
- posi: [490, 450],
|
|
|
- val: 8000
|
|
|
+ posi: [690, 395],
|
|
|
+ val: '5.4米',
|
|
|
+ guideLine: [{
|
|
|
+ type: 'm',
|
|
|
+ val: [640, 425]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'l',
|
|
|
+ val: [650, 385]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'l',
|
|
|
+ val: [665, 385]
|
|
|
+ } ]
|
|
|
},
|
|
|
{
|
|
|
- posi: [850, 540],
|
|
|
- val: 6000
|
|
|
+ posi: [920, 470],
|
|
|
+ val: '3.4米',
|
|
|
+ guideLine: [{
|
|
|
+ type: 'm',
|
|
|
+ val: [870, 490]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'l',
|
|
|
+ val: [880, 460]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'l',
|
|
|
+ val: [895, 460]
|
|
|
+ } ]
|
|
|
}
|
|
|
]
|
|
|
|
|
@@ -68,24 +82,8 @@ export default {
|
|
|
},
|
|
|
{
|
|
|
type: 'l',
|
|
|
- val: [790, 90]
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'l',
|
|
|
- val: [890, 0]
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'm',
|
|
|
- val: [790, 90]
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'l',
|
|
|
- val: [35, 110]
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'l',
|
|
|
- val: [0, 100]
|
|
|
- }],
|
|
|
+ val: [790, 85]
|
|
|
+ } ],
|
|
|
|
|
|
[{
|
|
|
type: 'm',
|
|
@@ -96,12 +94,6 @@ export default {
|
|
|
}, {
|
|
|
type: 'l',
|
|
|
val: [0, 420]
|
|
|
- }, {
|
|
|
- type: 'm',
|
|
|
- val: [35, 400]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [35, 110]
|
|
|
} ],
|
|
|
|
|
|
[{
|
|
@@ -110,65 +102,14 @@ export default {
|
|
|
}, {
|
|
|
type: 'l',
|
|
|
val: [1045, 626]
|
|
|
- }],
|
|
|
- // 窗户1
|
|
|
- [{
|
|
|
- type: 'm',
|
|
|
- val: [110, 150]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [110, 350]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [305, 350]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [305, 150]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [110, 150]
|
|
|
- }],
|
|
|
- // 窗户2
|
|
|
- [{
|
|
|
- type: 'm',
|
|
|
- val: [440, 150]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [438, 360]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [540, 362]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [540, 150]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [440, 150]
|
|
|
- }],
|
|
|
- // 门
|
|
|
- [{
|
|
|
- type: 'm',
|
|
|
- val: [635, 150]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [630, 423]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [765, 428]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [770, 150]
|
|
|
- }, {
|
|
|
- type: 'l',
|
|
|
- val: [635, 150]
|
|
|
}]
|
|
|
]
|
|
|
|
|
|
let testArr2 = []
|
|
|
- lineArr2.forEach(() => {
|
|
|
+ let tempA = lineArr2.concat(lineTxt)
|
|
|
+ tempA.forEach(() => {
|
|
|
testArr2.push([])
|
|
|
})
|
|
|
-
|
|
|
// 这里存放数据
|
|
|
return {
|
|
|
realWidth: 1091,
|
|
@@ -321,9 +262,12 @@ export default {
|
|
|
start (newVal) {
|
|
|
if (newVal) {
|
|
|
this.index = 0
|
|
|
- this.testArr2 = this.testArr2.map(item => {
|
|
|
+ let t = this.lineArr2.concat(this.lineTxt)
|
|
|
+ this.testArr2 = null
|
|
|
+ this.testArr2 = t.map(item => {
|
|
|
return []
|
|
|
})
|
|
|
+
|
|
|
this.animated()
|
|
|
} else {
|
|
|
this.init()
|
|
@@ -333,10 +277,13 @@ export default {
|
|
|
methods: {
|
|
|
animated () {
|
|
|
let drawTxt = () => {
|
|
|
- this.ctx.font = 'bold 22px Arial'
|
|
|
+ this.ctx.font = 'normal 16px Arial'
|
|
|
this.ctx.textAlign = 'center'
|
|
|
this.ctx.textBaseline = 'bottom'
|
|
|
this.ctx.fillStyle = '#fff'
|
|
|
+ this.ctx.strokeStyle = '#1fe4dc'
|
|
|
+ this.ctx.lineWidth = 1
|
|
|
+
|
|
|
this.lineTxt.forEach(item => {
|
|
|
this.ctx.fillText(item.val, item.posi[0], item.posi[1])
|
|
|
})
|
|
@@ -355,13 +302,20 @@ export default {
|
|
|
this.imgHeight * this.devicePixelRatio
|
|
|
)
|
|
|
this.ctx.strokeStyle = '#1fe4dc'
|
|
|
- this.ctx.lineWidth = 5
|
|
|
+ this.ctx.lineWidth = 2
|
|
|
this.ctx.beginPath()
|
|
|
|
|
|
- arr.forEach(item => {
|
|
|
+ arr.forEach((item, index) => {
|
|
|
item.forEach(i => {
|
|
|
if (i.type === 'm') {
|
|
|
this.ctx.moveTo(i.val[0], i.val[1])
|
|
|
+ this.ctx.stroke()
|
|
|
+ this.ctx.beginPath()
|
|
|
+ if (index < myArr.length) {
|
|
|
+ this.ctx.lineWidth = 2.5
|
|
|
+ } else {
|
|
|
+ this.ctx.lineWidth = 1
|
|
|
+ }
|
|
|
} else {
|
|
|
this.ctx.lineTo(i.val[0], i.val[1])
|
|
|
}
|
|
@@ -400,18 +354,59 @@ export default {
|
|
|
return arr
|
|
|
}
|
|
|
|
|
|
+ let getGuideArr = () => {
|
|
|
+ let arr = []
|
|
|
+ this.lineTxt.forEach(() => {
|
|
|
+ arr.push([])
|
|
|
+ })
|
|
|
+ let intervalX, intervalY
|
|
|
+ this.lineTxt.forEach((item, index) => {
|
|
|
+ item.guideLine.forEach((sub, idx) => {
|
|
|
+ let lt = this.lineTxt[index]['guideLine']
|
|
|
+ if (sub.type === 'm') {
|
|
|
+ arr[index].push(sub)
|
|
|
+ }
|
|
|
+ if (idx < lt.length - 1) {
|
|
|
+ if (lt[idx + 1]['type'] !== 'm') {
|
|
|
+ intervalX = (lt[idx + 1]['val'][0] - lt[idx]['val'][0]) / speed
|
|
|
+ intervalY = (lt[idx + 1]['val'][1] - lt[idx]['val'][1]) / speed
|
|
|
+ let i = 0
|
|
|
+ while (i <= speed) {
|
|
|
+ arr[index].push(Object.assign({}, sub, {
|
|
|
+ val: [lt[idx]['val'][0] + i * intervalX, lt[idx]['val'][1] + i * intervalY],
|
|
|
+ type: 'l'
|
|
|
+ }))
|
|
|
+ i++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ return arr
|
|
|
+ }
|
|
|
+
|
|
|
+ let guideArr = getGuideArr()
|
|
|
+
|
|
|
let myArr = getCutArr()
|
|
|
+ console.log(myArr)
|
|
|
|
|
|
let maxLength = 0
|
|
|
+ let guideLength = 0
|
|
|
+
|
|
|
myArr.forEach(item => {
|
|
|
maxLength = Math.max(item.length, maxLength)
|
|
|
})
|
|
|
+ guideArr.forEach(item => {
|
|
|
+ guideLength = Math.max(item.length, guideLength)
|
|
|
+ })
|
|
|
let draw = () => {
|
|
|
if (!this.start) {
|
|
|
return
|
|
|
}
|
|
|
- if (this.index === maxLength) {
|
|
|
- drawTxt()
|
|
|
+ if (this.index === maxLength + guideLength) {
|
|
|
+ setTimeout(() => {
|
|
|
+ drawTxt()
|
|
|
+ }, 300)
|
|
|
return
|
|
|
}
|
|
|
myArr.forEach((item, index) => {
|
|
@@ -419,9 +414,18 @@ export default {
|
|
|
item[this.index] && this.testArr2[index].push(item[this.index])
|
|
|
})
|
|
|
})
|
|
|
- this.index++
|
|
|
|
|
|
+ if (this.index >= maxLength) {
|
|
|
+ guideArr.forEach((item, index) => {
|
|
|
+ item.forEach((sub, idx) => {
|
|
|
+ item[this.index - maxLength] && this.testArr2[myArr.length + index].push(item[this.index - maxLength])
|
|
|
+ })
|
|
|
+ console.log(this.testArr2)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.index++
|
|
|
drawLine(this.testArr2)
|
|
|
+
|
|
|
requestAnimationFrame(draw)
|
|
|
}
|
|
|
draw()
|
|
@@ -438,43 +442,6 @@ export default {
|
|
|
this.imgWidth * this.devicePixelRatio,
|
|
|
this.imgHeight * this.devicePixelRatio
|
|
|
)
|
|
|
- // this.ctx.strokeStyle = '#1fe4dc'
|
|
|
- // this.ctx.lineWidth = 5
|
|
|
- // this.ctx.beginPath()
|
|
|
- // this.ctx.moveTo(0, 100)
|
|
|
- // this.ctx.lineTo(35, 110)
|
|
|
- // this.ctx.lineTo(35, 400)
|
|
|
- // this.ctx.moveTo(0, 420)
|
|
|
- // this.ctx.lineTo(35, 400)
|
|
|
- // this.ctx.lineTo(790, 430)
|
|
|
- // this.ctx.lineTo(790, 90)
|
|
|
- // this.ctx.lineTo(35, 110)
|
|
|
- // this.ctx.moveTo(790, 90)
|
|
|
- // this.ctx.lineTo(890, 0)
|
|
|
- // this.ctx.moveTo(790, 430)
|
|
|
- // this.ctx.lineTo(1045, 626)
|
|
|
-
|
|
|
- // // 窗口1
|
|
|
- // this.ctx.moveTo(110, 150)
|
|
|
- // this.ctx.lineTo(110, 350)
|
|
|
- // this.ctx.lineTo(305, 350)
|
|
|
- // this.ctx.lineTo(305, 150)
|
|
|
- // this.ctx.lineTo(110, 150)
|
|
|
-
|
|
|
- // // 窗口2
|
|
|
- // this.ctx.moveTo(440, 150)
|
|
|
- // this.ctx.lineTo(438, 360)
|
|
|
- // this.ctx.lineTo(540, 362)
|
|
|
- // this.ctx.lineTo(540, 150)
|
|
|
- // this.ctx.lineTo(440, 150)
|
|
|
-
|
|
|
- // // 门
|
|
|
- // this.ctx.moveTo(635, 150)
|
|
|
- // this.ctx.lineTo(630, 423)
|
|
|
- // this.ctx.lineTo(765, 428)
|
|
|
- // this.ctx.lineTo(770, 150)
|
|
|
- // this.ctx.lineTo(635, 150)
|
|
|
- // this.ctx.stroke()
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|