Ai
15 Star 177 Fork 64

德育处主任/Fabric.js学习资料(中文教程)

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
centeredScaling.html 988 Bytes
一键复制 编辑 原始数据 按行查看 历史
德育处主任 提交于 2022-08-21 00:26 +08:00 . 中心点缩放
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>centeredScaling</title>
<style>
#canvasBox {
border: 1px solid #ccc;
}
</style>
</head>
<body>
<canvas id="canvasBox" width="600" height="400"></canvas>
<script src="../../script/fabric.js"></script>
<script>
// 如果 centeredScaling 为 false(默认),需要按alt键才能以中心点作为缩放原点
let canvas = new fabric.Canvas('canvasBox', {
centeredScaling: true // 全局所有元素都生效
})
let rect = new fabric.Rect({
width: 100,
height: 60,
left: 100,
top: 100,
fill: 'pink',
// centeredScaling: true // 单个元素生效
})
let circle = new fabric.Circle({
radius: 50,
left: 300,
top: 80,
fill: 'green'
})
canvas.add(rect)
canvas.add(circle)
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/k21vin/fabricjs-demo.git
git@gitee.com:k21vin/fabricjs-demo.git
k21vin
fabricjs-demo
Fabric.js学习资料(中文教程)
master

搜索帮助