主体代码参考:https://blog.csdn.net/qq_41211900/article/details/89957144
关键调整代码部份:
函数:calcBethelLine
let n = 5;
let p5 = [
[1, 0, 0],
[0.5625,0.375, 0.0625],
[0.25, 0.5, 0.25],
[0.0625,0.375, 0.5625],
[0, 0, 1]
];
let point = [];
for (let i = 0; i < n; i++) {
//let t = i / (n - 1);
//let x = (1 - t) * (1 - t) * x0 + 2 * t * (1 - t) * x1 + t * t * x2;
//let y = (1 - t) * (1 - t) * y0 + 2 * t * (1 - t) * y1 + t * t * y2;
//仅针对n=5的参数代入(替换以上3行代码)
let x = p5[i][0] * x0 + p5[i][1] * x1 + p5[i][2] * x2;
let y = p5[i][0] * y0 + p5[i][1] * y1 + p5[i][2] * y2;
let r = lastRadius + (this.data.radius - lastRadius) / n * i;
point.push({ x: x, y: y, r: r });
if (point.length == 3) {
let a = this.ctaCalc(point[0].x, point[0].y, point[0].r, point[1].x, point[1].y, point[1].r, point[2].x, point[2].y, point[2].r);
a[0].color = this.data.lineColor;
// let bethelPoint = this.data.bethelPoint;
// console.log(a)
// console.log(this.data.bethelPoint)
// bethelPoint = bethelPoint.push(a);
this.bethelDraw(a, 1);
point = [{ x: x, y: y, r: r }];
}
}
函数:ctaCalc
/*以下代码仅调整精度,影响计算效率,删除
a[0].mx = a[0].mx.toFixed(1);
a[0].mx = parseFloat(a[0].mx);
a[0].my = a[0].my.toFixed(1);
a[0].my = parseFloat(a[0].my);
for (let i = 1; i < a.length; i++) {
a[i].c1x = a[i].c1x.toFixed(1);
a[i].c1x = parseFloat(a[i].c1x);
a[i].c1y = a[i].c1y.toFixed(1);
a[i].c1y = parseFloat(a[i].c1y);
a[i].c2x = a[i].c2x.toFixed(1);
a[i].c2x = parseFloat(a[i].c2x);
a[i].c2y = a[i].c2y.toFixed(1);
a[i].c2y = parseFloat(a[i].c2y);
a[i].ex = a[i].ex.toFixed(1);
a[i].ex = parseFloat(a[i].ex);
a[i].ey = a[i].ey.toFixed(1);
a[i].ey = parseFloat(a[i].ey);
}*/
函数:uploadScaleMove
if (e.type != 'touchmove') return false;
//由于手机/平板的计算能力差异,仅获取1/5的点数
this.data.pointCount ++;
if(this.data.pointCount % 5 != 0){
return false;
}