Javascript 画布标记拱形文本

Javascript 画布标记拱形文本,javascript,html,math,canvas,Javascript,Html,Math,Canvas,我正在编写一些在画布上沿弧线弯曲文本的代码,我让顶部尽可能靠近它,但我还需要在底部添加一些向上弯曲的文本。我想不出来。非常感谢您的帮助 此外,这里还有一个链接指向我正在制作的小提琴: var text='你好,我就是JS', len=text.length, //圆圈的覆盖范围 角度=Math.PI*.7, centerX=275, centerY=250, 半径=200, context=document.getElementById('canvas').getContext('2d'), n

我正在编写一些在画布上沿弧线弯曲文本的代码,我让顶部尽可能靠近它,但我还需要在底部添加一些向上弯曲的文本。我想不出来。非常感谢您的帮助

此外,这里还有一个链接指向我正在制作的小提琴:

var
text='你好,我就是JS',
len=text.length,
//圆圈的覆盖范围
角度=Math.PI*.7,
centerX=275,
centerY=250,
半径=200,
context=document.getElementById('canvas').getContext('2d'),
n=0;
//格式化文本
context.font='40px Arial';
context.textAlign='center';
context.fillStyle='black';
context.strokeStyle='blue';
context.lineWidth=2;
//保存当前状态
context.save();
//移动指针
上下文。翻译(centerX、centerY);
//轮换
旋转(-1*角度/2);
旋转(-1*(角度/透镜)/2);
//在字符串上循环
对于(;n
好的,我设法做到了。这是两个很小的变化

它包括在循环中反转平移和反转输入字符串。完美的

这是工作代码。(注意这两个小改动)和是一个链接

var
        text = 'Hello world, Im just JS'.split('').reverse().join(''),
        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();
var
text='helloworld,imjustjs'.split('').reverse().join(''),
len=text.length,
//圆圈的覆盖范围
角度=Math.PI*.7,
centerX=275,
centerY=250,
半径=200,
context=document.getElementById('canvas').getContext('2d'),
n=0;
//格式化文本
context.font='40px Arial';
context.textAlign='center';
context.fillStyle='black';
context.strokeStyle='blue';
context.lineWidth=2;
//保存当前状态
context.save();
//移动指针
上下文。翻译(centerX、centerY);
//轮换
旋转(-1*角度/2);
旋转(-1*(角度/透镜)/2);
//在字符串上循环
对于(;n
好的,我设法做到了。这是两个很小的变化

它包括在循环中反转平移和反转输入字符串。完美的

这是工作代码。(注意这两个小改动)和是一个链接

var
        text = 'Hello world, Im just JS'.split('').reverse().join(''),
        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();
var
text='helloworld,imjustjs'.split('').reverse().join(''),
len=text.length,
//圆圈的覆盖范围
角度=Math.PI*.7,
centerX=275,
centerY=250,
半径=200,
context=document.getElementById('canvas').getContext('2d'),
n=0;
//格式化文本
context.font='40px Arial';
context.textAlign='center';
context.fillStyle='black';
context.strokeStyle='blue';
context.lineWidth=2;
//保存当前状态
context.save();
//移动指针
上下文。翻译(centerX、centerY);
//轮换
旋转(-1*角度/2);
旋转(-1*(角度/透镜)/2);
//在字符串上循环
对于(;n
我以为这是重复的,不是。我以为这是重复的,不是。