Open In App

p5.js shininess() Function

The shininess() function in p5.js is used to specify the amount of gloss that would be present on the surface of shapes. It is used with the combination of the specularMaterial() function for setting material properties.

Syntax:



shininess( shine )

Parameters: This function accept a single parameter as mentioned above and described below.

Below example illustrates the shininess() function in p5.js:



Example:




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);
}

Output:

Online editor: https://editor.p5js.org/

Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/amp/

Reference: https://p5js.org/reference/#/p5/shininess

Article Tags :