使用beginContour()函數創建計數時,p5.js中的endContour()函數用於停止記錄頂點。這些函數用於從另一種形狀中除去一部分形狀。
內部形狀的頂點必須在與外部形狀相反的方向上定義。如果外部形狀具有按順時針順序定義的頂點,則內部形狀必須沿逆時針方向定義。然後使用此函數停止記錄內部形狀。
該函數隻能在beginShape()或endShape()函數內使用。 translate(),rotate()和scale()之類的轉換不適用於形狀和輪廓。
用法:
endContour()
參數:此函數不接受任何參數。
以下程序說明了p5.js中的endContour()函數:
例:
function setup() {
createCanvas(400, 300);
textSize(16);
}
function draw() {
clear();
background("green");
text("The inside of the letter is cut out"+
" using a countour", 10, 20);
// Starting the shape
// using beginShape()
beginShape();
// Specifying all the vertices
// of the exterior shape
vertex(40, 240);
vertex(100, 50);
vertex(130, 50);
vertex(200, 240);
vertex(160, 240);
vertex(140, 160);
vertex(100, 160);
vertex(75, 240);
// Starting a contour
beginContour();
// Specifying all the vertices
// of the interior shape
// in counter-clockwise order
vertex(130, 135);
vertex(115, 90);
vertex(105, 135);
// Ending the contour
// using endContour()
endContour();
// Ending the shape
endShape(CLOSE);
}
輸出:
在線編輯: https://editor.p5js.org/
環境設置: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
參考: https://p5js.org/reference/#/p5/endContour
相關用法
- PHP dir()用法及代碼示例
- PHP Ds\Set add()用法及代碼示例
- PHP next()用法及代碼示例
- PHP Ds\Set first()用法及代碼示例
- p5.js arc()用法及代碼示例
- PHP exp()用法及代碼示例
- p5.js hex()用法及代碼示例
- PHP Ds\Set last()用法及代碼示例
- d3.js d3.set.has()用法及代碼示例
- PHP Ds\Set contains()用法及代碼示例
- PHP Ds\Map xor()用法及代碼示例
- PHP each()用法及代碼示例
- p5.js nfs()用法及代碼示例
- p5.js mag()用法及代碼示例
- p5.js pan()用法及代碼示例
- p5.js value()用法及代碼示例
注:本文由純淨天空篩選整理自sayantanm19大神的英文原創作品 p5.js | endContour() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。