p5.js strokeWeight() function Last Updated : 11 Aug, 2023 Comments Improve Suggest changes Like Article Like Report The strokeWeight() function in p5.js is used to set the width of the stroke used for lines, points and the border around shapes. The stroke weight is set by using pixels. Syntax: strokeWeight(weight) Parameters: This function accepts a single parameter weight which stores the weight (in pixels) of the stroke. The below programs illustrate the strokeWeight() function in p5.js: Example 1: This example uses strokeWeight() function to set the width of the stroke. javascript function setup() { // Create Canvas of given size createCanvas(380, 170); } function draw() { // Set the background color background(220); // Set the stroke width strokeWeight(20); // Set the filled color fill('green'); // Draw the circle circle(60, 60, 34); // Set the text size textSize(20); // Set the text to print text("GeeksForGeeks", 120, 70); } Output: Example 2: This example uses strokeWeight() function to set the width of the stroke. javascript function setup() { // Create Canvas of given size createCanvas(380, 170); } function draw() { // Set the background color background(220); // Set the stroke color stroke('orange'); // Set the stroke width to 10 strokeWeight(10); // Orange // Draw a line line(20, 70, 80, 70); // Set the stroke color stroke('white'); // Set the stroke width to 8 strokeWeight(8); // White // Draw a line line(20, 90, 80, 90); // Set stroke color stroke('green'); // Set the stroke width to 6 strokeWeight(6); // Green // Draw a line line(20, 110, 80, 110); } Output: Reference: https://p5js.org/reference/#/p5/strokeWeight Comment More infoAdvertise with us Next Article p5.js strokeWeight() function S sarthak_ishu11 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-p5.js Similar Reads p5.js stroke() Function The stroke() function is used to draw the lines and border around the text and shapes. The color object can be set in terms of RGB or HSB depending on the color mode. The color object can also be set as string in terms of RGB, RGBA, Hex CSS color or named color string. Syntax: stroke( v1, v2, v3, al 2 min read 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 funct 2 min read p5.js strokeCap() Function The strokeCap() function in p5.js is used to set the style of line endings. The ends of line can be rounded, squared or extended based on their parameters SQUARE, PROJECT, and ROUND. The default value is ROUND. Syntax: strokeCap( cap ) Parameters: This function accepts single parameter cap which hol 1 min read p5.js textWidth() Function The textWidth() function is used to calculate the width of the text given as parameter. Syntax: textWidth( theText ) Parameters: This function accepts a single parameter as mentioned above and described below: theText: It holds the string of which the width has to be measured. Return Value: It retu 2 min read p5.js point() Function The point() function is an inbuilt function in p5.js which is used to draw the point in a given coordinate position. Syntax: point( x, y, [z]) Parameters: This function accept three parameters which are described below x: It is used to set the x-coordinate of point. y: It is used to set the y-coordi 1 min read Like