在本文中,我們將了解如何設置均勻的筆劃寬度圖像。 canvas圖像是用於創建圖像實例的fabric.js類之一。畫布圖像表示圖像是可移動的,可以根據需要進行拉伸。 strokeUniform用於鎖定均勻筆劃。
用法:
fabric.Image(image, {
strokeUniform:boolean
});
參數:此函數采用上述和以下描述的單個參數:
- strokeUniform :此參數采用布爾值來鎖定畫布圖像的均勻筆觸。
例:此示例使用FabricJS設置畫布圖像的strokeUniform屬性,如下例所示:
HTML
<!DOCTYPE html>
<html>
<head>
<!-- Adding the FabricJS library -->
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.6.2/fabric.min.js">
</script>
</head>
<body>
<h1 style="color:green;">
GeeksforGeeks
</h1>
<b>
Fabric.js | Image strokeUniform Property
</b>
<canvas id="canvas" width="400" height="300"
style="border:2px solid #000000">
</canvas>
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200327230544/g4gicon.png"
width="100" height="100" id="my-image"
style="display:none;">
<br>
<script>
// Creating the instance of canvas object
var canvas = new fabric.Canvas("canvas");
// Getting the image
var img = document.getElementById('my-image');
// Creating the image instance
var geeks = new fabric.Image(img, {
stroke:"green",
strokeUniform:false
});
canvas.add(geeks);
canvas.centerObject(geeks);
</script>
</body>
</html>
輸出:
相關用法
- Fabric.js Ellipse strokeUniform屬性用法及代碼示例
- Fabric.js Rect strokeUniform屬性用法及代碼示例
- Fabric.js Polygon strokeUniform屬性用法及代碼示例
- Fabric.js Textbox strokeUniform屬性用法及代碼示例
- Fabric.js Path strokeUniform用法及代碼示例
- Fabric.js Circle strokeUniform屬性用法及代碼示例
- Fabric.js Group strokeUniform屬性用法及代碼示例
- CSS list-style-image用法及代碼示例
- CSS border-image-slice用法及代碼示例
- CSS border-image-outset用法及代碼示例
- CSS border-image-repeat用法及代碼示例
- CSS border-image用法及代碼示例
- CSS border-image-width用法及代碼示例
- CSS background-image用法及代碼示例
- CSS border-image-source用法及代碼示例
- HTML Input Image src用法及代碼示例
- HTML Input Image width用法及代碼示例
- HTML Input Image type用法及代碼示例
- HTML Input Image name用法及代碼示例
注:本文由純淨天空篩選整理自dheerchanana08大神的英文原創作品 Fabric.js Image strokeUniform Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。