在本文中,我們將使用中風財產在其中設置畫布線的筆觸顏色FabricJS。畫布線表示該線是可移動的,可以根據需要進行拉伸。此外,當涉及初始筆劃顏色,高度,寬度,填充顏色或筆劃寬度時,可以自定義該行。
為了使之成為可能,我們將使用一個名為FabricJS的JavaScript HTML5畫布庫。導入庫後,我們將在body標簽中創建一個畫布塊,其中將包含該行。此後,我們將初始化由FabricJS和設置畫布線的筆觸顏色使用中風屬性,並在畫布上渲染該行,如下所示。
用法:
fabric.line({ stroke:'string' });
參數:此屬性接受上述和以下描述的單個參數:
- stroke :它指定畫布線的筆觸顏色。它包含一個字符串值。
範例1:
HTML
<!DOCTYPE html>
<html>
<head>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.6.2/fabric.min.js">
</script>
</head>
<body>
<h1>fabric.js | line stroke property</h1>
<canvas id="canvas" width="600" height="200"
style="border:1px solid #000000;">
</canvas>
<script>
var canvas = new fabric.Canvas("canvas");
var line = new fabric.Line([150, 10, 220, 150], {
stroke:'red',
});
canvas.add(line);
</script>
</body>
</html>
輸出:
相關用法
- CSS stroke-width用法及代碼示例
- CSS stroke-linecap用法及代碼示例
- CSS stroke-opacity用法及代碼示例
- CSS stroke-dashoffset用法及代碼示例
- CSS stroke-dasharray用法及代碼示例
- CSS stroke-linejoin用法及代碼示例
- CSS stroke-miterlimit用法及代碼示例
- Fabric.js Text stroke屬性用法及代碼示例
- Fabric.js Circle stroke屬性用法及代碼示例
- Fabric.js Rect stroke屬性用法及代碼示例
- Fabric.js Triangle stroke屬性用法及代碼示例
- Fabric.js Ellipse stroke屬性用法及代碼示例
- Fabric.js Polyline stroke屬性用法及代碼示例
- CSS stroke-color屬性用法及代碼示例
- Fabric.js Polygon stroke屬性用法及代碼示例
- Fabric.js Textbox stroke屬性用法及代碼示例
- Fabric.js Path stroke屬性用法及代碼示例
- Fabric.js Group stroke屬性用法及代碼示例
- HTML canvas stroke()用法及代碼示例
- p5.js stroke()用法及代碼示例
- Node.js GM stroke()用法及代碼示例
注:本文由純淨天空篩選整理自taran910大神的英文原創作品 Fabric.js line stroke Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。