如何使用 <v-rect> 组件移动矩形
要让矩形向左或向右移动,只需要修改矩形的'x'坐标即可。如果要向左移动,将'x'坐标减去一个固定值;如果要向右移动,将'x'坐标加上一个固定值。
例如,如果要向左移动50个单位,可以将代码修改为:
this.imgRect = {
x: minPoint.x - 50,
y: minPoint.y - dy * 1000 * this.rate,
width: dx * 1000 * this.rate,
height: dy * 1000 * this.rate,
dash: [10, 2],
stroke: 'white'
}
如果要向右移动50个单位,可以将代码修改为:
this.imgRect = {
x: minPoint.x + 50,
y: minPoint.y - dy * 1000 * this.rate,
width: dx * 1000 * this.rate,
height: dy * 1000 * this.rate,
dash: [10, 2],
stroke: 'white'
}
根据实际情况,你可以根据需要修改移动的单位和方向。
原文地址: https://www.cveoy.top/t/topic/fndt 著作权归作者所有。请勿转载和采集!