JavaFX Shearing

Shearing is a kind of transformation which changes the slope of the object with respect to any of the axis. There are two Shear transformations that are X-shear and Y-shear. The X-shear transformation changes the X-coordinate values while the Y-shear changes the Y-coordinate values.

In both kind of shearing, only one coordinate changes the value while the other remains same. The following image shows the object after applying the X-shear transformation to it. The y-coordinate of the rectangle remain unchanged while the X-coordinate shifts by some factor.

In JavaFX, the class javafx.scene.transform.Shear represents the Shear Transformation.


JavaFX Shearing

Properties

The properties of the class along with the setter methods are described in the following table.

Property Description Setter Methods
pivotX It is a double type property. It represents the X coordinate of the shear pivot point. setPivotX(double value)
pivotY It is a double type property. It represents the Y coordinate of the shear pivot point. setPivotY(double value)
x It is a double type property. It represents the multiplier by which the coordinates deviate in the positive X direction as the factor of their Y coordinate. setX(double value)
y It is a double type property. It represents the multiplier by which the coordinates deviate in the positive Y direction as the factor of their X coordinate. setY(double value)

Constructors

The class contains three constructors

  1. public Shear() : creates a new instance of Shear with the default parameters.
  2. public Shear(double x, double y) : creates a new instance with the specified offset coordinates. The pivot coordinates are set to (0,0).
  3. public Shear(double x, double y, double pivotX, double pivotY) : creates a new instance with the specified offset coordinates and pivot coordinates.

Example:

The following example illustrates the implementation of Shearing Transformation. Here, we have created three rectangles which are filled with the blue, dark-grey and pink color respectively. The dark-grey rectangle is the original one while the blue rectangle is X-sheared and the pink rectangle is Y-sheared.


JavaFX Shearing



Contact US

Email:[email protected]

JavaFX Shearing
10/30