Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let textSum = 0 // a-z0-9 为 1,其他为 2
for (let i = 0; i < d.text.length; ++i) {
if (d.text[i].match(/\w/)) {
textSum += 1
} else textSum += 2
}
if (!opt.fontSize && !d.fontSize) {
fontSize = fontSize * textSum / 2 > dLen * opt.textBottomPercentage ? dLen * opt.textBottomPercentage / textSum * 2 : fontSize
}
const text = svg.text(opt.center[0], opt.pos[1] + opt.radius - (r * opt.textBottomPercentage * Snap.cos(self[deg] / 2)) - fontSize, d.text)
text.attr({
fill: d.fontColor ? d.fontColor : opt.color.prizeFont,
fontSize: opt.fontSize ? opt.fontSize : fontSize
})
const box = text.node.getBoundingClientRect()
text.transform(new Snap.Matrix().translate(-Math.round(box.width / 2), 2))
const g = svg.g(pie, text).transform(new Snap.Matrix().rotate(self[deg] * Number(i), opt.center[0], opt.center[1]))
self[turntable].add(g)
}
}
Persona.prototype.onEnter = function() {
if (this.mShouldPopIn) {
this.mShouldPopIn = false;
this.mContainer.attr({display: 'block'});
this.mContainer.scale = 0.1;
this.mContainer.animate({transform: new Snap.Matrix()}, this.mPersonaOptions.config.transitionsDuration, mina.backout);
}
/* if this persona was set to be out of visual focus before it was added to the paper, apply the filter */
if (!this.mInVisualFocus) {
this._applyVisualFilter(1);
}
};
let textSum = 0
for (let i = 0; i < opt.buttonText.length; ++i) {
if (opt.buttonText[i].match(/\w/)) {
textSum += 1
} else textSum += 2
}
if (!opt.buttonFontSize) {
fontSize = fontSize * textSum / 2 > maxLen ? maxLen / textSum * 2 : fontSize
}
text = svg.text(center[0], center[1], opt.buttonText)
text.attr({
fill: opt.color.buttonFont,
fontSize: opt.buttonFontSize ? opt.buttonFontSize : fontSize
})
const box = text.node.getBoundingClientRect()
text.transform(new Snap.Matrix().translate(-Math.round(box.width / 2), 2))
}
self[button] = svg.g(b, text)
}
Node.prototype._setScale = function (scale) {
if (scale !== this.mScale) {
this.mScale = scale;
var matrix = new Snap.Matrix();
matrix.e = this.mPosition.x;
matrix.f = this.mPosition.y;
matrix.scale(scale);
this.transform(matrix);
}
};
if (d.text[i].match(/\w/)) {
textSum += 1
} else textSum += 2
}
if (!opt.fontSize && !d.fontSize) {
fontSize = fontSize * textSum / 2 > dLen * opt.textBottomPercentage ? dLen * opt.textBottomPercentage / textSum * 2 : fontSize
}
const text = svg.text(opt.center[0], opt.pos[1] + opt.radius - (r * opt.textBottomPercentage * Snap.cos(self[deg] / 2)) - fontSize, d.text)
text.attr({
fill: d.fontColor ? d.fontColor : opt.color.prizeFont,
fontSize: opt.fontSize ? opt.fontSize : fontSize
})
const box = text.node.getBoundingClientRect()
text.transform(new Snap.Matrix().translate(-Math.round(box.width / 2), 2))
const g = svg.g(pie, text).transform(new Snap.Matrix().rotate(self[deg] * Number(i), opt.center[0], opt.center[1]))
self[turntable].add(g)
}
}