在html5 canvas
中可以指定lineCap
style用于行尾。
例如:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.lineCap="round"; // <-- here lineCap is specified
ctx.moveTo(20,20);
ctx.lineTo(200,20);
可能的选项有:对接(默认)、圆形、方形
。
我的问题是:
使用 fabric.js 创建 Line
时如何指定 lineCap
样式?
var line = new fabric.Line(
[0, 100, 200, 100],
{
strokeWidth: 5
// I presume some option should be specified here, but how is it should be called?
}
);
最佳答案
我找到了答案
将其发布在此处,因为从 Fabric.js 文档中看不出来:
var line = new fabric.Line(
[0, 100, 200, 100],
{
strokeWidth: 5,
strokeLineCap: "round" // <-- this makes 'round' line ends style
}
);
关于javascript - Fabric.js指定lineCap样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42053827/