p5.js中的noErase()函數用於取消erase()函數的效果。它將使fill(),stroke()和blendMode()函數的函數恢複為使用erase()之前的函數。在此函數之後完成的任何繪製都將正常繪製。
用法:
noErase()
參數:該函數不接受任何參數。
下麵的示例說明了p5.js中的noErase()函數:
例:
function setup() {
createCanvas(600, 400);
textSize(20);
firstBlockSlider = createSlider(50, 250, 75, 1);
firstBlockSlider.position(30, 50);
secondBlockSlider = createSlider(50, 250, 175, 1);
secondBlockSlider.position(30, 120);
}
function draw() {
clear();
fill('black');
text("Move the slider below to change the"
+ " first block's position", 20, 30);
text("Move the slider below to change the"
+ " second block's position", 20, 100);
text("The black circle demonstrates the"
+ " erase area", 20, 170);
fill('red');
rect(firstBlockSlider.value(), 200, 50, 100);
// Start erasing with erase()
erase();
circle(150, 250, 100);
// Stop erasing with noErase()
noErase();
fill('red');
rect(secondBlockSlider.value(), 200, 50, 100);
// Circle to illustrate the erase position
noFill();
circle(150, 250, 100);
}
輸出:
環境設置: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
相關用法
- p5.js mag()用法及代碼示例
- p5.js value()用法及代碼示例
- p5.js box()用法及代碼示例
- PHP Ds\Map put()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
- PHP Ds\Map xor()用法及代碼示例
- PHP ord()用法及代碼示例
- p5.js nfs()用法及代碼示例
- p5.js pan()用法及代碼示例
- p5.js nf()用法及代碼示例
- PHP Ds\Set xor()用法及代碼示例
- p5.js nfc()用法及代碼示例
- p5.js nfp()用法及代碼示例
- PHP each()用法及代碼示例
- d3.js d3.set.add()用法及代碼示例
- p5.js arc()用法及代碼示例
注:本文由純淨天空篩選整理自sayantanm19大神的英文原創作品 p5.js | noErase() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。