
在本教程中,我们将学习如何使用 FabricJS 设置圆的垂直比例因子。圆形是 FabricJS 提供的各种形状之一。为了创建一个圆圈,我们必须创建一个 Fabric.Circle 类的实例并将其添加到画布中。正如我们可以指定圆形对象在画布中的位置、颜色、不透明度和尺寸一样,我们也可以设置圆形对象的垂直比例。这可以通过使用 scaleY 属性来完成。
语法
new fabric.Circle({ scaleY : Number }: Object)参数
选项(可选) - 此参数是一个对象 为我们的圈子提供额外的定制。使用此参数,可以更改与以scaleY为属性的对象相关的颜色、光标、描边宽度和许多其他属性等属性。
选项键
scaleY - 此属性接受数字值。分配的值决定垂直对象比例因子。默认值为1。
示例1
不使用scaleY时的默认外观
让我们看一个在不使用 scaleY 属性时显示圆形对象外观的示例。默认情况下,圆形对象的垂直比例因子为 1。scaleY 确定沿 Y 轴调整对象大小的变换。
Setting the vertical scale factor of a Circle using FabricJS
Notice the vertical scale factor of the circle. Here we have not used the scaleY property, but by default, it is set to 1.
示例 2
将 scaleY 属性作为键传递
在此示例中,我们传递 scaleY 属性作为键,值为2。这意味着圆形对象在垂直方向的比例因子加倍。
Setting the vertical scale factor of a Circle using FabricJS
Notice the vertical scale factor of the circle. Here we have set scaleY at 2, so the object appears elongated on the Y-axis.









