p5.js中的strokeJoin()函數用於設置連接線段的關節樣式。這些關節可以斜切,斜切或倒圓,並使用相應的參數MITER,BEVEL和ROUND指定。 MITER是默認關節。
用法:
strokeJoin(join)
參數:該函數接受單個參數聯接,該聯接存儲聯接參數常量“ MITER”,“ BEVEL”或“ ROUND”。
以下程序說明了p5.js中的strokeJoin()函數:
示例1:本示例使用strokeJoin()函數來合並筆觸。
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);
}
輸出:
示例2:本示例使用strokeJoin()函數來合並筆觸。
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);
}
輸出:
參考: https://p5js.org/reference/#/p5/strokeJoin
相關用法
- p5.js cos()用法及代碼示例
- PHP each()用法及代碼示例
- p5.js sq()用法及代碼示例
- p5.js pow()用法及代碼示例
- p5.js day()用法及代碼示例
- PHP pos()用法及代碼示例
- p5.js sin()用法及代碼示例
- p5.js tan()用法及代碼示例
- PHP key()用法及代碼示例
- p5.js log()用法及代碼示例
- CSS hsl()用法及代碼示例
- PHP Ds\Map put()用法及代碼示例
注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 p5.js | strokeJoin() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。