p5.js中的shininess()函數用於指定形狀表麵上的光澤度。與specularMaterial()函數組合使用以設置材料屬性。
用法:
shininess( shine )
參數:該函數接受如上所述和以下描述的單個參數。
- shine:它是一個數字,指定元素的發光程度。預設值為1。
以下示例說明了p5.js中的shininess()函數:
例:
let newFont;
function preload() {
newFont = loadFont('fonts/Montserrat.otf');
}
function setup() {
createCanvas(500, 300, WEBGL);
shineInput = createSlider(0, 100, 50, 1);
shineInput.position(20, 40);
textFont(newFont);
textSize(20);
}
function draw() {
background('green');
text("Move the slider to change the shininess value", -235, -125);
noStroke();
ambientLight(60, 60, 60);
pointLight(255, 255, 255, width / 2, height / 2, 75);
specularMaterial(250);
shininess(shineInput.value());
sphere(75);
}
輸出:
在線編輯: https://editor.p5js.org/
環境設置: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
參考: https://p5js.org/reference/#/p5/shininess
相關用法
- PHP each()用法及代碼示例
- PHP Ds\Set add()用法及代碼示例
- p5.js sin()用法及代碼示例
- CSS hsl()用法及代碼示例
- PHP Ds\Set last()用法及代碼示例
- p5.js int()用法及代碼示例
- PHP Ds\Set first()用法及代碼示例
- PHP each()用法及代碼示例
- p5.js value()用法及代碼示例
- p5.js box()用法及代碼示例
- PHP key()用法及代碼示例
注:本文由純淨天空篩選整理自sayantanm19大神的英文原創作品 p5.js | shininess() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。