Fabric.js 是一個用於處理畫布的 JavaScript 庫。畫布 ActiveSelection 是用於創建 ActiveSelection 實例的 fabric.js 類之一。畫布 ActiveSelection 表示 ActiveSelection 是可移動的,可以根據需要進行拉伸。在本文中,我們將使用 moveCursor 屬性來設置移動時光標的樣式。
方法:首先導入fabric.js庫。導入庫後,在包含 ActiveSelection 的 body 標簽中創建一個畫布塊。之後,初始化 Fabric.JS 提供的 Canvas 和 ActiveSelection 類的實例,並使用 moveCursor 屬性設置移動時光標的樣式。
用法:
fabric.ActiveSelection(ActiveSelection, { moveCursor:string });
參數:該函數采用上述和以下描述的單個參數:
- moveCursor:此參數采用字符串值。
例:本示例使用 FabricJS 設置畫布 ActiveSelection 的 moveCursor 屬性,如下例所示:
HTML
<!DOCTYPE html>
<html>
<head>
<!-- FabricJS CDN -->
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/fabric.js/3.6.2/fabric.min.js">
</script>
</head>
<body>
<div style="text-align:center;width:400px;">
<h1 style="color:green;">
GeeksforGeeks
</h1>
<b>
Fabric.js | ActiveSelection moveCursor Property
</b>
</div>
<div style="text-align:center;">
<canvas id="canvas" width="500" height="500"
style="border:1px solid green;">
</canvas>
</div>
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200327230544/g4gicon.png"
width="100" height="100"
id="my-image" style="display:none;">
<script>
var canvas = new fabric.Canvas("canvas");
// Initiate a Rect instance
var rectangle = new fabric.Rect({
width:200,
height:100,
});
canvas.add(rectangle);
var geek = new fabric.IText('GeeksforGeeks', {
});
canvas.add(geek);
canvas.centerObject(geek);
var gfg = new fabric.ActiveSelection(
canvas.getObjects(), {
moveCursor:'pointer'
});
canvas.setActiveObject(gfg);
canvas.requestRenderAll();
canvas.centerObject(gfg);
</script>
</body>
</html>
輸出:
相關用法
- Fabric.js Rect moveCursor屬性用法及代碼示例
- Fabric.js Triangle moveCursor屬性用法及代碼示例
- Fabric.js Polygon moveCursor屬性用法及代碼示例
- Fabric.js Path moveCursor屬性用法及代碼示例
- Fabric.js Textbox moveCursor屬性用法及代碼示例
- Fabric.js Polyline moveCursor屬性用法及代碼示例
- Fabric.js line moveCursor屬性用法及代碼示例
- Fabric.js Circle moveCursor屬性用法及代碼示例
- Fabric.js Ellipse moveCursor屬性用法及代碼示例
- Fabric.js Image moveCursor屬性用法及代碼示例
- Fabric.js Text moveCursor屬性用法及代碼示例
- Fabric.js Group moveCursor屬性用法及代碼示例
- Node.js writeStream.moveCursor()用法及代碼示例
- Fabric.js ActiveSelection strokeUniform屬性用法及代碼示例
- Fabric.js ActiveSelection transparentCorners屬性用法及代碼示例
- Fabric.js ActiveSelection type屬性用法及代碼示例
- Fabric.js ActiveSelection subTargetCheck屬性用法及代碼示例
- Fabric.js ActiveSelection useSetOnGroup屬性用法及代碼示例
- Fabric.js ActiveSelection angle屬性用法及代碼示例
- Fabric.js ActiveSelection lockMovementY屬性用法及代碼示例
- Fabric.js ActiveSelection lockMovementX屬性用法及代碼示例
- Fabric.js ActiveSelection objectCaching屬性用法及代碼示例
- Fabric.js ActiveSelection perPixelTargetFind屬性用法及代碼示例
- Fabric.js ActiveSelection paintFirst屬性用法及代碼示例
注:本文由純淨天空篩選整理自dheerchanana08大神的英文原創作品 Fabric.js ActiveSelection moveCursor Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。