p5.js shininess() Function
Last Updated :
23 Aug, 2023
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.
- shine: It is a number that specifies how much an element shines. The default value is 1.
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/
Reference: https://p5js.org/reference/#/p5/shininess
Share your thoughts in the comments
Please Login to comment...