在本文中,我們將看到如何使用Fabric.js設置畫布Textbox的垂直傾斜。 Fabric.js中的文本框是可移動的,可以根據需要進行拉伸。此外,當涉及初始筆劃顏色,高度,寬度,填充顏色或筆劃寬度時,可以自定義文本框。
為了使之成為可能,我們將使用一個名為Fabric.js的JavaScript庫。導入庫後,我們將在包含文本框的body標簽中創建一個canvas塊。此後,我們將初始化Fabric.js提供的Canvas和Textbox的實例,使用skewY屬性設置垂直偏斜,並在畫布上呈現文本框,如下麵的示例所示。
用法:
fabric.Textbox('text', { skewY:number });
參數:該函數接受如上所述和以下描述的單個參數:
- skewY:它以度為單位指定垂直傾斜角。
例:本示例使用Fabric.js設置文本框的垂直傾斜。
HTML
<html>
<head>
<!-- Adding the FabricJS library -->
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/fabric.js/4.3.0/fabric.min.js">
</script>
</head>
<body>
<h1 style="color:green;">
GeeksforGeeks
</h1>
<h3>
Fabric.js | Textbox skewY Property
</h3>
<canvas id="canvas" width="600" height="300"
style="border:1px solid #000000">
</canvas>
<script>
// Initiate a Canvas instance
var canvas = new fabric.Canvas("canvas");
// Create a new Textbox instance
var text = new fabric.Textbox(
'A Computer Science Portal', {
width:500,
skewY:200
});
// Render the Textbox in canvas
canvas.add(text);
canvas.centerObject(text);
</script>
</body>
</html>
輸出:
相關用法
- Fabric.js Circle skewY屬性用法及代碼示例
- Fabric.js Rect skewY屬性用法及代碼示例
- Fabric.js Triangle skewY屬性用法及代碼示例
- Fabric.js Ellipse skewY屬性用法及代碼示例
- Fabric.js Polyline skewY屬性用法及代碼示例
- Fabric.js Polygon skewY屬性用法及代碼示例
- Fabric.js line skewY屬性用法及代碼示例
- Fabric.js Path skewY屬性用法及代碼示例
- Fabric.js Image skewY屬性用法及代碼示例
- Fabric.js Group skewY屬性用法及代碼示例
- PHP ImagickDraw skewY()用法及代碼示例
- CSS skewY()用法及代碼示例
- Fabric.js Textbox borderOpacityWhenMoving屬性用法及代碼示例
- Fabric.js Textbox borderScaleFactor屬性用法及代碼示例
- Fabric.js Textbox centeredRotation屬性用法及代碼示例
- Fabric.js Textbox centeredScaling屬性用法及代碼示例
- Fabric.js Textbox charSpacing屬性用法及代碼示例
- Fabric.js Textbox cornerColor屬性用法及代碼示例
- Fabric.js Textbox cornerSize屬性用法及代碼示例
- Fabric.js Textbox fontFamily屬性用法及代碼示例
- Fabric.js Textbox fontSize屬性用法及代碼示例
- Fabric.js Textbox fontStyle屬性用法及代碼示例
- Fabric.js Textbox fontWeight屬性用法及代碼示例
- Fabric.js Textbox hasBorders屬性用法及代碼示例
注:本文由純淨天空篩選整理自blalverma92大神的英文原創作品 Fabric.js Textbox skewY Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。