【发布时间】:2018-08-20 02:41:34
【问题描述】:
我已经使用下面的代码行绘制了曲线,我需要绘制一个箭头。为此,我需要绘制 2 条带某个角度的线并将其旋转某个角度。画起来非常混乱。我正在关注为箭头提供的link 中的帖子。
.html
<canvas id = "canvas" width = "100px" height = "120px"></canvas>
.ts
arrow({ x: 10, y: 10 }, { x: 100, y: 140 }, 15); //function called on reload.
function arrow(p1, p2, size) {
var angle = Math.atan2((p2.y - p1.y), (p2.x - p1.x));
//curve line
ctx.strokeStyle = 'white';
ctx.beginPath();
ctx.lineWidth=3;
ctx.moveTo(40,0);
ctx.bezierCurveTo(30, 0, -70, 75, 100, 150);
ctx.lineTo(100,120)
ctx.stroke();
//to draw a triangle ??
}
【问题讨论】:
标签: javascript html css canvas