2017-02-05 36 views
0

html5 canvas中可以爲行結束指定lineCap styleFabric.js指定lineCap樣式

例如爲:

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); 

可能的選項:butt (Default), round, square

我的問題是:
創建Linefabric.js時如何指定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? 
    } 
); 

回答

1

我找到了答案

在這裏張貼,因爲它不是從fabric.js文檔顯而易見的:

var line = new fabric.Line(
    [0, 100, 200, 100], 
    { 
     strokeWidth: 5, 
     strokeLineCap: "round" // <-- this makes 'round' line ends style 
    } 
);