How to set the angle of skew on the Y-axis of a Circle using FabricJS?

In this tutorial, we are going to learn how to set the angle of skew on Y-axis of a Circle using FabricJS. Circle is one of the various shapes provided by FabricJS. In order to create a circle, we will have to create an instance of fabric.Circle class and add it to the canvas. Our circle object can be customized in various ways like changing its dimensions, adding a background color or by changing the angle of skew on Y-axis. We can do this by using the skewY property.

Syntax

new fabric.Circle({ skewY: Number }: Object)

Parameters

  • options (optional) ? This parameter is an Object which provides additional customizations to our circle. Using this parameter, properties such as colour, cursor, stroke width and a lot of other properties can be changed related to the object of which skewY is a property.

Property Details

  • skewY ? This property accepts a Number which determines the angle of skew on Y-axis of an object. The value is specified in degrees and creates a vertical distortion effect.

Example 1: Circle Without skewY Property

Let's see an example to understand how our circle object appears when the skewY property is not applied. In this case, there will be no distortion by any angle in our circle object.

<!DOCTYPE html>
<html>
   <head>
      <!-- Adding the Fabric JS Library-->
      <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/510/fabric.min.js"></script>
   </head>

   <body>
      <h2>Setting the angle of skew on the Y-axis of a circle using FabricJS</h2>
      <p>Here we have not applied the <b>skewY</b> property, hence there is no distortion in the object.</p>
      <canvas id="canvas"></canvas>

      <script>
         // Initiate a canvas instance
         var canvas = new fabric.Canvas("canvas");
         var circle = new fabric.Circle({
            left: 50,
            top: 90,
            radius: 50,
            fill: "#ccccff",
            stroke: "#7b68ee",
            strokeWidth: 5
         });
         canvas.add(circle);
         canvas.setWidth(document.body.scrollWidth);
         canvas.setHeight(250);
      </script>
   </body>
</html>

Example 2: Circle With skewY Property

In this example, we will see how we can assign a numerical value to the skewY property. The value that is being passed will determine the distortion along the Y-axis. Since we have assigned the skewY property a value of 30, the effect will be as if the circle object has been pinched across the corner vertically to make a 30-degree angle.

<!DOCTYPE html>
<html>
   <head>
      <!-- Adding the Fabric JS Library-->
      <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/510/fabric.min.js"></script>
   </head>

   <body>
      <h2>Setting the angle of skew on Y-axis of circle using FabricJS</h2>
      <p>Notice the circle here has skewed on the Y-axis at an angle of 30 degrees, as we have set <b>skewY</b> at 30.</p>
      <canvas id="canvas"></canvas>

      <script>
         // Initiate a canvas instance
         var canvas = new fabric.Canvas("canvas");
         var circle = new fabric.Circle({
            left: 50,
            top: 90,
            radius: 50,
            fill: "#ccccff",
            stroke: "#7b68ee",
            strokeWidth: 5,
            skewY: 30
         });
         canvas.add(circle);
         canvas.setWidth(document.body.scrollWidth);
         canvas.setHeight(250);
      </script>
   </body>
</html>

Key Points

  • The skewY property creates a vertical distortion effect on the circle

  • Positive values skew the object in one direction, while negative values skew in the opposite direction

  • The skew transformation affects the visual appearance but doesn't change the object's actual dimensions

Conclusion

The skewY property in FabricJS allows you to create vertical distortion effects on circle objects. By adjusting the numerical value, you can control the degree of skew transformation applied along the Y-axis.

Updated on: 2026-03-15T23:19:00+05:30

283 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements