我算的角度有点不对,那个拉杆可以控制弧形的弯曲程度,但是坐标和角度都有点偏差,求助大佬
这是相关的代码
var r = 100;
let txt = this.selectedLayer.text;
var arcStrength = this.selectedLayer.arcStrength / 2;
this.selectedLayer.style.width = r * 2 + this.selectedLayer.style.fontSize / 2 + 15;
this.selectedLayer.style.height = r;
// 计算字符间距
if (this.selectedLayer.style.letterSpacing == 0) {
this.selectedLayer.style.letterSpacing = 0.2;
}
for (var i = 0; i < txt.length; i++) {
var du = (i * this.selectedLayer.style.letterSpacing - ((txt.length - 1) * this.selectedLayer.style.letterSpacing) / 2);
if (texStelection == 1) {
//180度上弧文字
var x1 = (r + arcStrength * 0.5) + (r + arcStrength * 0.5) * Math.sin(du);
var y1 = (r - arcStrength * 0.5) + -(r - arcStrength * 0.5) * Math.cos(du);
// var x1 = r +r * Math.sin(du);
// var y1 = r + -r * Math.cos(du);
//旋转角度
var x = 360 / txt.length * du;
this.selectedLayer.text[i].left = x1;
this.selectedLayer.text[i].top = y1;
arcXMax = Math.max(arcXMax, this.selectedLayer.text[i].left);
arcXMin = Math.min(arcXMin, this.selectedLayer.text[i].left);
arcYMax = Math.max(arcYMax, this.selectedLayer.text[i].top);
arcYMin = Math.min(arcYMin, this.selectedLayer.text[i].top);
this.selectedLayer.text[i].rotate = (du) * (360 / 6.28) / 100 * (-arcStrength + 100)
this.selectedLayer.style.height = arcYMax - arcYMin + this.selectedLayer.style.fontSize * 1.25;