p5.js strokeJoin() function
Last Updated :
11 Aug, 2023
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() {
createCanvas(380, 170);
}
function draw() {
background(220);
strokeWeight(12);
strokeJoin(ROUND);
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() {
createCanvas(380, 170);
}
function draw() {
background(220);
strokeWeight(10);
strokeJoin(BEVEL);
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...