在本教程中,我们将学习如何使用 FabricJS拉直图像对象。 我们可以通过创建fabric.Image的实例来创建一个Image对象。既然是一个 FabricJS 的基本元素,我们还可以通过应用轻松自定义它 诸如角度、不透明度等属性。为了拉直图像对象,我们使用 拉直方法。
straighten(): fabric.Object
让我们看一个代码示例,看看当 straighten 时我们的 Image 对象看起来如何 方法没有被使用。 straighten 方法通过将对象从其所在位置旋转来straighten 当前角度为 0、90、180 或 270 等,具体取决于更接近的角度。角度 属性设置对象的旋转角度(以度为单位)。在这里,我们指定了 角度为 45。但是由于我们没有应用 straighten 属性,所以旋转角度 将保持 45 度。
Passing the angle property a value without using the straighten method
You can see that the Image object has an angle of 45 degrees
让我们看一个代码示例,看看当 straighten 时 Image 对象是什么样子的 方法与角度属性结合使用。虽然我们已经设定了角度 旋转为 45 度,我们的图像对象将通过将其旋转回 0 来拉直 degree as we have used the 拉直方法。
Using the straighten method
You can see that the angle of rotation is 0 degree for the image object
위 내용은 如何使用 FabricJS 拉直 Image 对象?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!