HomeLanguagesJavascriptp5.js Typography shearY() Function

p5.js Typography shearY() Function

The shearY() function in p5.js is used to shear a shape or object around the y-axis. The object is sheared by the amount specified by the angle parameter. For proper functioning of angles should be specified in the current angleMode. The objects are always sheared around their relative position to the origin and in a clockwise direction.

Syntax:

shearY(angle)

Parameters: This function accepts single parameter angle which stores the value of angle.

Below programs illustrate the shearY() function in p5.js:

Example 1: This example uses shearY() function to shear the object around y-axis.




function setup() {
  
    // Create Canvas of given size
    createCanvas(780, 650);
}
  
function draw() {
      
    // Set the background color
    background(220);
      
    // Set fill color
    fill('lightgreen');
      
    // Set stroke width
    strokeWeight(5);
      
    // Set shearY function
    shearY(PI/6);
      
    // Finally Draw the sheared rectangle
    rect(30, 30, 400, 300);
}


Output:

Example 2: This example uses shearY() function to shear the object around y-axis.




function setup() {
      
    // Create Canvas of given size
    createCanvas(780, 650);
}
  
function draw() {
      
    // Set the background color
    background(220);
      
    // Set fill color
    fill('lightgreen');
      
    // Set stroke width
    strokeWeight(5);
      
    // Set shearY function
    shearY(PI/9);
      
    // Finally Draw the sheared
    // circle of radius 80 
    circle(height/2, width/2, 80);
}


Output:

Reference: https://p5js.org/reference/#/p5/shearY

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

3 COMMENTS

Most Popular

Dominic
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS