我正在编写一些在画布上沿弧线弯曲文本的代码,我让顶部尽可能接近,但我还需要在底部添加一些向上弯曲的文本。我搞不定。任何帮助是极大的赞赏。
另外,这是我正在研究的小提琴的链接:这里
var
text = 'Hello world, Im just JS',
len = text.length,
// The coverage of the circle
angle = Math.PI * .7,
centerX = 275,
centerY = 250,
radius = 200,
context = document.getElementById('canvas').getContext('2d'),
n = 0;
// Format the text
context.font = '40px Arial';
context.textAlign = 'center';
context.fillStyle = 'black';
context.strokeStyle = 'blue';
context.lineWidth = 2;
// Save the current state
context.save();
// Move our pointer
context.translate(centerX, centerY);
// Rotate
context.rotate(-1 * angle / 2);
context.rotate(-1 * (angle / len) / 2);
// Loop over the string
for(; n < len; n += 1) {
context.rotate(angle / len);
context.save();
context.translate(0, -1 * radius);
context.fillText(text[n], 0, 0);
context.strokeText(text[n], 0, 0);
context.restore();
};
// Restore the canvas state
context.restore();