提交 5f168ac5 authored 作者: 王健's avatar 王健

缝隙

上级 75a63020
...@@ -111,10 +111,10 @@ export default { ...@@ -111,10 +111,10 @@ export default {
tableData: [ tableData: [
{ {
dataType: "裂缝", dataType: "裂缝",
startStake: "236512", startStake: "236012",
startStakeCenter: "10", startStakeCenter: "10",
endStake: "237512", endStake: "236022",
endStakeCenter: "30", endStakeCenter: "5",
dataHeight: "10", dataHeight: "10",
dataWidth: "0", dataWidth: "0",
}, },
...@@ -271,14 +271,20 @@ export default { ...@@ -271,14 +271,20 @@ export default {
// strokeStyle, // strokeStyle,
// }); // });
} else if (data.dataType === "裂缝") { } else if (data.dataType === "裂缝") {
// this.drowLine({ const startx =
// startx: 0, this.boxStartx + (data.startStake - this.startStake) * this.ratio;
// starty: this.center - this.lineHeight * (this.lineNumber / 2), const starty = this.center - data.startStakeCenter * this.ratio;
// endx: this.boxWidth, const endx =
// endy: this.center - this.lineHeight * (this.lineNumber / 2), this.boxStartx + (data.endStake - this.startStake) * this.ratio;
// lineWidth: 1, const endy = this.center - data.endStakeCenter * this.ratio;
// strokeStyle: "#000", this.drowGap({
// }); startx: startx,
starty: starty,
endx: endx,
endy: endy,
lineWidth: 1,
strokeStyle: "#000",
});
} }
}); });
}, },
...@@ -357,6 +363,32 @@ export default { ...@@ -357,6 +363,32 @@ export default {
this.ctx.stroke(); this.ctx.stroke();
this.ctx.closePath(); this.ctx.closePath();
}, },
drowGap(gap) {
const { startx, starty, endx, endy } = gap;
this.ctx.save();
this.ctx.setLineDash([]);
this.ctx.beginPath();
this.ctx.moveTo(startx, starty);
console.log(startx, starty);
// console.log(this.getRandom(startx, endx));
console.log(endx, endy);
// console.log(this.getRandom(starty, endy));
// this.ctx.lineTo(endx, endy);
for (var i = 0; i < 1; i++) {
this.ctx.quadraticCurveTo(
this.getRandom(startx, endx),
this.getRandom(starty, endy),
this.getRandom(startx, endx),
this.getRandom(starty, endy)
);
}
this.ctx.quadraticCurveTo(537, 236, endx, endy);
this.ctx.lineWidth = 4;
this.ctx.strokeStyle = "#000";
this.ctx.stroke();
this.ctx.closePath();
},
drowText() { drowText() {
this.ctx.font = "12px 微软雅黑"; this.ctx.font = "12px 微软雅黑";
this.ctx.fillStyle = "#000"; this.ctx.fillStyle = "#000";
...@@ -380,6 +412,11 @@ export default { ...@@ -380,6 +412,11 @@ export default {
const b = Math.floor(Math.random() * 255); const b = Math.floor(Math.random() * 255);
return "rgba(" + r + "," + g + "," + b + ",0.8)"; return "rgba(" + r + "," + g + "," + b + ",0.8)";
}, },
getRandom(min, max) {
return Math.floor(Math.random() * (max - min)) === min
? min + 1
: Math.floor(Math.random() * (max - min)) + min;
},
}, },
}; };
</script> </script>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论