如何使用 FabricJS 禁用 Circle 的居中缩放?

WBOY
发布: 2023-09-07 17:13:02
转载
1358 人浏览过

如何使用 FabricJS 禁用 Circle 的居中缩放?

在本教程中,我们将学习如何使用 FabricJS 禁用 Circle 的居中缩放。圆形是 FabricJS 提供的各种形状之一。为了创建一个圆圈,我们必须创建一个 Fabric.Circle 类的实例并将其添加到画布中。通过控件进行缩放时,为centeredScaling属性分配一个真值,使用中心作为对象的变换原点。

语法

new fabric.Circle({ centeredScaling: Boolean }: Object)
登录后复制

参数

  • 选项(可选)- 此参数是一个提供额外自定义的对象到我们的圈子。使用此参数,可以更改与centeredScaling属性相关的对象的颜色、光标、描边宽度等属性

选项键

  • centeredScaling- 此属性接受布尔值价值。当此属性为True时,对象使用中心作为变换原点。

示例 1

centeredScaling作为键传递并为其分配一个“true”值

让我们看一段代码,看看圆形对象在centeredScaling时的行为

em> 属性已启用。当我们放大对象时,变换的原点是圆心。

     
  

Disabling the centered scaling of circle using FabricJs

Select the object and stretch it by holding one of its controlling corners. You will notice the circle scales up uniformly from its center. This is the default behavior. Here we have not used the centeredScaling property but by default, it is set to True.

登录后复制

示例 2

禁用 centeredScaling 属性

我们可以通过为其指定一个 false 值来禁用centeredScaling属性。它将迫使圆不再使用圆心作为变换中心。这是一个代码来证明这一点

     
  

Disabling the centered scaling of circle using FabricJs

Select the object and stretch it by holding one of its controlling corners. You will notice that the circle is no longer scaling up uniformly from its center. Here we have used the centeredScaling property and set it False.

登录后复制

以上是如何使用 FabricJS 禁用 Circle 的居中缩放?的详细内容。更多信息请关注PHP中文网其他相关文章!

来源:tutorialspoint.com
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!