Wednesday, July 3, 2024
HomeLanguagesJavascriptp5.js strokeJoin() function

p5.js strokeJoin() function

The strokeJoin() function in p5.js is used to set the joint style which connect the line segments. These joints are either mitered, beveled, or rounded and specified with the corresponding parameters MITER, BEVEL, and ROUND. MITER is the default joint.

Syntax:

strokeJoin(join)

Parameters: This function accepts single parameter join which stores the joint parameter constant either ‘MITER’, ‘BEVEL’ or ‘ROUND’.

Below programs illustrates the strokeJoin() function in p5.js:

Example 1: This example uses strokeJoin() function to join the strokes.




function setup() {
      
    // Create Canvas of given size
    createCanvas(380, 170);
}
  
function draw() {
      
    // Set the background color
    background(220);
      
    // Set the stroke weight
    strokeWeight(12);
      
    // Set strokeJoin function
    strokeJoin(ROUND);
      
    // Function to create line segment
    line(20, 30, 200, 30);
    line(200, 30, 200, 100);
    line(200, 100, 20, 30);
}


Output:

Example 2: This example uses strokeJoin() function to join the strokes.




function setup() {
      
    // Create Canvas of given size
    createCanvas(380, 170);
}
  
function draw() {
      
    // Set the background color
    background(220);
      
    // Set the stroke weight
    strokeWeight(10);
      
    // Set strokeJoin function
    strokeJoin(BEVEL);
      
    // Function to create line segment
    line(20, 30, 200, 30);
    line(200, 30, 200, 100);
    line(200, 100, 20, 100);
    line(20, 100, 20, 30);
}


Output:

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

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!

Shaida Kate Naidoo
am passionate about learning the latest technologies available to developers in either a Front End or Back End capacity. I enjoy creating applications that are well designed and responsive, in addition to being user friendly. I thrive in fast paced environments. With a diverse educational and work experience background, I excel at collaborating with teams both local and international. A versatile developer with interests in Software Development and Software Engineering. I consider myself to be adaptable and a self motivated learner. I am interested in new programming technologies, and continuous self improvement.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments