當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


p5.js shininess()用法及代碼示例

p5.j​​s中的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); 
}

輸出:
shininess-slider

在線編輯: https://editor.p5js.org/

環境設置: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/

參考: https://p5js.org/reference/#/p5/shininess




相關用法


注:本文由純淨天空篩選整理自sayantanm19大神的英文原創作品 p5.js | shininess() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。