Sets the specular color for lights.
specularColor()
affects lights that bounce off a surface in a preferred direction. These lights include directionalLight(), pointLight(), and spotLight(). The function helps to create highlights on p5.Geometry objects that are styled with specularMaterial(). If a geometry does not use specularMaterial(), then specularColor()
will have no effect.
Note: specularColor()
doesn’t affect lights that bounce in all directions, including ambientLight() and imageLight().
There are three ways to call specularColor()
with optional parameters to set the specular highlight color.
The first way to call specularColor()
has two optional parameters, gray
and alpha
. Grayscale and alpha values between 0 and 255, as in specularColor(50)
or specularColor(50, 80)
, can be passed to set the specular highlight color.
The second way to call specularColor()
has one optional parameter, color
. A p5.Color object, an array of color values, or a CSS color string can be passed to set the specular highlight color.
The third way to call specularColor()
has four optional parameters, v1
, v2
, v3
, and alpha
. RGBA, HSBA, or HSLA values, as in specularColor(255, 0, 0, 80)
, can be passed to set the specular highlight color. Color values will be interpreted using the current colorMode().
Examples
Syntax
specularColor(v1, v2, v3)
specularColor(gray)
specularColor(value)
specularColor(values)
specularColor(color)
Parameters
red or hue value in the current colorMode().
green or saturation value in the current colorMode().
blue, brightness, or lightness value in the current colorMode().
grayscale value between 0 and 255.
color as a CSS string.
color as an array of RGBA, HSBA, or HSLA values.
color as a p5.Color object.