noTint()函數用於刪除以前使用tint()函數應用的圖像的填充值。它將恢複圖像的色彩並以其原始色調顯示它們。
用法:
noTint()
參數:該函數不接受任何參數。
以下示例說明了p5.js中的noTint()函數:
範例1:
function preload() {
img = loadImage('sample-image.png');
}
function setup() {
createCanvas(600, 300);
textSize(22);
}
function draw() {
clear();
text("Using the tint() function", 20, 20);
tint("red");
image(img, 20, 40);
text("Using the noTint() function", 20, 170);
noTint()
image(img, 20, 180);
}
輸出:
範例2:
function preload() {
img = loadImage('sample-image.png');
disableTint = false;
}
function setup() {
createCanvas(600, 300);
textSize(22);
// Create a button for toggling the
// noTint() function
removeBtn = createButton("Toggle using noTint");
removeBtn.position(30, 200)
removeBtn.mousePressed(removeTint);
}
function draw() {
clear();
text("Click on the button to use the noTint() function", 20, 20);
text("Using noTint():" + disableTint, 20, 40);
// Check if the boolean value is true
// to use the noTint() function
// in this draw loop
if (disableTint) noTint();
image(img, 30, 60);
// Using the tint() function here
// would tint the image in the next
// draw loop
tint("red");
}
function removeTint() {
// Toggle the use of noTint()
disableTint = !disableTint;
}
輸出:
在線編輯: https://editor.p5js.org/
環境設置: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
參考: https://p5js.org/reference/#/p5/notint
相關用法
- p5.js nf()用法及代碼示例
- p5.js box()用法及代碼示例
- PHP dir()用法及代碼示例
- PHP pi( )用法及代碼示例
- p5.js nfc()用法及代碼示例
- CSS rgb()用法及代碼示例
- PHP Ds\Set xor()用法及代碼示例
- PHP pow( )用法及代碼示例
- p5.js nfp()用法及代碼示例
- p5.js nfs()用法及代碼示例
- p5.js cos()用法及代碼示例
- d3.js d3.map.set()用法及代碼示例
注:本文由純淨天空篩選整理自sayantanm19大神的英文原創作品 p5.js | noTint() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。