添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
lineStyle (x1, y1, x2, y2, lineWidth = 4, color = 'black') {
    let rectX = x1 < x2 ? x1 : x2;
    let rectY = y1 < y2 ? y1 : y2;
    let rectWidth = Math.abs(x1 - x2);
    let rectHeight = Math.abs(y1 - y2);
    //弦长
    let stringWidth = Math.ceil(Math.sqrt((rectWidth * rectWidth) + (rectHeight * rectHeight)));
    let xPad = (rectWidth - stringWidth) / 2;
    let yPad = (rectHeight - lineWidth) / 2;
    let radNum = Math.atan2((y1 - y2), (x1 - x2));
    return `
        position: absolute;
        width: ${ stringWidth }px;
        height: ${ lineWidth }px;
        background-color: ${ color };
        transform: translate(${ rectX + xPad }px, ${ rectY + yPad }px) rotate(${ radNum }rad);