javascript - 如何在 HTML5 Canvas 中的两个文本对象之间绘制二次曲线?

标签 javascript html canvas bezier

每个科目的目标。

代码片段:

var canvas= document.getElementById('myCanvas');
var ctx= canvas.getContext('2d');   
canvas.width= 520;
canvas.height= 405;
ctx.font = "15pt Verdana";
ctx.lineWidth = 1;

// text 1
ctx.fillText("me and my dog puddie", 210, 90);  
// text 2
ctx.fillText("you and many many crazy nuts", 210, 130); 
// draw a quadratic bezier curved line between the these 2 text blocks
ctx.strokeStyle = "rgb(65,60,50)";
ctx.beginPath();
ctx.moveTo(210,100);
ctx.bezierCurve(230,250,130,160,160,100);
ctx.stroke();

/* outcome:
no line were drawn between these two text objects
*/

我对二次曲线的理解非常有限

最佳答案

换行

ctx.bezierCurve(230,250,130,160,160,100);

ctx.bezierCurveTo(230,250,130,160,160,100);

你应该可以开始了。

关于javascript - 如何在 HTML5 Canvas 中的两个文本对象之间绘制二次曲线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3299621/

相关文章:

javascript - 如何上传之前存储在LocalStorage中的图片?

javascript - Datatables iOS,Safari 根本不显示

javascript - 为什么 getBackgroundPage() 没有在 chrome.runtime 中为我定义?

javascript - 模板引擎中的 "with"和 "no with"

validation - 禁用 HTML5 表单元素的验证

javascript - 如何在 HTML Canvas 中以给定 Angular 找到距离给定坐标最近的坐标

javascript - 从 Canvas 获取图像数据

javascript/ajax登录系统

html - chrome/opera anchor 在添加 dom 元素后移开

Javascript - 将对象指向鼠标